Use a dictionary for greetings, making it easier to change them
This commit is contained in:
parent
b987f3f381
commit
b4264e1018
1 changed files with 13 additions and 21 deletions
34
tweeter.py
34
tweeter.py
|
@ -28,28 +28,20 @@ while True:
|
||||||
original = int(status[0])
|
original = int(status[0])
|
||||||
recipient = status[2]
|
recipient = status[2]
|
||||||
comment = status[3]
|
comment = status[3]
|
||||||
try:
|
greetings = {
|
||||||
greeting = random.randint(1,9)
|
0: "Es ist soweit."
|
||||||
if greeting == 1:
|
1: "Die Zeit ist gekommen."
|
||||||
text = "Es ist soweit."
|
2: "Los geht's."
|
||||||
elif greeting == 2:
|
3: "Du wolltest geweckt werden. Ich wecke."
|
||||||
text = "Die Zeit ist gekommen."
|
4: "*aufweck*"
|
||||||
elif greeting == 3:
|
5: "Hopp, aufstehen!"
|
||||||
text = "Los geht's."
|
6: "*BUMM*"
|
||||||
elif greeting == 4:
|
7: "Guten Tag. Hier spricht die Polizei!"
|
||||||
text = "Du wolltest geweckt werden. Ich wecke."
|
8: "Guten Morgen. :P"
|
||||||
elif greeting == 5:
|
}
|
||||||
text = "*aufweck*"
|
|
||||||
elif greeting == 6:
|
|
||||||
text = "Hopp, aufstehen!"
|
|
||||||
elif greeting == 7:
|
|
||||||
text = "*BUMM*"
|
|
||||||
elif greeting == 8:
|
|
||||||
text = "Guten Tag. Hier spricht die Polizei!"
|
|
||||||
else:
|
|
||||||
text = "Guten Morgen. :P"
|
|
||||||
|
|
||||||
api.update_status("@%s %s %s" % (recipient, text, comment) [:140], original)
|
try:
|
||||||
|
api.update_status("@%s %s %s" % (recipient, greetings.get(random.randint(0,len(dict)-1)), comment) [:140], original)
|
||||||
cur.execute("UPDATE tweets SET sent = 1 WHERE tweet_id = %i" % original)
|
cur.execute("UPDATE tweets SET sent = 1 WHERE tweet_id = %i" % original)
|
||||||
sql_conn.commit()
|
sql_conn.commit()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
Loading…
Reference in a new issue