Open Geyorgiy opened 3 years ago
Hi everyone, I just need to send messages to telegram without echo
#define CTBOT_DEBUG_MODE CTBOT_DEBUG_ALL #include "CTBot.h" CTBot myBot; String ssid = "ssid"; String pass = "pass"; String token = "7777777:7777777777777777777777777777"; //String chat_id ="8888888888"; TBMessage msg; void setup() { Serial.begin(9600); Serial.println("Starting TelegramBot..."); myBot.wifiConnect(ssid, pass); myBot.setTelegramToken(token); if (myBot.testConnection()) { Serial.println("\ntestConnection OK"); myBot.sendMessage(msg.sender.id, "Бот Охрана запущен"); } else { Serial.println("\ntestConnection NOK"); } } void loop() { TBMessage msg; //Led 1 Входная дверь и зал //Serial.println(digitalRead(16)); int val1 = digitalRead(16); if (val1 <1) { myBot.sendMessage(msg.sender.id, "Двери или зал"); Serial.println("Двери или зал");} // Led 1 ----------------------------------------- //if (myBot.getNewMessage(msg)) //myBot.sendMessage(msg.sender.id, msg.text); //delay(500); }
Terminal
-->sendCommand: Payload {"chat_id":999999999,"text":"Бот Охрана запущен","disable_notification":false} --->receive: HTTPS response error: --->receive: Content-Length size: 73 --->receive: start payload: {"ok":false,"error_code":400,"description":"Bad Request: chat not found"} ??????????????? --->receive: end payload --->parseResponse: response received --->parseResponse: JSON error { "ok": false, "error_code": 400, "description": "Bad Request: chat not found" ??????????????????? } --->POST: Remaining data to send: 96 --->sendCommand: Header POST /bot7777777:7777777777777777777777777777/sendMessage HTTP/1.1 Host: api.telegram.org Content-Length: 96 Content-Type: application/json
Thanks
I think you're use msg.sender.id in setup function without initializing msg variable. Also this is just bot, you cant send message to your bot directly from this bot.
Hi everyone, I just need to send messages to telegram without echo
Terminal
Thanks