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

wwebjs-yagami

v1.7.0-0.3.1

Published

- [πŸ€– Yagami](#-yagami) - [πŸ“ Description](#-description) - [πŸ’‘ Usage](#-usage) - [⬆️ Install](#️-install) - [πŸ”Ž Example](#-example) - [πŸ‘Ύ Clients](#-clients) - [πŸ•Ή Commands](#-commands) - [βš™οΈ Environment variables](#️-environment-variab

Downloads

5

Readme

πŸ€– Yagami

πŸ“ Description

Yagami is a Whatsapp client for command execution via message.

πŸ’‘ Usage

⬆️ Install

npm install wwebjs-yagami

πŸ”Ž Example

import { YagamiClient, connectToDatabase } from 'wwebjs-yagami';
import commands from './commands';
async function main() {
  const isServer = process.env.SERVER === 'true';

  const { store } = await connectToDatabase();
  const authStrategy = new RemoteAuth({
    clientId: process.env.CLIENT_ID,
    store,
    backupSyncIntervalMs: 5 * 60 * 1000
  });

  const clientOptions: YagamiOptions = {
    handleSignups: true,
    authStrategy,
    puppeteer: {
      headless: true,
      [isServer && 'executablePath']: '/usr/bin/chromium-browser',
      [isServer && 'args']: ['--no-sandbox']
    }
  };

  const client = new YagamiClient(commands, clientOptions);

  start();

  function start() {
    client.init();
  }
}
main();

Obs:

🚨 You must import connectToDatabase and call that function before instantiating Yagami Client.

See commands.md for more info about commands.

After running npm start or npm run compile (build + start), you'll see that in the terminal:

πŸ‘Ύ Clients

It's possible to have many concurrent clients. In other words, you can manage more than one bot simultaneously with one Node instance.

To do so, it's necessary to instantiate different objects of YagamiClient, in that way:

const foo = new YagamiClient(commandsFoo, clientOptionsFoo);
const bar = new YagamiClient(commandsBar, clientOptionsBar);
start();

function start() {
  foo.init();
  bar.init();
...

πŸ•Ή Commands

See commands README.

βš™οΈ Environment variables

Some environment variables are necessary. You must create a .env file at the project root and follow this pattern:

SERVER=false # is running in a server?
MONGO_URI="" # mongo connection string
CLIENT_ID="" # ID that will represent a unique session at the database

πŸ“¦ Main dependencies

🎁 whatsapp-web.js

It's the main library that makes all the magic. It provides a helpful API with Whatsapp Web.

The qrcode-terminal module allows the QR Code mirroring from the Whatsapp Web page to the terminal.

πŸ–₯ winston

It's the one responsible for standardization logs. You may use the helper logger instead of console.log.

πŸ—ƒ Database

The Yagami Client, through mongoose, uses Mongo's non-relational database to store some entities such as:

You find the DB logic in the src/app directory.

πŸ“‚ /app/collections

A collection provides methods to maintain a database entity. In other words, you can create, update, delete and read a database entity.

πŸ“‚ /app/models

A estrutura de dados das entidades User e Group do banco Γ© representada nas classes contidas nessa pasta.

User and Group's database entities are represented by the classes contained in that directory.

🎫 Session

You can use any phone number with Yagami Client. To do so, it is used a session stored in the database, for avoiding scanning the QR Code every execution. It is done through the whatsapp-web.js auth strategy, Remote Auth.

Each session is identified by the environment variable CLIENT_ID. For each new ID, two collections are created in the Mongo database:

  • whatsapp-RemoteAuth-<CLIENT_ID>.chunks

  • whatsapp-RemoteAuth-<CLIENT_ID>.files