Bugfixes
This commit is contained in:
parent
1a77740845
commit
c99aeba708
5 changed files with 11 additions and 5 deletions
|
@ -7,6 +7,7 @@ import structlog
|
||||||
|
|
||||||
import butterrobot.logging
|
import butterrobot.logging
|
||||||
from butterrobot.config import SLACK_TOKEN, LOG_LEVEL, ENABLED_PLUGINS
|
from butterrobot.config import SLACK_TOKEN, LOG_LEVEL, ENABLED_PLUGINS
|
||||||
|
from butterrobot.objects import Message
|
||||||
from butterrobot.plugins import get_available_plugins
|
from butterrobot.plugins import get_available_plugins
|
||||||
from butterrobot.platforms import PLATFORMS
|
from butterrobot.platforms import PLATFORMS
|
||||||
from butterrobot.platforms.base import Platform
|
from butterrobot.platforms.base import Platform
|
||||||
|
@ -50,7 +51,11 @@ async def incoming_platform_message_view(platform, path=None):
|
||||||
|
|
||||||
for plugin in enabled_plugins:
|
for plugin in enabled_plugins:
|
||||||
if result := await plugin.on_message(message):
|
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 {}
|
return {}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TelegramAPI:
|
||||||
async with session.post(url, json=payload) as response:
|
async with session.post(url, json=payload) as response:
|
||||||
response = await response.json()
|
response = await response.json()
|
||||||
if not response["ok"]:
|
if not response["ok"]:
|
||||||
raise cls.TelegramClientError
|
raise cls.TelegramClientError(response)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def send_message(
|
async def send_message(
|
||||||
|
|
|
@ -4,13 +4,14 @@ from abc import abstractclassmethod
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
|
from butterrobot.objects import Message
|
||||||
|
|
||||||
logger = structlog.get_logger(__name__)
|
logger = structlog.get_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Plugin:
|
class Plugin:
|
||||||
@abstractclassmethod
|
@abstractclassmethod
|
||||||
def on_message(cls, message):
|
async def on_message(cls, message: Message):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ FROM alpine:3.11
|
||||||
|
|
||||||
ENV PYTHON_VERSION=3.8.2-r1
|
ENV PYTHON_VERSION=3.8.2-r1
|
||||||
ENV APP_PORT 8080
|
ENV APP_PORT 8080
|
||||||
ENV BUTTERROBOT_VERSION 0.0.2a3
|
ENV BUTTERROBOT_VERSION 0.0.2a4
|
||||||
ENV EXTRA_DEPENDENCIES ""
|
ENV EXTRA_DEPENDENCIES ""
|
||||||
|
|
||||||
COPY bin/start-server.sh /usr/local/bin/start-server
|
COPY bin/start-server.sh /usr/local/bin/start-server
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "butterrobot"
|
name = "butterrobot"
|
||||||
version = "0.0.2a3"
|
version = "0.0.2a4"
|
||||||
description = "What is my purpose?"
|
description = "What is my purpose?"
|
||||||
authors = ["Felipe Martin <me@fmartingr.com>"]
|
authors = ["Felipe Martin <me@fmartingr.com>"]
|
||||||
license = "GPL-2.0"
|
license = "GPL-2.0"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue