
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@laxeder/wppconnect
Advanced tools
Uma API para desenvolvimento de ChatBot multi-plataforma em JavaScript/TypeScript
Instalando pacote
npm i @rompot/wppconnect
Importando API
// TypeScript
import { WPPConnect } from "@laxeder/wppconnect";
import { Client } from "rompot";
// Javascript
const { WPPConnect } = require("@laxeder/wppconnect");
const { Client } = require("rompot");
Após iniciar o bot um QR Code será emprimido no terminal, escane-o com seu WhatsApp para gerar uma nova conexão entre seu número e o Client. Essa conexão será guardada em ./path-to-auth, para gerar uma nova delete-o ou se conecte com um novo caminho de sessão.
const client = new Client(new WPPConnect())
client.connect("./path-to-auth");
client.on("qr", (qr) => {
console.log("Scan QR:" qr)
})
type ConnectionConfig = {
/** * Configuração dos comandos */
commandConfig?: CommandConfig;
/** * Desabilita comandos automaticos */
disableAutoCommand?: boolean;
/** * Desabilita escrevndo automatico */
disableAutoTyping?: boolean;
/** * Desabilita a visualização automatica das mensagem recebidas */
disableAutoRead?: boolean;
};
const config: ConnectionConfig = {};
client.config = config;
import { Command, Message } from "rompot";
// Cria um comando com o nome hello
// Ao ser executado envia a mensagem "Hello World!"
class HelloCommand extends Command {
tags: string[] = ["hello"];
prefix: string = "/";
public async execute(message: Message) {
await message.reply(`Hello World!`);
}
}
class DateCommand extends Command {
tags: string[] = ["date"];
prefix: string = "/";
public async execute(message: Message) {
await message.reply(`Data: ${new Date()}`);
}
}
// Listando comandos
const commands = [new HelloCommand(), new DateCommand()];
client.setCommands(commands);
client.on("open", (open) => {
console.log("Client conectado!");
});
client.on("close", (close) => {
console.log("Client desconectado!");
});
client.on("closed", (closed) => {
console.log("Conexão com o bot encerrada!");
});
client.on("connecting", (conn) => {
console.log("Conectando bot");
});
client.on("reconnecting", (conn) => {
console.log("Reconectando bot");
});
client.on("message", (message) => {
console.log(`Mensagem recebida de ${message.user.name}`);
if (message.text == "Oi") {
message.reply("Olá");
}
});
client.on("user", async (update) => {
if (update.action == "join") {
await client.send(new Message(update.chat, `@${update.fromUser.id} entrou no grupo.`));
}
if (update.action == "leave") {
await client.send(new Message(update.chat, `@${update.fromUser.id} saiu do grupo...`));
}
if (update.action == "add") {
await client.send(new Message(update.chat, `Membro @${update.fromUser.id} adicionou o @${update.user.id} ao grupo!`));
}
if (update.action == "remove") {
client.send(new Message(update.chat, `Membro @${update.fromUser.id} removeu o @${update.user.id} do grupo.`));
}
if (update.action == "promote") {
client.send(new Message(update.chat, `Membro @${update.fromUser.id} promoveu o @${update.user.id} para admin!`));
}
if (update.action == "demote") {
await client.send(new Message(update.chat, `Membro @${update.fromUser.id} removeu o admin do @${update.user.id}.`));
}
});
client.on("error", (err: any) => {
console.error(`Um erro ocorreu: ${err}`);
});
import { Message } from "rompot";
// Chat
const chat = new Chat("id12345");
// Criar mensagem
const msg = new Message(chat, "texto");
// Enviar mensagem
client.send(msg);
// Mencionar usuário
msg.mentions.push("userId");
// Marcar mensagem
msg.mention = message;
// Ativa as funções da mensagen
msg.client = client;
// Responder mensagem
msg.reply(message);
// Visualiza uma mensagem recebida
msg.read();
// Reage a mensagem
msg.addReaction("❤");
// remove a reação de uma mensagem
msg.removeReaction();
import { ImageMessage, VideoMessage, AudioMessage, FileMessage, StickerMessage, LocationMessage, ContactMessage } from "rompot";
// Criar mensagem com imagem
const imageMessage = new ImageMessage(chat, "texto", Buffer.from(""));
// Criar mensagem com video
const videoMessage = new VideoMessage(chat, "texto", Buffer.from(""));
// Criar mensagem de audio
const audioMessage = new AudioMessage(chat, "texto", Buffer.from(""));
// Criar mensagem de arquivo
const fileMessage = new FileMessage(chat, "texto", Buffer.from(""));
// Criar mensagem de sticker
const stickerMessage = new StickerMessage(chat, Buffer.from(""));
// Criar mensagem de localiação
// Latitude, Longitude
const locationMessage = new LocationMessage(chat, 24.121231, 55.1121221);
// Criar mensagem com contatos
const contactMessage = new ContactMessage(chat, "nome", "userId");
import { ButtonMessage, ListMessage, PollMessage } from "rompot";
// Criando botões
const btnMessage = new ButtonMessage(chat, "texto", "rodapé");
btnMessage.addCall("Call", "1234567890");
btnMessage.addUrl("Link", "https://example.com");
btnMessage.addReply("Texto", "button-id-123");
// Criar lista
const listMessage = new ListMessage(chat, "texto", "botão", "titulo", "rodapé");
const index1 = listMessage.addCategory("Categoria 1");
const index2 = listMessage.addCategory("Categoria 2");
listMessage.addItem(index1, "Item 1");
listMessage.addItem(index1, "Item 2");
listMessage.addItem(index2, "Abc 1");
listMessage.addItem(index2, "Abc 2");
// Criar enquete
const pollMessage = new PollMessage(chat, "Hello World!");
pollMessage.addOption("Hello", "id-hello-123");
pollMessage.addOption("Hey", "id-hey-123");
pollMessage.addOption("Hi", "id-hi-123");
import { Command, PollUpdateMessage } from "rompot";
class ButtonCommand extends Command {
tags: string[] = ["cmd-button"];
public async response(message: Message) {
await message.reply(`Button Clicked!`);
}
}
client.addCommand(new ButtonCommand());
client.on("message", async (message: Message) => {
if (message instanceof PollUpdateMessage) {
// Não responde caso a votação da enquete foi removida
if (message.action == "remove") return;
}
// Verifica o ID passado na mensagem como opção
if (message.selected == "button-id-123") {
const cmd = client.getCommand("cmd-button");
// Manda a resposta ao comando
if (cmd) cmd.response(message);
}
}):
client.setBotProfile(Buffer.from(""));
client.getBotProfile();
client.setBotName("Name");
client.setBotDescription("Description");
client.getBotDescription();
Você pode obter o chat em message.chat ou client.getChat("id"), o ID pode ser encontrado em message.chat.id
client.createChat("name");
client.leaveChat(chat);
client.setChatProfile(chat, Buffer.from(""));
client.getChatProfile(chat);
client.setChatName(chat, "Name chat");
client.getChatName(chat);
client.setChatDescription(chat, "Chat description");
client.getChatDescription(chat);
message.user ou em chat.getUser("id"), o ID pode se encontrado em message.user.idclient.addUserInChat(chat, user);
client.removeUserInChat(chat, user);
client.promoteUserInChat(chat, user);
client.demoteUserInChat(chat, user);
Esse Software foi construído com:
Este projeto está sob a licença MIT - veja o arquivo LICENSE para mais detalhes.
FAQs
wppconnection version rompot
The npm package @laxeder/wppconnect receives a total of 6 weekly downloads. As such, @laxeder/wppconnect popularity was classified as not popular.
We found that @laxeder/wppconnect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.