From 1ae02d29734725f40c469f2a71ef29590e7fd605 Mon Sep 17 00:00:00 2001 From: Felipe M Date: Tue, 11 Aug 2020 13:37:17 +0200 Subject: [PATCH] Ignore messages from bots --- butterrobot/app.py | 2 +- butterrobot/objects.py | 2 +- butterrobot/platforms/slack.py | 2 +- butterrobot/platforms/telegram.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/butterrobot/app.py b/butterrobot/app.py index 8487949..6657114 100644 --- a/butterrobot/app.py +++ b/butterrobot/app.py @@ -55,7 +55,7 @@ async def incoming_platform_message_view(platform, path=None): ) return {"error": str(error)}, 400 - if not message: + if not message or message.from_bot: return {} for plugin in enabled_plugins: diff --git a/butterrobot/objects.py b/butterrobot/objects.py index 8ef22ca..926e6a7 100644 --- a/butterrobot/objects.py +++ b/butterrobot/objects.py @@ -8,7 +8,7 @@ class Message: text: Text chat: Text author: Text - is_bot: bool = False + from_bot: bool = False date: Optional[datetime] = None id: Optional[Text] = None reply_to: Optional[Text] = None diff --git a/butterrobot/platforms/slack.py b/butterrobot/platforms/slack.py index f6d1865..d40a57f 100644 --- a/butterrobot/platforms/slack.py +++ b/butterrobot/platforms/slack.py @@ -64,7 +64,7 @@ class SlackPlatform(Platform): return Message( id=data["event"].get("thread_ts", data["event"]["ts"]), author=data["event"]["user"], - is_bot="bot_id" in data["event"], + from_bot="bot_id" in data["event"], date=datetime.fromtimestamp(int(float(data["event"]["event_ts"]))), text=data["event"]["text"], chat=data["event"]["channel"], diff --git a/butterrobot/platforms/telegram.py b/butterrobot/platforms/telegram.py index 602fd33..a83c9b6 100644 --- a/butterrobot/platforms/telegram.py +++ b/butterrobot/platforms/telegram.py @@ -61,7 +61,7 @@ class TelegramPlatform(Platform): id=request_data["message"]["message_id"], date=datetime.fromtimestamp(request_data["message"]["date"]), text=str(request_data["message"]["text"]), - is_bot=request_data["message"]["from"]["is_bot"], + from_bot=request_data["message"]["from"]["from_bot"], author=request_data["message"]["from"]["id"], chat=str(request_data["message"]["chat"]["id"]), raw=request_data,