1.7.0-0.3.1 • Published 9 months ago

wwebjs-yagami v1.7.0-0.3.1

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

🤖 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

1.7.0-0.3.0

9 months ago

1.7.0-0.2.1

9 months ago

1.7.0-0.0.3

10 months ago

1.7.0-0.3.1

9 months ago

1.7.0-0.1.0

10 months ago

1.7.0-0.0.1

10 months ago

1.7.0-alpha.5

10 months ago

1.6.2

10 months ago

1.7.0-0.2.0

9 months ago

1.7.0-0.0.2

10 months ago

1.6.1

10 months ago

1.7.0-alpha.3

10 months ago

1.6.0

10 months ago

1.7.0-alpha.4

10 months ago

1.7.0-alpha.1

10 months ago

1.7.0-alpha.2

10 months ago

1.7.0-alpha

10 months ago

1.4.0-alpha.1

1 year ago

1.5.0

12 months ago

1.4.0

1 year ago

1.4.0-alpha

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago