Allow Transbot to handle multi-sentence tweets.

This commit is contained in:
Klaus-Uwe Mitterer 2015-03-19 01:57:48 +01:00
parent 9afd088394
commit d01c6581dc

View file

@ -54,8 +54,21 @@ for status in timeline:
auth = tweepy.OAuthHandler(a[1], a[2])
auth.set_access_token(a[3], a[4])
api = tweepy.API(auth)
tstring = ""
curstr = ""
for word in text.split(" "):
curstr += word
if word[-1] in "!?.":
tstring += translate.Translator(to_lang=a[0]).translate(curstr)) + " "
curstr = ""
if curstr != "":
tstring += translate.Translator(to_lang=a[0]).translate(curstr))
try:
api.update_status(translate.Translator(to_lang=a[0]).translate(text).encode('utf-8')[:140])
api.update_status(tstring.encode('utf-8')[:140])
tw_counter += 1
except tweepy.error.TweepError, e:
print e