witnessmenow/Universal-Arduino-Telegram-Bot

Retrieving time

ehraz786 opened this issue · 4 comments

is retrieving time from ntp necessary?
without "time_t now" the bot doesn't receive any message.

Serial.print("Retrieving time: ");
configTime(0, 0, "pool.ntp.org");
time_t now = time(nullptr);
while (now < 24 * 3600)
{
  Serial.print(".");
  delay(100);
  now = time(nullptr);
}
Serial.println(now);
Hegy commented

Hello!
Please try to connect to another wifi device (router or hot-spot on your mobile).

Tried it.
Without retrieving the time, the bot fails to receive any message.

Hegy commented

Is your bot able to send a message without retrieving the time?

I am using the example sketch SendMessageFromEvent.ino from examples/ESP8266/SendMessageFromEvent

bot.sendMessage(CHAT_ID, "Bot started up", "");

This above line works well if the below lines are there

Serial.print("Retrieving time: ");
 configTime(0, 0, "pool.ntp.org"); // get UTC time via NTP
 time_t now = time(nullptr);
 while (now < 24 * 3600)
 {
   Serial.print(".");
   delay(100);
   now = time(nullptr);
 }
 Serial.println(now);

but fails to do anything upon removing it