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

Can't use the Bulk Messages for ESP8266 code! #232

Open
Clarathms opened this issue Mar 23, 2021 · 3 comments · May be fixed by #359
Open

Can't use the Bulk Messages for ESP8266 code! #232

Clarathms opened this issue Mar 23, 2021 · 3 comments · May be fixed by #359

Comments

@Clarathms
Copy link

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

@wirewound
Copy link

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.

@SebouhArmenakian
Copy link

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 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.

@SebouhArmenakian
Copy link

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();
}

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

Successfully merging a pull request may close this issue.

3 participants