added regex magic so twitter & masto don't mention themselves by accident
This commit is contained in:
parent
ee61ba19e6
commit
10de40549c
|
@ -77,9 +77,10 @@ class RetootBot(object):
|
||||||
self.save_last()
|
self.save_last()
|
||||||
os.rename('seen_toots.pickle.part', 'seen_toots.pickle')
|
os.rename('seen_toots.pickle.part', 'seen_toots.pickle')
|
||||||
# add mention to mentions
|
# add mention to mentions
|
||||||
|
text = re.sub("(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9-_]+)", "", status['status']['content'])
|
||||||
mentions.append(report.Report(status['account']['acct'],
|
mentions.append(report.Report(status['account']['acct'],
|
||||||
"mastodon",
|
"mastodon",
|
||||||
re.sub(r'<[^>]*>', '', status['status']['content']),
|
re.sub(r'<[^>]*>', '', text),
|
||||||
status['status']['id'],
|
status['status']['id'],
|
||||||
status['status']['created_at']))
|
status['status']['created_at']))
|
||||||
return mentions
|
return mentions
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import tweepy
|
import tweepy
|
||||||
|
import re
|
||||||
import requests
|
import requests
|
||||||
import pytoml as toml
|
import pytoml as toml
|
||||||
import trigger
|
import trigger
|
||||||
|
@ -111,9 +112,10 @@ class RetweetBot(object):
|
||||||
else:
|
else:
|
||||||
mentions = self.api.mentions_timeline(since_id=self.last_mention)
|
mentions = self.api.mentions_timeline(since_id=self.last_mention)
|
||||||
for status in mentions:
|
for status in mentions:
|
||||||
|
text = re.sub("(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9-_]+)", "", status.text)
|
||||||
reports.append(report.Report(status.author.screen_name,
|
reports.append(report.Report(status.author.screen_name,
|
||||||
"twitter",
|
"twitter",
|
||||||
status.text,
|
text,
|
||||||
status.id,
|
status.id,
|
||||||
status.created_at))
|
status.created_at))
|
||||||
return reports
|
return reports
|
||||||
|
|
Loading…
Reference in a new issue