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

View File

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

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

View File

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

View File

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