From c99aeba70860d963caeb3ee892c608d7d1c9b655 Mon Sep 17 00:00:00 2001 From: Felipe M Date: Tue, 11 Aug 2020 12:57:56 +0200 Subject: [PATCH] Bugfixes --- butterrobot/app.py | 7 ++++++- butterrobot/lib/telegram.py | 2 +- butterrobot/plugins.py | 3 ++- docker/Dockerfile | 2 +- pyproject.toml | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/butterrobot/app.py b/butterrobot/app.py index 891c456..e051f66 100644 --- a/butterrobot/app.py +++ b/butterrobot/app.py @@ -7,6 +7,7 @@ import structlog import butterrobot.logging from butterrobot.config import SLACK_TOKEN, LOG_LEVEL, ENABLED_PLUGINS +from butterrobot.objects import Message from butterrobot.plugins import get_available_plugins from butterrobot.platforms import PLATFORMS from butterrobot.platforms.base import Platform @@ -50,7 +51,11 @@ async def incoming_platform_message_view(platform, path=None): for plugin in enabled_plugins: if result := await plugin.on_message(message): - await available_platforms[platform].methods.send_message(result) + if isinstance(result, Message): + result = [result] + + for message in result: + await available_platforms[platform].methods.send_message(result) return {} diff --git a/butterrobot/lib/telegram.py b/butterrobot/lib/telegram.py index cd082b9..ac2bd21 100644 --- a/butterrobot/lib/telegram.py +++ b/butterrobot/lib/telegram.py @@ -31,7 +31,7 @@ class TelegramAPI: async with session.post(url, json=payload) as response: response = await response.json() if not response["ok"]: - raise cls.TelegramClientError + raise cls.TelegramClientError(response) @classmethod async def send_message( diff --git a/butterrobot/plugins.py b/butterrobot/plugins.py index b9dc5a0..b2752e8 100644 --- a/butterrobot/plugins.py +++ b/butterrobot/plugins.py @@ -4,13 +4,14 @@ from abc import abstractclassmethod import structlog +from butterrobot.objects import Message logger = structlog.get_logger(__name__) class Plugin: @abstractclassmethod - def on_message(cls, message): + async def on_message(cls, message: Message): pass diff --git a/docker/Dockerfile b/docker/Dockerfile index 398c43c..54c2ede 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.11 ENV PYTHON_VERSION=3.8.2-r1 ENV APP_PORT 8080 -ENV BUTTERROBOT_VERSION 0.0.2a3 +ENV BUTTERROBOT_VERSION 0.0.2a4 ENV EXTRA_DEPENDENCIES "" COPY bin/start-server.sh /usr/local/bin/start-server diff --git a/pyproject.toml b/pyproject.toml index 4db62fb..0bcd2c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "butterrobot" -version = "0.0.2a3" +version = "0.0.2a4" description = "What is my purpose?" authors = ["Felipe Martin "] license = "GPL-2.0"