From 163fe83c8ac1633abc42162c9ab1329719face49 Mon Sep 17 00:00:00 2001 From: Marcel Walter Date: Wed, 21 Jan 2026 12:30:32 +0100 Subject: [PATCH] fix for long incoming messages and /cmd@bot_name handling --- src/Telegram.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Telegram.cpp b/src/Telegram.cpp index 244877b..9576a32 100644 --- a/src/Telegram.cpp +++ b/src/Telegram.cpp @@ -19,7 +19,7 @@ void Telegram::handleNewMessages(int numNewMessages) if (from_name == "") from_name = "Guest"; - if (text == "/send_test_action") + if (text.startsWith("/send_test_action")) { bot.sendChatAction(chat_id, "typing"); delay(4000); @@ -53,11 +53,11 @@ void Telegram::handleNewMessages(int numNewMessages) String DisplayText = cmdList[i].functionPointer(Arguments); if (DisplayText.isEmpty()) { - bot.sendMessage(chat_id, "Display text is empty!!"); + bot.sendMessage(chat_id, "Display text ist leer!!"); } else { - String Answer = "Display text is \""; + String Answer = "Display zeigt \""; Answer += DisplayText; Answer += "\"."; bot.sendMessage(chat_id, Answer); @@ -67,7 +67,7 @@ void Telegram::handleNewMessages(int numNewMessages) } } - if ((text == "/display_start") || (text == "/start") || (text == "/help")) + if (text.startsWith("/start") || text.startsWith("/help")) { String welcome = "Willkommen beim Tür-Display-Bot, " + from_name + ".\n\n"; welcome += "Hier kommen die möglichen Kommandos, die ich verstehe:\n"; @@ -97,6 +97,7 @@ void Telegram::init() Serial.println("clearing old messages"); int numNewMessages = bot.getUpdates(bot.last_message_received + 1); + bot.maxMessageLength = 2500; while (numNewMessages) { for (int i = 0; i < numNewMessages; i++) @@ -139,7 +140,7 @@ void Telegram::init() serializeJson(doc, jsonString); bot.setMyCommands(jsonString); - bot.sendMessage(TELEGRAM_BOT_OWNER, "Hi I'm online."); + bot.sendMessage(TELEGRAM_BOT_OWNER, "Hi, ich bin online."); bot_lasttime = millis(); }