check if mention is in reply to anything #41

coc
b3yond 2018-10-08 23:32:33 +02:00
parent b5de7cde9f
commit 17df4f15e4
2 changed files with 5 additions and 7 deletions

View File

@ -42,7 +42,7 @@ class TwitterBot(Bot):
if last_dm is None:
mentions = api.direct_messages()
else:
mentions = api.mentions_timeline(since_id=last_dm[0])
mentions = api.direct_messages(since_id=last_dm[0])
user.set_last_twitter_request(time())
for status in mentions:
text = re.sub(

View File

@ -29,7 +29,6 @@ class TwitterBot(Bot):
:return: reports: (list of report.Report objects)
"""
reports = []
#global last_twitter_request
try:
if user.get_last_twitter_request() + 60 > time():
return reports
@ -50,11 +49,10 @@ class TwitterBot(Bot):
mentions = api.mentions_timeline(since_id=last_mention)
user.set_last_twitter_request(time())
for status in mentions:
text = re.sub(
"(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9-_]+)",
"", status.text)
username = "@" + api.me().screen_name
if username in status.text:
if status._json['in_reply_to_status_id'] == None:
text = re.sub(
"(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9-_]+)",
"", status.text)
reports.append(report.Report(status.author.screen_name,
self,
text,