tgbot-cpp
tgbot-cpp copied to clipboard
Please help
How can i send messages with timer? When i try this code:
try { printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str()); TgBot::TgLongPoll longPoll(bot); while (true) { time_t ttime = time(0); tm* local_time = localtime(&ttime); if (local_time->tm_hour == 10 && local_time->tm_min == 57) { printf("Report send in\n" + local_time->tm_hour + local_time->tm_min); bot.getEvents(). bot.getApi().sendMessage(IdAdmin, u8"Recieved message?"); } longPoll.start(); } } catch (TgBot::TgException& e) { printf("error: %s\n", e.what()); }
What i'm doing wrong?
The function longPoll.start() blocks for 10 seconds by default. So local_time->tm_hour == 10 && local_time->tm_min == 57 won't execute correctly.