Ignore messages from bots

This commit is contained in:
Felipe M 2020-08-11 13:37:17 +02:00
parent 562d7138c0
commit 1ae02d2973
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
4 changed files with 4 additions and 4 deletions

View File

@ -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:

View File

@ -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

View File

@ -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"],

View File

@ -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,