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

velixs-md

v1.0.0

Published

Multi Session Whatsapp Library

Downloads

77

Readme

Whatsapp Multi Session - Menghubungkan Lebih Banyak Sesi Whatsapp dalam 1 Aplikasi

Menghubungkan aplikasi Anda dengan Whatsapp

Pustaka ringan untuk whatsapp. Tidak memerlukan Selenium atau browser lainnya.

Berdiri di atas Baileys Pustaka.

Installation

Install package using npm

npm install velixs-md

Kemudian impor kode Anda

Gunakan JS Module

import * as whatsapp from "velixs-md";

atau gunakan CommonJS

const whatsapp = require("velixs-md");

Session Usage/Examples

Start New Session

// buat sesi dengan ID : ilsyaganz

const session = await whatsapp.startSession("ilsya");
// Kemudian, pindai QR di terminal

Get All Session ID

const sessions = whatsapp.getAllSession();
// mengembalikan semua ID sesi yang telah dibuat

Get Session Data By ID

const session = whatsapp.getSession("ilsya");
// mengembalikan data sesi

Load Session From Storage / Load Saved Session

whatsapp.loadSessionsFromStorage();
// Mulai sesi tersimpan tanpa memindai lagi

Messaging Usage/Examples

Send Text Message

await whatsapp.sendTextMessage({
  sessionId: "ilsya", // session ID
  to: "6281234567890", // always add country code (ex: 62)
  text: "Hi There, This is Message from Server!", // message you want to send
});

Send Image

const image = fs.readFileSync("./myimage.png"); // return Buffer
const send = await whatsapp.sendImage({
  sessionId: "ilsya",
  to: "6281234567890",
  text: "My Image Caption",
  media: image, // can from URL too
});

Send Video

const video = fs.readFileSync("./video.mp4"); // return Buffer
const send = await whatsapp.sendVideo({
  sessionId: "ilsya",
  to: "6281234567890",
  text: "My Video Caption",
  media: video, // can from URL too
});

Send Document File

const filename = "file.pdf";
const document = fs.readFileSync(filename); // return Buffer
const send = await whatsapp.sendDocument({
  sessionId: "ilsya",
  to: "6281234567890",
  filename: filename,
  media: document,
  text: "Hei, Check this Document",
});

Read a Message

await whatsapp.readMessage({
  sessionId: "ilsya",
  key: msg.key,
});

Send Typing Effect

await whatsapp.sendTyping({
  sessionId: "ilsya",
  to: "6281234567890",
  duration: 3000,
});

Listener Usage/Examples

Add Listener/Callback When Receive a Message

whatsapp.onMessageReceived((msg) => {
  console.log(`New Message Received On Session: ${msg.sessionId} >>>`, msg);
});

Add Listener/Callback When QR Printed

whatsapp.onQRUpdated(({ sessionId, qr }) => {
  console.log(qr);
});

Add Listener/Callback When Session Connected

whatsapp.onConnected((sessionId) => {
  console.log("session connected :" + sessionId);
});

Handling Incoming Message Examples

whatsapp.onMessageReceived(async (msg) => {
  if (msg.key.fromMe || msg.key.remoteJid.includes("status")) return;
  await whatsapp.readMessage({
    sessionId: msg.sessionId,
    key: msg.key,
  });
  await whatsapp.sendTyping({
    sessionId: msg.sessionId,
    to: msg.key.remoteJid,
    duration: 3000,
  });
  await whatsapp.sendTextMessage({
    sessionId: msg.sessionId,
    to: msg.key.remoteJid,
    text: "Hello!",
    answering: msg, // for quoting message
  });
});

Save Media Message (Image, Video, Document)

wa.onMessageReceived(async (msg) => {
  if (msg.message?.imageMessage) {
    // save image
    msg.saveImage("./image.jpg");
  }

  if (msg.message?.videoMessage) {
    // save video
    msg.saveVideo("./video.mp4");
  }

  if (msg.message?.documentMessage) {
    // save document
    msg.saveDocument("./file"); // without extension
  }
});

Optional Configuration Usage/Examples

Set custom credentials directory

// default dir is "wa_credentials"
whatsapp.setCredentialsDir("my_custom_dir");
// or : credentials/mycreds

Authors

Feedback or Support

If you have any feedback or support, please reach out to me at [email protected]