ReikerNx Bot SDK v1.0.0

A lightweight Node.js wrapper to manage your bot's direct messages and group messages easily.

Node.js

Installation

Install the package using npm:

npm install reikernx

Then require it in your project:

const nexus = require('reikernx');

Setup

Before using any function, you must configure your bot:

nexus.setup({
  botUsername: 'your_bot_username',
  password: 'your_bot_password'
});

Functions

sendDM({ to, text, isMedia = false, replyto = null })

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

sendGroup({ to, text, replyto = null })

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!'
});

listenMessages(callback)

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)

Example Script Usage:

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

Notes

Important Information
  • Messages are polled every second.
  • Duplicate messages are prevented using a local timestamps.json file.
  • All functions require the bot to be configured first via setup().
  • Media messages cannot be replied to at this time.
  • Errors will be thrown if setup is missing or incomplete.

This SDK provides simple bot management.
No external API details or backend configurations are required from your side.