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

velespk

v1.3.3

Published

Pacote destinado a criação rápida de chatbots para Whatsapp

Downloads

10

Readme

#VELESPK

Pacote destinado a criação rápida de chatbots para Whatsapp //Framework em Breve

Pacote inclui um arquivo index.js com todo o esqueleto da aplicação pronto, juntamente com suas dependências, basta instalar e usar.

npm install velespk

Documentação ainda em Criação.

Documentação do Código

Este código usa a função waMain do pacote velespk para criar uma instância do cliente do WhatsApp Web e incluir quaisquer módulos adicionais do pacote whatsapp-web.js.

Configurando o Cliente

Para configurar o cliente, chame a função waMain com as opções desejadas:

const { waMain } = require('velespk');

const {client, seuModule} = waMain({
    modules: {seuModule},
    executablePath: 'path/to/chrome'
});

A função waMain aceita um objeto de opções que pode incluir propriedades como modules e executablePath.

Para Utilizar o client.on você declara ele juntamente com o client no waMain.

Lembre-se o client.on agora usa a sintaxe clo.

const { waMain } = require('velespk');

const { client, clo } = waMain({
    // ... opções aqui ...
});

// Manipulador de evento assíncrono
clo('message', async (message) => {
    // Lógica assíncrona aqui
});

// Manipulador de evento síncrono
clo('outro-evento', (data) => {
    // Lógica síncrona aqui
});

É possivel alterar os eventos entre os disponíveis, usar ele como assíncrono ou síncrono

Enviando Mensagens

Depois de criar a instância do cliente, você pode usar as funções mMsg e mMsgs para enviar mensagens simples ou várias mensagens com base em palavras-chave, respectivamente.

Enviando uma Mensagem Simples

Para enviar uma mensagem simples para o cliente, use a função mMsg:

mMsg(client, 'Oi', 'Oi, como você está?');

A função mMsg aceita três argumentos: a instância do cliente, a palavra-chave e a mensagem a ser enviada.

Enviando Várias Mensagens

Para enviar várias mensagens para o cliente com base em palavras-chave, use a função mMsgs:

const messages = {
    'Oi': 'Oi, como você está?',
    '!ping': 'pong',
    // Adicione outras palavras-chave e respostas aqui
};
mMsgs(client, messages);

A função mMsgs aceita dois argumentos: a instância do cliente e um objeto contendo pares de palavras-chave e respostas.

Recebendo Mensagens

Você pode usar o evento message do cliente normalmente após chamar a função waMain com as opções desejadas e obter a instância do cliente. Aqui está um exemplo de como você pode fazer isso:

client.on('message', msg => {
    // Coloque aqui o código para lidar com mensagens recebidas
    console.log(`Received message: ${msg.body}`);
});

Quando uma nova mensagem é recebida pelo cliente, o manipulador de eventos é chamado e o código dentro dele é executado. Neste caso, o código simplesmente imprime a mensagem recebida no console.

Você pode modificar o código dentro do manipulador de eventos para fazer o que quiser com as mensagens recebidas, como responder automaticamente ou armazená-las em um banco de dados.

English

#VELESPK

Package for quick creation of chatbots for WhatsApp //Framework coming soon

The package includes an index.js file with the entire application skeleton ready, along with its dependencies, just install and use.

npm install velespk

Code Documentation

This code uses the waMain function from the velespk package to create an instance of the WhatsApp Web client and include any additional modules from the whatsapp-web.js package.

Setting up the Client

To set up the client, call the waMain function with the desired options:

const { waMain } = require('velespk');

const {client, MessageMedia} = waMain({
    modules: {MessageMedia},
    executablePath: 'path/to/chrome'
});

The waMain function accepts an options object that can include properties such as modules and executablePath.

To use client.on you declare it together with client in waMain.

Remember client.on now uses the clo syntax.

const { waMain } = require('velespk');

const { client, clo } = waMain({
     // ... options here ...
});

// Asynchronous event handler
clo('message', async(message) => {
     // Async logic here
});

// Synchronous event handler
clo('other-event', (date) => {
     // Synchronous logic here
});

It is possible to change the events between those available, use it as asynchronous or synchronous

Sending Messages

After creating the client instance, you can use the mMsg and mMsgs functions to send simple messages or multiple messages based on keywords, respectively.

Sending a Simple Message

To send a simple message to the client, use the mMsg function:

mMsg(client, 'Hi', 'Hi, how are you?');

The mMsg function accepts three arguments: the client instance, the keyword, and the message to be sent.

Sending Multiple Messages

To send multiple messages to the client based on keywords, use the mMsgs function:

const messages = {
    'Hi': 'Hi, how are you?',
    '!ping': 'pong',
    // Add other keywords and responses here
};
mMsgs(client, messages);

The mMsgs function accepts two arguments: the client instance and an object containing pairs of keywords and responses.

Receiving Messages

You can use the client’s message event normally after calling the waMain function with the desired options and obtaining the client instance. Here is an example of how you can do this:

client.on('message', msg => {
    // Put your code here to handle received messages
    console.log(`Received message: ${msg.body}`);
});

When a new message is received by the client, the event handler is called and the code inside it is executed. In this case, the code simply prints the received message to the console.

You can modify the code inside the event handler to do whatever you want with received messages, such as automatically responding or storing them in a database.