npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ssms

v1.0.2

Published

Self SMS gateway designed for droid send to be using your phone as SMS gateway

Downloads

16

Readme

SSMS API Node.js Implementation

This module provides functions for interacting with the DroidSend API to send, retrieve, and resend SMS and MMS messages. It includes functionality for detailed message management, including sending to individual numbers, groups, and contacts.

Installation

First, install the required dependencies:

npm install ssms

Configuration

Before you start, set up the necessary configuration values:


const API_KEY = "";

Functions

sendSingleMessage

Send a single message to a mobile number.

Parameters:

  • number: The mobile number to which the message will be sent.
  • message: The message text.
  • device: (Optional) The ID of the device to be used for sending the message.
  • schedule: (Optional) The timestamp for scheduling the message.
  • isMMS: (Optional) Set to true for sending an MMS message.
  • attachments: (Optional) Comma-separated list of image URLs to attach (for MMS).
  • prioritize: (Optional) Set to true to prioritize the message.

Example:

const deviceID = 17373
async function start() {
  await sendSingleMessage(API_KEY, "12837373", "Test message", 1,deviceID);
}

start();

sendMessages

Send bulk messages to multiple recipients.

Parameters:

  • messages: An array containing objects with number and message fields.
  • option: Specifies how to use devices/SIMs. Use constants: USE_SPECIFIED, USE_ALL_DEVICES, or USE_ALL_SIMS.
  • devices: (Optional) An array of device IDs to be used for sending messages.
  • schedule: (Optional) The timestamp for scheduling the messages.
  • useRandomDevice: (Optional) Set to true to send messages using only one random device from selected devices.

Example:

const messages = [
    { number: "+11234567890", message: "Test message 1" },
    { number: "+11234567891", message: "Test message 2" }
];

try {
    const result = await sendMessages(messages);
    console.log(result);
} catch (err) {
    console.error(err);
}

sendMessageToContactsList

Send a message to all contacts in a specified list.

Parameters:

  • listID: The ID of the contacts list.
  • message: The message text.
  • option: Specifies how to use devices/SIMs.
  • devices: (Optional) An array of device IDs to be used.
  • schedule: (Optional) The timestamp for scheduling the message.
  • isMMS: (Optional) Set to true for sending an MMS message.
  • attachments: (Optional) Comma-separated list of image URLs to attach (for MMS).

Example:

try {
    const result = await sendMessageToContactsList(1, "This is a test message to a list.");
    console.log(result);
} catch (err) {
    console.error(err);
}

getMessageByID

Retrieve the details of a message using its ID.

Parameters:

  • id: The ID of the message.

Example:

try {
    const message = await getMessageByID(123);
    console.log(message);
} catch (err) {
    console.error(err);
}

getMessagesByGroupID

Retrieve messages by their group ID.

Parameters:

  • groupID: The group ID of the messages.

Example:

try {
    const messages = await getMessagesByGroupID("group123");
    console.log(messages);
} catch (err) {
    console.error(err);
}

getDevices

Retrieve all enabled devices.

Example:

try {
    const devices = await getDevices();
    console.log(devices);
} catch (err) {
    console.error(err);
}

sendUssdRequest

Send a USSD request using a specified device and SIM slot.

Parameters:

  • request: The USSD request (e.g., *150#).
  • device: The ID of the device.
  • simSlot: (Optional) The SIM slot to use (0 for the first SIM, 1 for the second SIM).

Example:

try {
    const ussd = await sendUssdRequest("*150#", 1, 0);
    console.log(ussd);
} catch (err) {
    console.error(err);
}

getUssdRequestByID

Retrieve details of a USSD request using its ID.

Parameters:

  • id: The ID of the USSD request.

Example:

try {
    const ussd = await getUssdRequestByID(123);
    console.log(ussd);
} catch (err) {
    console.error(err);
}

Usage

Ensure that you have correctly configured your SERVER and API_KEY constants before using any of the functions.

Example: Sending a Single Message



async function sendSingleMessage(number, message, device = 0, schedule = null, isMMS = false, attachments = null, prioritize = false) {
    const url = `${SERVER}/services/send.php`;
    const postData = {
        number,
        message,
        schedule,
        key: API_KEY,
        devices: device,
        type: isMMS ? "mms" : "sms",
        attachments,
        prioritize: prioritize ? 1 : 0,
    };

    try {
        const response = await axios.post(url, postData);
        return response.data.messages[0];
    } catch (err) {
        throw new Error(err.response ? err.response.data.error.message : err.message);
    }
}

try {
    const msg = await sendSingleMessage("+11234567890", "This is a test message.");
    console.log("Message sent:", msg);
} catch (err) {
    console.error("Failed to send message:", err.message);
}

License

This project is licensed under the MIT License.