A lightweight Node.js wrapper to manage your bot's direct messages and group messages easily.
Node.jsInstall the package using npm:
npm install reikernx
Then require it in your project:
const nexus = require('reikernx');
Before using any function, you must configure your bot:
nexus.setup({
botUsername: 'your_bot_username',
password: 'your_bot_password'
});
Send a direct message to a user.
| Parameter | Type | Description |
|---|---|---|
to |
string | Username of the recipient |
text |
string | Message text or media URL |
isMedia |
boolean (optional) | Set to true if it's a media message |
replyto |
string (optional) | Message ID you are replying to (currently not supported for media) |
Example:
await nexus.sendDM({
to: 'username123',
text: 'Hello!',
isMedia: false
});
Send a message to a group chat.
| Parameter | Type | Description |
|---|---|---|
to |
string | Group ID |
text |
string | Message text |
replyto |
string (optional) | Message ID you are replying to |
Example:
await nexus.sendGroup({
to: 'groupchatid',
text: 'Hey everyone!'
});
Start listening for new incoming messages (both DMs and Group Messages).
| Parameter | Type | Description |
|---|---|---|
callback |
function | A function that will be triggered for each new message |
Each message passed to the callback will have the following structure:
| Property | Type | Description |
|---|---|---|
type |
string | 'dm' or 'group' |
id |
string | Unique message ID |
from |
string | Sender username |
to |
string | Recipient (username for DM / group ID for group) |
text |
string | Message content |
media |
boolean | Whether the message contains media |
replyTo |
string or null | ID of the message being replied to |
recipient |
string | Same as to (use this for replies) |
nexus.setup({
botUsername: 'yourusername',
password: 'yourpassword'
});
nexus.listenMessages(async (msg) => {
const text = msg.text.trim().toLowerCase();
// !ping in group
if (msg.type === 'group' && text === '!ping') {
await nexus.sendGroup({
to: msg.recipient, // group id
text: 'Hello'
});
console.log(`Replied Hello to group ${msg.recipient}`);
}
// !pic in DM
if (msg.type === 'dm' && text === '!pic') {
await nexus.sendDM({
to: msg.recipient, // username
text: 'https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png',
isMedia: true
});
console.log(`Sent picture to DM ${msg.recipient}`);
}
// !reply in both DM or group
if (text === '!reply') {
if (msg.type === 'group') {
await nexus.sendGroup({
to: msg.recipient,
text: 'This is a reply to your message!',
replyto: msg.id
});
console.log(`Replied to group message ${msg.id}`);
}
if (msg.type === 'dm') {
await nexus.sendDM({
to: msg.recipient,
text: 'This is a reply to your message!',
replyto: msg.id
});
console.log(`Replied to DM message ${msg.id}`);
}
}
});
This SDK provides simple bot management.
No external API details or backend configurations are required from your side.