From fd5abc748fa4f663463b143b5ed4fbfec727cf03 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 1 Jan 2020 17:55:19 +0100 Subject: [PATCH] Added missing docs --- docs/source/backends.rst | 1 + docs/source/events.rst | 1 + .../platypush/backend/chat.telegram.rst | 5 +++++ .../source/platypush/events/chat.telegram.rst | 5 +++++ .../platypush/plugins/chat.telegram.rst | 5 +++++ docs/source/plugins.rst | 1 + platypush/backend/chat/telegram.py | 22 +++++++++---------- platypush/message/event/chat/telegram.py | 4 ++-- 8 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 docs/source/platypush/backend/chat.telegram.rst create mode 100644 docs/source/platypush/events/chat.telegram.rst create mode 100644 docs/source/platypush/plugins/chat.telegram.rst diff --git a/docs/source/backends.rst b/docs/source/backends.rst index e67dc7a9d..ea5bfe428 100644 --- a/docs/source/backends.rst +++ b/docs/source/backends.rst @@ -14,6 +14,7 @@ Backends platypush/backend/bluetooth.pushserver.rst platypush/backend/button.flic.rst platypush/backend/camera.pi.rst + platypush/backend/chat.telegram.rst platypush/backend/google.fit.rst platypush/backend/google.pubsub.rst platypush/backend/gps.rst diff --git a/docs/source/events.rst b/docs/source/events.rst index d6d58201f..8f04e6982 100644 --- a/docs/source/events.rst +++ b/docs/source/events.rst @@ -13,6 +13,7 @@ Events platypush/events/bluetooth.rst platypush/events/button.flic.rst platypush/events/camera.rst + platypush/events/chat.telegram.rst platypush/events/distance.rst platypush/events/geo.rst platypush/events/google.rst diff --git a/docs/source/platypush/backend/chat.telegram.rst b/docs/source/platypush/backend/chat.telegram.rst new file mode 100644 index 000000000..5f1c66314 --- /dev/null +++ b/docs/source/platypush/backend/chat.telegram.rst @@ -0,0 +1,5 @@ +``platypush.backend.chat.telegram`` +=================================== + +.. automodule:: platypush.backend.chat.telegram + :members: diff --git a/docs/source/platypush/events/chat.telegram.rst b/docs/source/platypush/events/chat.telegram.rst new file mode 100644 index 000000000..068c54998 --- /dev/null +++ b/docs/source/platypush/events/chat.telegram.rst @@ -0,0 +1,5 @@ +``platypush.message.event.chat.telegram`` +========================================= + +.. automodule:: platypush.message.event.chat.telegram + :members: diff --git a/docs/source/platypush/plugins/chat.telegram.rst b/docs/source/platypush/plugins/chat.telegram.rst new file mode 100644 index 000000000..0f1778883 --- /dev/null +++ b/docs/source/platypush/plugins/chat.telegram.rst @@ -0,0 +1,5 @@ +``platypush.plugins.chat.telegram`` +=================================== + +.. automodule:: platypush.plugins.chat.telegram + :members: diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 2947a89a1..260cdf495 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -20,6 +20,7 @@ Plugins platypush/plugins/camera.android.ipcam.rst platypush/plugins/camera.ir.mlx90640.rst platypush/plugins/camera.pi.rst + platypush/plugins/chat.telegram.rst platypush/plugins/clipboard.rst platypush/plugins/db.rst platypush/plugins/dropbox.rst diff --git a/platypush/backend/chat/telegram.py b/platypush/backend/chat/telegram.py index 0f4416000..dfbccc21d 100644 --- a/platypush/backend/chat/telegram.py +++ b/platypush/backend/chat/telegram.py @@ -2,7 +2,7 @@ from typing import List, Optional from platypush.backend import Backend from platypush.context import get_plugin -from platypush.message.event.chat.telegram import NewMessageEvent, NewCommandMessageEvent +from platypush.message.event.chat.telegram import MessageEvent, CommandMessageEvent from platypush.plugins.chat.telegram import ChatTelegramPlugin @@ -12,8 +12,8 @@ class ChatTelegramBackend(Backend): Triggers: - * :class:`platypush.message.event.chat.telegram.NewMessageEvent` when a new message is received. - * :class:`platypush.message.event.chat.telegram.NewCommandMessageEvent` when a new command message is received. + * :class:`platypush.message.event.chat.telegram.MessageEvent` when a message is received. + * :class:`platypush.message.event.chat.telegram.CommandMessageEvent` when a command message is received. Requires: @@ -35,18 +35,18 @@ class ChatTelegramBackend(Backend): def _msg_hook(self): # noinspection PyUnusedLocal def hook(update, context): - self.bus.post(NewMessageEvent(chat_id=update.effective_chat.id, - message=self._plugin.parse_msg(update.effective_message).output, - user=self._plugin.parse_user(update.effective_user).output)) + self.bus.post(MessageEvent(chat_id=update.effective_chat.id, + message=self._plugin.parse_msg(update.effective_message).output, + user=self._plugin.parse_user(update.effective_user).output)) return hook def _command_hook(self, cmd): # noinspection PyUnusedLocal def hook(update, context): - self.bus.post(NewCommandMessageEvent(command=cmd, - chat_id=update.effective_chat.id, - message=self._plugin.parse_msg(update.effective_message).output, - user=self._plugin.parse_user(update.effective_user).output)) + self.bus.post(CommandMessageEvent(command=cmd, + chat_id=update.effective_chat.id, + message=self._plugin.parse_msg(update.effective_message).output, + user=self._plugin.parse_user(update.effective_user).output)) return hook @@ -57,7 +57,7 @@ class ChatTelegramBackend(Backend): super().run() telegram = self._plugin.get_telegram() dispatcher = telegram.dispatcher - dispatcher.add_handler(MessageHandler(Filters.text, self._msg_hook())) + dispatcher.add_handler(MessageHandler(Filters.all, self._msg_hook())) for cmd in self.commands: dispatcher.add_handler(CommandHandler(cmd, self._command_hook(cmd))) diff --git a/platypush/message/event/chat/telegram.py b/platypush/message/event/chat/telegram.py index 9aa82133a..bc7ef97b1 100644 --- a/platypush/message/event/chat/telegram.py +++ b/platypush/message/event/chat/telegram.py @@ -6,7 +6,7 @@ class TelegramEvent(Event): super().__init__(*args, chat_id=chat_id, **kwargs) -class NewMessageEvent(TelegramEvent): +class MessageEvent(TelegramEvent): """ Event triggered when a new message is received by the Telegram bot. """ @@ -14,7 +14,7 @@ class NewMessageEvent(TelegramEvent): super().__init__(*args, message=message, user=user, **kwargs) -class NewCommandMessageEvent(NewMessageEvent): +class CommandMessageEvent(MessageEvent): """ Event triggered when a new message is received by the Telegram bot. """