2015-03-18 20:33:43 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2015-03-19 17:16:17 +00:00
|
|
|
import HTMLParser, tweepy, os, sqlite3, time, random
|
2015-03-18 20:33:43 +00:00
|
|
|
|
|
|
|
# Notice: You may want to create seperate apps (or even accounts) for
|
|
|
|
# the getter and the tweeter.
|
|
|
|
|
|
|
|
# For larger user bases, consider using multiple tweeter accounts.
|
|
|
|
|
|
|
|
cke = "Consumer Key"
|
|
|
|
cse = "Consumer Secret"
|
|
|
|
ato = "Access Token"
|
|
|
|
ase = "Access Secret"
|
|
|
|
|
|
|
|
database_filename = "Database.db"
|
|
|
|
|
|
|
|
auth = tweepy.OAuthHandler(cke, cse)
|
|
|
|
auth.set_access_token(ato, ase)
|
|
|
|
api = tweepy.API(auth)
|
|
|
|
|
|
|
|
sql_conn = sqlite3.connect(database_filename)
|
|
|
|
cur = sql_conn.cursor()
|
|
|
|
|
|
|
|
while True:
|
2015-03-18 22:41:33 +00:00
|
|
|
values = cur.execute("SELECT * FROM tweets WHERE datetime(timestamp) < datetime('now','localtime') AND sent = 0")
|
2015-03-18 20:33:43 +00:00
|
|
|
for status in values:
|
2015-03-18 20:48:26 +00:00
|
|
|
original = int(status[0])
|
2015-03-18 20:33:43 +00:00
|
|
|
recipient = status[2]
|
|
|
|
comment = status[3]
|
2015-03-19 17:16:17 +00:00
|
|
|
try:
|
2015-03-19 19:18:59 +00:00
|
|
|
greeting = random.randint(1,9)
|
2015-03-19 17:16:17 +00:00
|
|
|
if greeting == 1:
|
|
|
|
text = "Es ist soweit."
|
|
|
|
elif greeting == 2:
|
|
|
|
text = "Die Zeit ist gekommen."
|
2015-03-19 19:09:27 +00:00
|
|
|
elif greeting == 3:
|
|
|
|
text = "Los geht's."
|
|
|
|
elif greeting == 4:
|
|
|
|
text = "Du wolltest geweckt werden. Ich wecke."
|
|
|
|
elif greeting == 5:
|
|
|
|
text = "*aufweck*"
|
|
|
|
elif greeting == 6:
|
|
|
|
text = "Hopp, aufstehen!"
|
|
|
|
elif greeting == 7:
|
|
|
|
text = "*BUMM*"
|
2015-03-19 19:18:59 +00:00
|
|
|
elif greeting == 8:
|
|
|
|
text = "Guten Tag. Hier spricht die Polizei!"
|
2015-03-19 17:16:17 +00:00
|
|
|
else:
|
|
|
|
text = "Guten Morgen. :P"
|
|
|
|
|
2015-03-19 19:32:40 +00:00
|
|
|
api.update_status("@%s %s %s" % (recipient, text, comment) [:140], original)
|
2015-03-18 21:42:54 +00:00
|
|
|
cur.execute("UPDATE tweets SET sent = 1 WHERE tweet_id = %i" % original)
|
2015-03-18 21:50:03 +00:00
|
|
|
sql_conn.commit()
|
2015-03-19 18:38:33 +00:00
|
|
|
except Exception, e:
|
|
|
|
print "Error in " + str(twid)
|
|
|
|
print e
|
2015-03-18 20:48:26 +00:00
|
|
|
pass
|
2015-03-18 20:33:43 +00:00
|
|
|
|
|
|
|
time.sleep(10)
|