Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
messenger-events
Advanced tools
Messenger Events is an abstraction layer over the more popular [`facebook-chat-api`](https://github.com/Schmavery/facebook-chat-api/) and has as an objective to simplify the library and make it overall more consistent through embracing immutable Object-Or
Messenger Events is a thin abstraction layer over the more popular facebook-chat-api
and has as an objective to simplify the library and make it overall more consistent through embracing immutable Object-Oriented design while at the same time enabling backward compatibility with the underlying library.
Performance is at best a consideration in this project and is sacrificed on every turn in favor of making the library easier to use. This library is not recommended for projects relying on quick response times and instead favors more complex use cases such as building a messenger clone.
This library abstracts nearly everything you will need so you don't have to!
The following are features which either feature no, or insufficient support but will have first-class support.
The following are features which will, at best, feature second-class support and worst, not be implemented. If facebook-chat-api
supports a feature in this list, you can still use it by using it directly. Conversely, some in this list are not supported because they lack support and will be implemented if it changes.
GetFriendsList()
method (Reason: Read the response to my PR, if you are curious, Messenger Events is using my fork instead of the official repo until it is fixed)Cleaner SyntaxThe following is a short program to receive a message, react to it, log the user's nickname (if any) as well as his real name and send him a private message.
require("messenger-events")
({email: "FB_EMAIL", password: "FB_PASSWORD"},
(success, $) => {
if (!success) return console.log($);
$.onMessage((context, message) => {
message.react(":haha:");
console.log(context.user.nickname, context.user.name);
context.user.sendMessage("Hey!")
})
})
require("messenger-events")
({email: "FB_EMAIL", password: "FB_PASSWORD"},
(success, $) => {
if (!success) return console.log($);
$.onMessage((context, message) => {
console.log("This will be called first")
})
$.onMessage((context, message) => {
console.log("This will be called second")
})
$.onMessage((context, message) => {
console.log("This will be called third")
})
})
facebook-chat-api
To permit users more familiar with facebook-chat-api
to gradually transition to Messenger Events as well as to allow the usage of left-out features, it exposes direct access to the API in the $.api
object.
require("messenger-events")
({email: "FB_EMAIL", password: "FB_PASSWORD"},
(success, $) => {
if (!success) return console.log($);
var yourID = "000000000000000";
var msg = "Hey!";
$.api.sendMessage(msg, yourID);
// Or alternatively,
let api = $.api;
api.sendMessage(msg, yourID);
})
When using the legacy api
object directly, note that using api.listen()
is not the real api.listen()
but instead mapped to api.legacyListen()
while the real one is at api.realListen()
. While they are functionally the same, you must never use api.realListen()
as it will break all the abstractions. A bonus of using api.legacyListen()
, is that it allows you to reuse it multiple times as opposed to the real listener provided by facebook-chat-api
(Issue #525).
This project is in active development making it both not feature-complete (yet) and unstable enough to make it unsuitable for production environments. You are encouraged to remedy both of those issues.
This project depends fully on
facebook-chat-api
, if there is a bug in their code, it will propagate to this package as well.
FAQs
Messenger Events is an abstraction layer over the more popular [`facebook-chat-api`](https://github.com/Schmavery/facebook-chat-api/) and has as an objective to simplify the library and make it overall more consistent through embracing immutable Object-Or
The npm package messenger-events receives a total of 8 weekly downloads. As such, messenger-events popularity was classified as not popular.
We found that messenger-events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.