forked from ticketfrei/ticketfrei
put in more escapes. har har har.
This commit is contained in:
parent
e476c9b2da
commit
f181545f14
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
||||||
*.swp
|
*.swp
|
||||||
|
.idea/
|
||||||
|
last_rt
|
||||||
ticketfrei.cfg
|
ticketfrei.cfg
|
||||||
seen_toots.pickle
|
seen_toots.pickle
|
||||||
seen_toots.pickle.part
|
seen_toots.pickle.part
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
__author__ = "b3yond"
|
__author__ = "b3yond"
|
||||||
|
|
||||||
import twitter
|
import twitter
|
||||||
|
import requests
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -9,7 +11,7 @@ How to get these keys is described in doc/twitter_api.md
|
||||||
|
|
||||||
After you received keys, store them in ../../api_keys, one at a line.
|
After you received keys, store them in ../../api_keys, one at a line.
|
||||||
"""
|
"""
|
||||||
with open("../../api_keys", "r") as file:
|
with open("../appkeys/ticketfrei@twitter.com", "r") as file:
|
||||||
keys = file.readlines()
|
keys = file.readlines()
|
||||||
for i in keys:
|
for i in keys:
|
||||||
print i,
|
print i,
|
||||||
|
@ -23,32 +25,58 @@ api = twitter.Api(consumer_key = keys[0].strip(),
|
||||||
|
|
||||||
|
|
||||||
# This counter is needed to keep track which was the last tweet you retweeted
|
# This counter is needed to keep track which was the last tweet you retweeted
|
||||||
last_rt = ""
|
with open("../last_rt", "r+") as file:
|
||||||
|
last_rt = file.read()
|
||||||
|
|
||||||
|
|
||||||
# Words which have to be included into the tweets for the tweet to get retweeted
|
# Words which have to be included into the tweets for the tweet to get retweeted
|
||||||
with open("../triggerwords.txt", "r") as file:
|
with open("../triggerwords", "r") as file:
|
||||||
triggers = file.readlines()
|
triggers = file.readlines()
|
||||||
|
|
||||||
|
try:
|
||||||
|
while 1:
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
while 1:
|
# Store all mentions in a list of Status Objects
|
||||||
sleep(1)
|
try:
|
||||||
|
mentions = api.GetMentions(since_id=last_rt)
|
||||||
# Store all mentions in a list of Status Objects
|
except requests.exceptions.ConnectionError:
|
||||||
mentions = api.GetMentions(since_id=last_rt)
|
done = False
|
||||||
print mentions
|
while done == False:
|
||||||
for i in mentions:
|
|
||||||
print i.user.name, i.user.id, i.text # debug
|
|
||||||
|
|
||||||
# Is the Text of the Tweet in the triggerlist?
|
|
||||||
for j in triggers:
|
|
||||||
if i.text.lower().find(j):
|
|
||||||
|
|
||||||
# Retweet status, save the id so it doesn't get crawled again
|
|
||||||
try:
|
try:
|
||||||
feedback = api.PostRetweet(i.id)
|
mentions = api.GetMentions(since_id=last_rt)
|
||||||
print feedback
|
done = True
|
||||||
except twitter.error.TwitterError:
|
except:
|
||||||
print("[ERROR] probably you already retweeted this tweet.")
|
sleep(10)
|
||||||
last_rt = i.id
|
|
||||||
break
|
print mentions
|
||||||
|
for i in mentions:
|
||||||
|
print i.user.name, i.user.id, i.text # debug
|
||||||
|
|
||||||
|
# Is the Text of the Tweet in the triggerlist?
|
||||||
|
for j in triggers:
|
||||||
|
if i.text.lower().find(j):
|
||||||
|
|
||||||
|
# Retweet status
|
||||||
|
try:
|
||||||
|
api.PostRetweet(i.id)
|
||||||
|
|
||||||
|
# This is an Error we need to get rid of. Why are tweets RTed twice?
|
||||||
|
except twitter.error.TwitterError:
|
||||||
|
print("[ERROR] probably you already retweeted this tweet.")
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
done = False
|
||||||
|
while done == False:
|
||||||
|
try:
|
||||||
|
api.PostRetweet(i.id)
|
||||||
|
done = True
|
||||||
|
except:
|
||||||
|
sleep(10)
|
||||||
|
|
||||||
|
# save the id so it doesn't get crawled again
|
||||||
|
last_rt = i.id
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
api.PostDirectMessage("Help! I broke down. restart me pls :$", "801098086005243904", "links_tech")
|
||||||
|
with open("../last_rt", "w") as file:
|
||||||
|
file.write(last_rt)
|
Loading…
Reference in a new issue