mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-30 15:04:18 +00:00
28 lines
826 B
Python
28 lines
826 B
Python
import logging
|
|
import telegram
|
|
from typing import *
|
|
from royalnet.serf.telegram.telegramserf import TelegramSerf, escape
|
|
from royalnet.commands import *
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class TelegramMessageEvent(Event):
|
|
name = "telegram_message"
|
|
|
|
async def run(self, chat_id, text, **kwargs) -> dict:
|
|
if not self.interface.name == "telegram":
|
|
raise UnsupportedError()
|
|
|
|
# noinspection PyTypeChecker
|
|
serf: TelegramSerf = self.interface.serf
|
|
|
|
log.debug("Forwarding message from Herald to Telegram.")
|
|
await serf.api_call(serf.client.send_message,
|
|
chat_id=chat_id,
|
|
text=escape(text),
|
|
parse_mode="HTML",
|
|
disable_web_page_preview=True)
|
|
|
|
return {}
|