diff --git a/backend.py b/backend.py index 0578bc9..19d23db 100755 --- a/backend.py +++ b/backend.py @@ -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: diff --git a/retootbot.py b/mastodonbot.py similarity index 95% rename from retootbot.py rename to mastodonbot.py index 705ee3a..152f01e 100755 --- a/retootbot.py +++ b/mastodonbot.py @@ -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: diff --git a/retweetbot.py b/twitterbot.py similarity index 99% rename from retweetbot.py rename to twitterbot.py index d9e44e3..9eeb87c 100755 --- a/retweetbot.py +++ b/twitterbot.py @@ -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: