witnessmenow / Universal-Arduino-Telegram-Bot

Use Telegram on your Arduino (ESP8266 or Wifi-101 boards)
MIT License
1.12k stars 306 forks source link

Bulk Messages Esp8266 - Subscriber Data not being saved #297

Open Oseihie opened 2 years ago

Oseihie commented 2 years ago

Hello @Bolukan and everyone,

I am trying the Bulk Messages example for the Esp8266. I flashed the code to the Esp8266 with no problem and was able to establish a communication between my bot from telegram and Esp8266. After sending /start on telegram, i get a response with the commands and it is expected that the chat_id and name from telegram is saved in the json file. But when I send the request to see all subscribers, I get a response of null.

I have taken a look at the code but I cannot find what the issue might be. Does anyone have an idea?

SebouhArmenakian commented 6 months ago

Replacing between //users.getOrCreateMember(chat_id, from_name); and subscribedUsersFile.close(); will solve the issue:-

if ((usersDoc.isNull()) && (subscribedUsersFile)) { subscribedUsersFile.print("{"" + chat_id + "":" + """ + from_name + ""}" ); } else { serializeJson(users, subscribedUsersFile); users = usersDoc.as(); }

https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot/issues/232