oncall-engine/engine/apps/telegram/updates/update_handlers/start_message.py
Innokentii Konstantinov 2c6a27154f
Support mutliregion telegram (#676)
* Support mutliregion telegram

* Fix test_personal_message

* Fix tg verification code tests

* Simplify /start cmd handler

* Comment about link with org_id in tg msg
2022-10-25 14:53:07 +08:00

23 lines
870 B
Python

from apps.telegram.client import TelegramClient
from apps.telegram.updates.update_handlers.update_handler import UpdateHandler
START_TEXT = """Hi!
This is Grafana OnCall notification bot. You can connect your Grafana OnCall account to Telegram on user settings page.
"""
class StartMessageHandler(UpdateHandler):
def matches(self) -> bool:
is_message = self.update.message is not None and self.update.message.text is not None
if not is_message:
return False
is_from_private_chat = self.update.message.chat.type == "private"
is_start_message = self.update.message.text == "/start"
return is_from_private_chat and is_start_message
def process_update(self) -> None:
telegram_client = TelegramClient()
telegram_client.send_raw_message(chat_id=self.update.effective_user.id, text=START_TEXT)