Added missing docs

This commit is contained in:
Fabio Manganiello 2020-01-01 17:55:19 +01:00
parent 753694a865
commit fd5abc748f
8 changed files with 31 additions and 13 deletions

View file

@ -14,6 +14,7 @@ Backends
platypush/backend/bluetooth.pushserver.rst platypush/backend/bluetooth.pushserver.rst
platypush/backend/button.flic.rst platypush/backend/button.flic.rst
platypush/backend/camera.pi.rst platypush/backend/camera.pi.rst
platypush/backend/chat.telegram.rst
platypush/backend/google.fit.rst platypush/backend/google.fit.rst
platypush/backend/google.pubsub.rst platypush/backend/google.pubsub.rst
platypush/backend/gps.rst platypush/backend/gps.rst

View file

@ -13,6 +13,7 @@ Events
platypush/events/bluetooth.rst platypush/events/bluetooth.rst
platypush/events/button.flic.rst platypush/events/button.flic.rst
platypush/events/camera.rst platypush/events/camera.rst
platypush/events/chat.telegram.rst
platypush/events/distance.rst platypush/events/distance.rst
platypush/events/geo.rst platypush/events/geo.rst
platypush/events/google.rst platypush/events/google.rst

View file

@ -0,0 +1,5 @@
``platypush.backend.chat.telegram``
===================================
.. automodule:: platypush.backend.chat.telegram
:members:

View file

@ -0,0 +1,5 @@
``platypush.message.event.chat.telegram``
=========================================
.. automodule:: platypush.message.event.chat.telegram
:members:

View file

@ -0,0 +1,5 @@
``platypush.plugins.chat.telegram``
===================================
.. automodule:: platypush.plugins.chat.telegram
:members:

View file

@ -20,6 +20,7 @@ Plugins
platypush/plugins/camera.android.ipcam.rst platypush/plugins/camera.android.ipcam.rst
platypush/plugins/camera.ir.mlx90640.rst platypush/plugins/camera.ir.mlx90640.rst
platypush/plugins/camera.pi.rst platypush/plugins/camera.pi.rst
platypush/plugins/chat.telegram.rst
platypush/plugins/clipboard.rst platypush/plugins/clipboard.rst
platypush/plugins/db.rst platypush/plugins/db.rst
platypush/plugins/dropbox.rst platypush/plugins/dropbox.rst

View file

@ -2,7 +2,7 @@ from typing import List, Optional
from platypush.backend import Backend from platypush.backend import Backend
from platypush.context import get_plugin 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 from platypush.plugins.chat.telegram import ChatTelegramPlugin
@ -12,8 +12,8 @@ class ChatTelegramBackend(Backend):
Triggers: Triggers:
* :class:`platypush.message.event.chat.telegram.NewMessageEvent` when a new message is received. * :class:`platypush.message.event.chat.telegram.MessageEvent` when a message is received.
* :class:`platypush.message.event.chat.telegram.NewCommandMessageEvent` when a new command message is received. * :class:`platypush.message.event.chat.telegram.CommandMessageEvent` when a command message is received.
Requires: Requires:
@ -35,18 +35,18 @@ class ChatTelegramBackend(Backend):
def _msg_hook(self): def _msg_hook(self):
# noinspection PyUnusedLocal # noinspection PyUnusedLocal
def hook(update, context): def hook(update, context):
self.bus.post(NewMessageEvent(chat_id=update.effective_chat.id, self.bus.post(MessageEvent(chat_id=update.effective_chat.id,
message=self._plugin.parse_msg(update.effective_message).output, message=self._plugin.parse_msg(update.effective_message).output,
user=self._plugin.parse_user(update.effective_user).output)) user=self._plugin.parse_user(update.effective_user).output))
return hook return hook
def _command_hook(self, cmd): def _command_hook(self, cmd):
# noinspection PyUnusedLocal # noinspection PyUnusedLocal
def hook(update, context): def hook(update, context):
self.bus.post(NewCommandMessageEvent(command=cmd, self.bus.post(CommandMessageEvent(command=cmd,
chat_id=update.effective_chat.id, chat_id=update.effective_chat.id,
message=self._plugin.parse_msg(update.effective_message).output, message=self._plugin.parse_msg(update.effective_message).output,
user=self._plugin.parse_user(update.effective_user).output)) user=self._plugin.parse_user(update.effective_user).output))
return hook return hook
@ -57,7 +57,7 @@ class ChatTelegramBackend(Backend):
super().run() super().run()
telegram = self._plugin.get_telegram() telegram = self._plugin.get_telegram()
dispatcher = telegram.dispatcher 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: for cmd in self.commands:
dispatcher.add_handler(CommandHandler(cmd, self._command_hook(cmd))) dispatcher.add_handler(CommandHandler(cmd, self._command_hook(cmd)))

View file

@ -6,7 +6,7 @@ class TelegramEvent(Event):
super().__init__(*args, chat_id=chat_id, **kwargs) 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. 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) 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. Event triggered when a new message is received by the Telegram bot.
""" """