renamed retweetbot & retootbot (wtf, those names)

multi-deployment
b3yond 2018-03-23 18:06:59 +01:00
parent aa5669b019
commit be118fb4bd
3 changed files with 11 additions and 11 deletions

View File

@ -6,8 +6,8 @@ import time
import sendmail
from db import DB
from retootbot import RetootBot
from retweetbot import RetweetBot
from mastodonbot import MastodonBot
from twitterbot import TwitterBot
from mailbot import Mailbot
from trigger import Trigger
@ -23,8 +23,8 @@ def get_users(db):
def init_bots(config, logger, db, users):
for uid in users:
users[uid].append(Trigger(config, uid, db))
users[uid].append(RetootBot(config, logger, uid, db))
users[uid].append(RetweetBot(config, logger, uid, db))
users[uid].append(MastodonBot(config, logger, uid, db))
users[uid].append(TwitterBot(config, logger, uid, db))
users[uid].append(Mailbot(config, logger, uid, db))
return users
@ -46,7 +46,7 @@ def run():
for bot in users[uid]:
reports = bot.crawl()
for status in reports:
if not trigger.is_ok(status.text):
if not users[uid][0].is_ok(status.text):
continue
for bot2 in users[uid]:
if bot == bot2:

View File

@ -9,7 +9,7 @@ import report
from user import User
class RetootBot(object):
class MastodonBot(object):
def __init__(self, config, logger, uid, db):
self.config = config
self.logger = logger
@ -35,11 +35,11 @@ class RetootBot(object):
"""
mentions = []
try:
all = self.m.notifications()
notifications = self.m.notifications()
except: # mastodon.Mastodon.MastodonAPIError is unfortunately not in __init__.py
self.logger.error("Unknown Mastodon API Error.", exc_info=True)
return mentions
for status in all:
for status in notifications:
if status['type'] == 'mention' and status['status']['id'] > self.seen_toots:
# save state
self.seen_toots = status['status']['id']
@ -94,7 +94,7 @@ if __name__ == '__main__':
config = backend.get_config()
trigger = trigger.Trigger(config)
bot = RetootBot(config)
bot = MastodonBot(config)
try:
while True:

View File

@ -8,7 +8,7 @@ import report
from user import User
class RetweetBot(object):
class TwitterBot(object):
"""
This bot retweets all tweets which
1) mention him,
@ -190,7 +190,7 @@ if __name__ == "__main__":
trigger = trigger.Trigger(config)
# initialise twitter bot
bot = RetweetBot(config)
bot = TwitterBot(config)
try:
while True: