implemented trigger in main flow
This commit is contained in:
parent
f4759545ad
commit
9f675683b5
1
last_mention
Normal file
1
last_mention
Normal file
|
@ -0,0 +1 @@
|
||||||
|
876122799538147328
|
|
@ -6,7 +6,7 @@ import trigger
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
class Retweetbot(object):
|
class RetweetBot(object):
|
||||||
"""
|
"""
|
||||||
This bot retweets all tweets which
|
This bot retweets all tweets which
|
||||||
1) mention him,
|
1) mention him,
|
||||||
|
@ -155,15 +155,14 @@ class Retweetbot(object):
|
||||||
|
|
||||||
for status in mentions:
|
for status in mentions:
|
||||||
# Is the Text of the Tweet in the triggerlist?
|
# Is the Text of the Tweet in the triggerlist?
|
||||||
should_retweet = self.trigger.check_string(status.text)
|
if self.trigger.check_string(status.text):
|
||||||
|
# Retweet status
|
||||||
# Retweet status
|
|
||||||
if should_retweet:
|
|
||||||
mastodon.append(self.retweet(status))
|
mastodon.append(self.retweet(status))
|
||||||
|
|
||||||
# save the id so it doesn't get crawled again
|
# save the id so it doesn't get crawled again
|
||||||
self.last_mention = status.id
|
self.last_mention = status.id
|
||||||
print self.last_mention
|
print self.last_mention
|
||||||
|
# Return Retweets for tooting on mastodon
|
||||||
return mastodon
|
return mastodon
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
@ -176,7 +175,7 @@ class Retweetbot(object):
|
||||||
|
|
||||||
if __name__ == "main":
|
if __name__ == "main":
|
||||||
# create an Api object
|
# create an Api object
|
||||||
bot = Retweetbot()
|
bot = RetweetBot()
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
bot.flow()
|
bot.flow()
|
||||||
|
|
|
@ -3,6 +3,7 @@ import time
|
||||||
|
|
||||||
from retootbot import RetootBot
|
from retootbot import RetootBot
|
||||||
from retweetbot import RetweetBot
|
from retweetbot import RetweetBot
|
||||||
|
from trigger import Trigger
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -10,8 +11,10 @@ if __name__ == '__main__':
|
||||||
with open('ticketfrei.cfg') as configfile:
|
with open('ticketfrei.cfg') as configfile:
|
||||||
config = toml.load(configfile)
|
config = toml.load(configfile)
|
||||||
|
|
||||||
|
trigger = Trigger()
|
||||||
|
|
||||||
mbot = RetootBot(config)
|
mbot = RetootBot(config)
|
||||||
tbot = RetweetBot()
|
tbot = RetweetBot(config, trigger=trigger)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
statuses = []
|
statuses = []
|
||||||
|
|
Loading…
Reference in a new issue