check if mention is in reply to anything #41
This commit is contained in:
parent
b5de7cde9f
commit
17df4f15e4
|
@ -42,7 +42,7 @@ class TwitterBot(Bot):
|
||||||
if last_dm is None:
|
if last_dm is None:
|
||||||
mentions = api.direct_messages()
|
mentions = api.direct_messages()
|
||||||
else:
|
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())
|
user.set_last_twitter_request(time())
|
||||||
for status in mentions:
|
for status in mentions:
|
||||||
text = re.sub(
|
text = re.sub(
|
||||||
|
|
|
@ -29,7 +29,6 @@ class TwitterBot(Bot):
|
||||||
:return: reports: (list of report.Report objects)
|
:return: reports: (list of report.Report objects)
|
||||||
"""
|
"""
|
||||||
reports = []
|
reports = []
|
||||||
#global last_twitter_request
|
|
||||||
try:
|
try:
|
||||||
if user.get_last_twitter_request() + 60 > time():
|
if user.get_last_twitter_request() + 60 > time():
|
||||||
return reports
|
return reports
|
||||||
|
@ -50,11 +49,10 @@ class TwitterBot(Bot):
|
||||||
mentions = api.mentions_timeline(since_id=last_mention)
|
mentions = api.mentions_timeline(since_id=last_mention)
|
||||||
user.set_last_twitter_request(time())
|
user.set_last_twitter_request(time())
|
||||||
for status in mentions:
|
for status in mentions:
|
||||||
text = re.sub(
|
if status._json['in_reply_to_status_id'] == None:
|
||||||
"(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9-_]+)",
|
text = re.sub(
|
||||||
"", status.text)
|
"(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9-_]+)",
|
||||||
username = "@" + api.me().screen_name
|
"", status.text)
|
||||||
if username in status.text:
|
|
||||||
reports.append(report.Report(status.author.screen_name,
|
reports.append(report.Report(status.author.screen_name,
|
||||||
self,
|
self,
|
||||||
text,
|
text,
|
||||||
|
|
Loading…
Reference in a new issue