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:
@@ -8,6 +8,8 @@ api_url = str(config("SMS_API_URL", cast=str, default=""))
|
||||
api_key = str(config("SMS_API_KEY", cast=str, default=""))
|
||||
bot_token = str(config("TG_BOT_TOKEN", cast=str, default=""))
|
||||
chat_id = str(config("TG_CHAT_ID", cast=str, default=""))
|
||||
# Optional forum topic to post into. If empty, messages go to the group's General topic.
|
||||
topic_id = str(config("TG_TOPIC_ID", cast=str, default=""))
|
||||
|
||||
|
||||
def format_mobile(mobile: str) -> str:
|
||||
@@ -88,6 +90,8 @@ def send_telegram_markdown(message: str):
|
||||
try:
|
||||
url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
|
||||
payload = {"chat_id": chat_id, "text": message, "parse_mode": "MarkdownV2"}
|
||||
if topic_id:
|
||||
payload["message_thread_id"] = topic_id
|
||||
|
||||
response = requests.post(url, data=payload)
|
||||
response.raise_for_status()
|
||||
|
||||
Reference in New Issue
Block a user