renamed retweetbot & retootbot (wtf, those names)

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

View file

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

View file

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