From 17df4f15e46195f67bd64e6734ca4158bc28d77b Mon Sep 17 00:00:00 2001 From: b3yond Date: Mon, 8 Oct 2018 23:32:33 +0200 Subject: [PATCH] check if mention is in reply to anything #41 --- active_bots/twitterDMs.py | 2 +- active_bots/twitterbot.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/active_bots/twitterDMs.py b/active_bots/twitterDMs.py index 36db7a4..18c7e64 100644 --- a/active_bots/twitterDMs.py +++ b/active_bots/twitterDMs.py @@ -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( diff --git a/active_bots/twitterbot.py b/active_bots/twitterbot.py index caf3ec5..0efb14f 100755 --- a/active_bots/twitterbot.py +++ b/active_bots/twitterbot.py @@ -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,