Yes. It's important, so I tried to avoid posting the same content, which tends to be a bot operation, so that I would say it only once.
http://qiita.com/clarinet758/items/3e245a4388ef8a752ca3
op.py
while i < 4:
#Go from newest to oldest up to the last 4 posts.
tl = tll[i].text
otu=re.compile(u'Thank you for your hard work')
oha=re.compile(u'Utilization time')
#Check if a specific word is included
if re.search(u'@xxx Good night', tl):
jk = tll[i].created_at
t = open('kanri.txt', 'w')
t.write(str(jk))
t.close()
tane = '@xxx Thank you for your hard work. Bed in%s time%I set it in about s minutes.' % (str(jk.hour+9), str(jk.minute))
m=i-1
#From the moment a specific word is found, go to the new one and look for the word that the bot is using in the reply
#If there is a specific word, it is a simple judgment, but it ends as it has been operated.
#If you do not hit after seeing the latest arrival, tweet as inactive.
while m>=0:
if re.search(otu, tll[m].text):
break
else: m-=1
# if m<=0:
if m<0:
oat.client.request('https://api.twitter.com/1.1/statuses/update.json', 'POST', urlencode({'status': tane}))
i+=5
I'll tweak variable names and things that are too dirty after tomorrow. I wonder if it is necessary to save the log if it goes back only about one digit for personal use. However, if there are many follw destinations, there is a high risk that the simple judgment word will be confused in TL, so it depends on the situation. Hmmm, I think it's easy to check only specific words at that time without saving the log.
Corrected the condition from m <= 0 to m <0 at the last judgment. If <=, when hitting with the latest remark and exiting with break, m is 0, so duplicate remarks could not be stopped.