From d47e4ccc0d16c31833635d79580896d44e5332ac Mon Sep 17 00:00:00 2001 From: Skowll Date: Sun, 24 May 2026 14:13:57 +0200 Subject: [PATCH] edit telegram_id after initial pr --- core/automation_engine.py | 12 ++++++++++-- webui/static/stats-automations.js | 6 +++--- webui/static/wishlist-tools.js | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/automation_engine.py b/core/automation_engine.py index 82329279..424c445e 100644 --- a/core/automation_engine.py +++ b/core/automation_engine.py @@ -997,7 +997,8 @@ class AutomationEngine: """Send message via Telegram Bot API.""" bot_token = config.get('bot_token', '').strip() chat_id = config.get('chat_id', '').strip() - thread_id = config.get('thread_id', '').strip() + thread_id = str(config.get('thread_id', '')).strip() + if not bot_token or not chat_id: raise ValueError("Bot token and chat ID are required for Telegram") @@ -1006,9 +1007,16 @@ class AutomationEngine: for key, value in variables.items(): message = message.replace('{' + key + '}', value) + payload = {"chat_id": chat_id, "text": message, "parse_mode": "HTML"} + if thread_id: + try: + payload["message_thread_id"] = int(thread_id) + except ValueError: + pass # invalid — fall back to main chat + resp = requests.post( f'https://api.telegram.org/bot{bot_token}/sendMessage', - json={"chat_id": chat_id, "message_thread_id": thread_id, "text": message, "parse_mode": "HTML"}, + json=payload, timeout=10, ) data = resp.json() if resp.status_code == 200 else {} diff --git a/webui/static/stats-automations.js b/webui/static/stats-automations.js index 947a8c16..56a7e06a 100644 --- a/webui/static/stats-automations.js +++ b/webui/static/stats-automations.js @@ -4315,7 +4315,7 @@ function _promptNotifyConfig(groupName) { if (type === 'discord_webhook') { config = { webhook_url: (overlay.querySelector('#deploy-notify-url')?.value || '').trim() }; } else if (type === 'telegram') { - config = { bot_token: (overlay.querySelector('#deploy-notify-token')?.value || '').trim(), chat_id: (overlay.querySelector('#deploy-notify-chat')?.value || '').trim(), thread_id: (overlay.querySelector('#deploy-notify-thread')?.value || '').trim() }; + config = { bot_token: (overlay.querySelector('#deploy-notify-token')?.value || '').trim(), chat_id: (overlay.querySelector('#deploy-notify-chat')?.value || '').trim(), thread_id: (overlay.querySelector('#deploy-notify-thread')?.value || '').trim() }; } else if (type === 'pushbullet') { config = { access_token: (overlay.querySelector('#deploy-notify-token')?.value || '').trim() }; } else { @@ -5447,7 +5447,7 @@ function _renderBlockConfigFields(slotKey, blockType, config) { if (blockType === 'telegram') { const botToken = _escAttr(config.bot_token || ''); const chatId = _escAttr(config.chat_id || ''); - const threadID = _escAttr(config.thread_id || ''); + const threadId = _escAttr(config.thread_id || ''); return `
@@ -5458,7 +5458,7 @@ function _renderBlockConfigFields(slotKey, blockType, config) {
- +
diff --git a/webui/static/wishlist-tools.js b/webui/static/wishlist-tools.js index 45e46fb4..df62111c 100644 --- a/webui/static/wishlist-tools.js +++ b/webui/static/wishlist-tools.js @@ -6530,7 +6530,7 @@ const TOOL_HELP_CONTENT = {