Schmavery / facebook-chat-api

Unofficial Facebook Chat API for Nodejs
MIT License
1.94k stars 597 forks source link

how to listen to Message Requests from non-friend accounts? #886

Open rhenwinch opened 3 years ago

rhenwinch commented 3 years ago

How to listen to Message Requests from non-friend accounts? I thought it also listens to that

Also, I'm not sure how api.handleMessageRequest actually works bc u need a 'threadID' to accept/ignore a message request.

image

rhenwinch commented 3 years ago

Copied from my Chatbot file, just modify and use it

api.getThreadList(10, null, ["PENDING"], function (err, list) { if (err) { log("[Facebook]", "Remove Pending Messages encountered an error (at getThreadList:PENDING):", err); if (err.error == "Not logged in." && global.config.facebookAutoRestartLoggedOut) { log("[Facebook]", "Detected not logged in. Throwing 7378278 to restarting..."); facebookloggedIn = false; process.exit(7378278); } return null; } handleList(list, "PENDING");

    api.getThreadList(10, null, ["OTHER"], function (err, list) {
      if (err) {
        log(
          "[Facebook]", "Remove Pending Messages encountered an error (at getThreadList:OTHER):",
          err
        );
        if (err.error == "Not logged in." && global.config.facebookAutoRestartLoggedOut) {
          log("[Facebook]", "Detected not logged in. Throwing 7378278 to restarting...");
          facebookloggedIn = false;
          process.exit(7378278);
        }
        return null;
      }
      handleList(list, "OTHER");

      api.markAsReadAll(function (err) {
        if (err) {
          if (err.error == "Not logged in." && global.config.facebookAutoRestartLoggedOut) {
            log("[Facebook]", "Not logged in. Triggering restart...");
            process.exit(7378278);
          }
        }
      });
    });
  });

thanks, I just saw your comment rn. 1 last question, do u have a method to not get banned? like use an old account or smth?