2017-12-30 00:15:22 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-03-28 15:36:35 +00:00
|
|
|
from bot import Bot
|
|
|
|
import active_bots
|
|
|
|
from config import config
|
|
|
|
from db import db
|
2018-03-24 15:26:35 +00:00
|
|
|
import logging
|
2018-01-07 19:22:32 +00:00
|
|
|
import sendmail
|
2018-03-28 15:36:35 +00:00
|
|
|
import time
|
2018-03-23 14:51:52 +00:00
|
|
|
|
2018-03-23 10:05:24 +00:00
|
|
|
|
2018-03-24 15:26:35 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
logpath = config['logging']['logpath']
|
|
|
|
logger = logging.getLogger()
|
|
|
|
fh = logging.FileHandler(logpath)
|
|
|
|
fh.setLevel(logging.DEBUG)
|
|
|
|
logger.addHandler(fh)
|
|
|
|
|
2018-03-28 15:36:35 +00:00
|
|
|
bots = []
|
|
|
|
for ActiveBot in active_bots.__dict__.values():
|
|
|
|
if isinstance(ActiveBot, type) and issubclass(ActiveBot, Bot):
|
|
|
|
bots.append(ActiveBot())
|
2018-03-23 14:51:52 +00:00
|
|
|
|
2018-03-28 15:36:35 +00:00
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
for user in db.active_users:
|
|
|
|
for bot in bots:
|
|
|
|
reports = bot.crawl(user)
|
2018-03-23 14:51:52 +00:00
|
|
|
for status in reports:
|
2018-03-28 15:36:35 +00:00
|
|
|
if not user.is_appropriate(status):
|
2018-03-23 14:51:52 +00:00
|
|
|
continue
|
2018-03-28 21:50:55 +00:00
|
|
|
for bot2 in bots:
|
|
|
|
bot2.post(user, status)
|
2018-03-28 15:36:35 +00:00
|
|
|
time.sleep(60) # twitter rate limit >.<
|
|
|
|
except:
|
|
|
|
logger.error('Shutdown', exc_info=True)
|
2018-03-28 20:12:57 +00:00
|
|
|
mailer = sendmail.Mailer()
|
2018-03-28 15:36:35 +00:00
|
|
|
try:
|
|
|
|
mailer.send('', config['web']['contact'],
|
|
|
|
'Ticketfrei Crash Report',
|
|
|
|
attachment=config['logging']['logpath'])
|
2018-01-07 19:22:32 +00:00
|
|
|
except:
|
2018-03-28 15:36:35 +00:00
|
|
|
logger.error('Mail sending failed', exc_info=True)
|