2017-12-30 00:15:22 +00:00
|
|
|
#!/usr/bin/env python3
|
2017-07-20 20:30:43 +00:00
|
|
|
|
2017-06-17 16:15:13 +00:00
|
|
|
import pytoml as toml
|
2017-12-30 15:33:34 +00:00
|
|
|
import logger
|
2017-06-17 16:15:13 +00:00
|
|
|
import time
|
2017-12-30 00:15:22 +00:00
|
|
|
import sys
|
2017-06-17 16:15:13 +00:00
|
|
|
|
2017-06-17 18:49:30 +00:00
|
|
|
from retootbot import RetootBot
|
|
|
|
from retweetbot import RetweetBot
|
2017-06-17 20:11:44 +00:00
|
|
|
from trigger import Trigger
|
2017-06-17 18:27:53 +00:00
|
|
|
|
2017-06-17 17:37:33 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# read config in TOML format (https://github.com/toml-lang/toml#toml)
|
2017-12-30 09:32:20 +00:00
|
|
|
with open('config.toml') as configfile:
|
2017-06-17 18:49:30 +00:00
|
|
|
config = toml.load(configfile)
|
|
|
|
|
2017-06-17 23:33:47 +00:00
|
|
|
trigger = Trigger(config)
|
2017-06-17 20:11:44 +00:00
|
|
|
|
2018-01-05 09:42:31 +00:00
|
|
|
logger = logger.Logger(config)
|
2017-07-20 20:30:43 +00:00
|
|
|
|
2017-12-30 15:33:34 +00:00
|
|
|
mbot = RetootBot(config, trigger, logger)
|
|
|
|
tbot = RetweetBot(trigger, config, logger)
|
2017-06-17 18:49:30 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
statuses = []
|
|
|
|
while True:
|
|
|
|
statuses = mbot.retoot(statuses)
|
2017-06-25 19:42:06 +00:00
|
|
|
statuses = tbot.flow(statuses)
|
2017-11-24 17:11:35 +00:00
|
|
|
time.sleep(60)
|
|
|
|
except KeyboardInterrupt:
|
2017-12-30 00:15:22 +00:00
|
|
|
print("Good bye. Remember to restart the bot!")
|
2017-07-11 20:05:46 +00:00
|
|
|
except:
|
2018-01-04 11:20:59 +00:00
|
|
|
exc = sys.exc_info() # returns tuple [Exception type, Exception object, Traceback object]
|
2018-01-05 09:42:31 +00:00
|
|
|
message = logger.generate_tb(exc)
|
2018-01-04 11:20:59 +00:00
|
|
|
tbot.logger.log(message)
|
2018-01-05 09:42:31 +00:00
|
|
|
tbot.save_last_mention()
|
|
|
|
tbot.logger.shutdown(message)
|