forked from rpalo/fanbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (31 loc) · 1.23 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Main loop program for the Fan Bot"""
import argparse
import logging
import time
import schedule
from fanbot.fanbot import Fanbot
from fanbot import compliments, secrets
logging.basicConfig(level=logging.INFO)
def main(greeting=True):
bot = Fanbot.create_from_modules(secrets, compliments)
if greeting:
bot.hello_world()
try:
# Initially hardcoding a schedule. Could be swapped out later
# PLACE YOUR CUSTOM SCHEDULES HERE. SEE SCHEDULE MODULE DOCUMENTATION.
schedule.every(30).minutes.do(bot.respond_to_tweets)
schedule.every().day.at("10:30").do(bot.post_compliment)
while True:
schedule.run_pending()
# You can tune the sleep length too. Should be roughly the same
# as the most frequently scheduled job above
time.sleep(30*60) # seconds
except KeyboardInterrupt:
if greeting:
bot.goodbye()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Tell a FanBot what to do.")
parser.add_argument("--no-greeting", dest="greet", action='store_false',
help="Mutes initial startup message.")
args = parser.parse_args()
main(greeting=args.greet)