implemented trigger in main flow

This commit is contained in:
b3yond 2017-06-17 22:11:44 +02:00
parent f4759545ad
commit 9f675683b5
3 changed files with 10 additions and 7 deletions

1
last_mention Normal file
View file

@ -0,0 +1 @@
876122799538147328

View file

@ -6,7 +6,7 @@ import trigger
from time import sleep
class Retweetbot(object):
class RetweetBot(object):
"""
This bot retweets all tweets which
1) mention him,
@ -155,15 +155,14 @@ class Retweetbot(object):
for status in mentions:
# Is the Text of the Tweet in the triggerlist?
should_retweet = self.trigger.check_string(status.text)
# Retweet status
if should_retweet:
if self.trigger.check_string(status.text):
# Retweet status
mastodon.append(self.retweet(status))
# save the id so it doesn't get crawled again
self.last_mention = status.id
print self.last_mention
# Return Retweets for tooting on mastodon
return mastodon
def shutdown(self):
@ -176,7 +175,7 @@ class Retweetbot(object):
if __name__ == "main":
# create an Api object
bot = Retweetbot()
bot = RetweetBot()
try:
while True:
bot.flow()

View file

@ -3,6 +3,7 @@ import time
from retootbot import RetootBot
from retweetbot import RetweetBot
from trigger import Trigger
if __name__ == '__main__':
@ -10,8 +11,10 @@ if __name__ == '__main__':
with open('ticketfrei.cfg') as configfile:
config = toml.load(configfile)
trigger = Trigger()
mbot = RetootBot(config)
tbot = RetweetBot()
tbot = RetweetBot(config, trigger=trigger)
try:
statuses = []