ServerDowntimeNotifier/TelegramHandler.py

18 lines
384 B
Python
Raw Normal View History

2021-03-10 21:07:52 +00:00
import os
import telegram
import logging
class TelegramHandler:
def __init__(self):
token = os.environ['TELEGRAM_PLUTO_BOT_TOKEN']
if not token:
logging.error('The TELEGRAM_TOKEN must be set')
raise NotImplementedError
self.bot = telegram.Bot(token=token)
def sendMessage(self, recipient: str, message: str):
self.bot.sendMessage(chat_id=recipient, text=message)