Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no messages sent #80

Open
Geyorgiy opened this issue Mar 14, 2021 · 1 comment
Open

no messages sent #80

Geyorgiy opened this issue Mar 14, 2021 · 1 comment

Comments

@Geyorgiy
Copy link

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

@TheLonelyAstronaut
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants