Author handling in retweeter

This commit is contained in:
Klaus-Uwe Mitterer 2016-12-07 12:12:17 +01:00
parent 0b9bb2856e
commit 64cd16a640

View file

@ -1,7 +1,7 @@
import argparse, tools import argparse, tools
def getSavepoint(db, user): def getSavepoint(db, user):
db.executeQuery("SELECT max(tweet_id) FROM retweets WHERE author = '%s'" % user) db.executeQuery("SELECT MAX(tweet_id) FROM retweets WHERE LOWER(author) = '%s'" % user.lower())
try: try:
return int(db.getNext()[0]) return int(db.getNext()[0])
except: except:
@ -19,11 +19,11 @@ def retweet(user, two=tools.twObject(), db=tools.dbHelper(tools.dbpath())):
tw_counter = 0 tw_counter = 0
for status in timeline: for status in timeline:
if status.text[0] != "@" or two.whoami() in status.text: if (status.text[0] != "@" or two.whoami() in status.text) and status.text[0:2] != "RT":
timestamp = status.created_at.strftime('%Y-%m-%d %H:%M:%S') + " +0000" timestamp = status.created_at.strftime('%Y-%m-%d %H:%M:%S') + " +0000"
text = unescapeText(status.text) text = unescapeText(status.text)
db.executeQuery("INSERT INTO retweets('id','created_at','text') VALUES(" + str(status.id) + ",'" + timestamp + "','" + text + "')") db.executeQuery("INSERT INTO retweets('id','author','created_at','text') VALUES(" + str(status.id) + ",'" + user.lower() + "','" + timestamp + "','" + text + "')")
db.commit() db.commit()
two.retweet(status.id) two.retweet(status.id)