Open Clarathms opened 3 years ago
I can not solve this in a pretty way but i found that if e new subscribedUsersFile is created serializeJson(users, subscribedUsersFile)
writes "null" in the file because getSubscribedUsers()
returns null becaus the file is empty yet.
if (usersDoc.isNull())
{
users = usersDoc.to<JsonObject>();
}
else
{
users = usersDoc.as<JsonObject>();
}
This was my workaround for the problem.
wirewound, you saved my days trying to figure out the issue why I always get "null" for "/showallusers".
I added your suggestion in bool addSubscribedUser(String chat_id, String from_name) after serializeJson(users, subscribedUsersFile); and the sketch works like a charm.
Thank you @witnessmenow Brian Lough and @wirewound
I can not solve this in a pretty way but i found that if e new subscribedUsersFile is created
serializeJson(users, subscribedUsersFile)
writes "null" in the file becausegetSubscribedUsers()
returns null becaus the file is empty yet.if (usersDoc.isNull()) { users = usersDoc.to<JsonObject>(); } else { users = usersDoc.as<JsonObject>(); }
This was my workaround for the problem.
Unfortunately for unforeseen reasons the suggestion of @wirewound doesn't work always. Based on his suggestions adding the below by 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
I copied the Bulk Message code the same way it was written, and added the SSID ,password and bot token as it told me to do. But when I tested it, all the bot functions wouldn't work. For example : Even tho there were 2 subscribed users, it just kept saying ´´null´´
I would like to know how to proceed