add support for group topics tg notifications
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 8s
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 8s
This commit is contained in:
@@ -12,6 +12,8 @@ telegram_loop = None
|
||||
|
||||
BOT_TOKEN = config("TG_BOT_TOKEN", default="killme", cast=str)
|
||||
CHAT_ID = config("TG_CHAT_ID", default="drake", cast=str)
|
||||
# Optional forum topic to post into. If empty, messages go to the group's General topic.
|
||||
TOPIC_ID = config("TG_TOPIC_ID", default="", cast=str)
|
||||
|
||||
if not BOT_TOKEN or not isinstance(BOT_TOKEN, str):
|
||||
raise ValueError(
|
||||
@@ -57,10 +59,14 @@ else:
|
||||
|
||||
async def send_telegram_alert(markdown_message: str):
|
||||
logger.info("[TELEGRAM] Preparing to send alert...")
|
||||
kwargs = {}
|
||||
if TOPIC_ID:
|
||||
kwargs["message_thread_id"] = int(TOPIC_ID)
|
||||
await bot.send_message(
|
||||
chat_id=str(CHAT_ID),
|
||||
text=markdown_message,
|
||||
parse_mode=ParseMode.MARKDOWN_V2,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user