Giter VIP home page Giter VIP logo

zap's Introduction

zap

alt text

GitHub issues GitHub stars GitHub forks

Welcome to ZAP

WhatsApp bot model code that include some nice features:

  • Integrated with OpenAI API (GPT models, Dalle, Whisper)
  • Possibility to easy integrate with other APIs
  • Custom prompts for all usages
  • Create and send stickers
  • Show view once media (Meta says that this is normal, not a vulnerbaility, a feature xD)
  • Recieve deleted for everyone messages on pv

Start

This bot works using whatsapp-web.js lib that simulate a whatsapp-web application running on a browser with puppteer, this lib takes the login QR code and shows up on terminal screen, so you gonna need scan this QR code on your first run.

To log-out you can just delete .wwjs* folders or disconnect a "Chrome (macOS)" device from your device list on WA app.

bot-config.json

Note that exists a file named bot-config.json, in this file you will config the conmmands of the bot linked to functions (switch cases) in the code, if you want to add some function, follow other functions structure and add your config in this file.

bot-config.json example

{
    "ping": "ping",
    "gptquestion": "/gpt",
    "sticker": "/sticker",
    "everyone": "@everyone"
    "switch_case": "command_string"
}

Note ping command, it points to this part of the code:

case callers.ping:
    printCall(sender_contact, callers.ping)
    await message.reply('pong')
break

In this file you can also remove the commands that you dont want.

Install and config

Basics

First of all, clone the repository

git clone https://github.com/viniciuspereiras/zap
cd zap

Now you need to configure your .env file, first change the name:

mv .env.example .env
vim .env

Now, add your OpenAI keys (required for GPT functions, Dalle, etc), if you dont want to use, just leave in blank and remove OpenAI commands from your bot-config.json.

Put your number in the config (.env) file following the example in the file (obrigatory)

install packages

npm install

install google-chrome-stable

Puppteer for default uses chromium as a browser engine, but chromium does not have the CODECS that WhatsApp uses for send videos and GIFs (included animated stickers), so if you want to send this type of media, consider install google-chrome on your server.

  • in ubuntu search on google how to install
  • in Arch (I use arch btw) yay -S google-chrome

If you want to not use google chrome:

// [...]
const client = new Client({
    authStrategy: new LocalAuth(),
    //coment this lines above
    //puppeteer: {
    //    executablePath: '/usr/bin/google-chrome-stable'
    //}
})
// [...]

Fisrt run

Now you have all installed, you can test running

node app.js

Dont forget to scan the QR code, like you do to connect to a new device on whatsapp-web

When you read in the logs "[+] Ready to go!", its running.

Running on VPS (background)

I recommend run with pm2 to manage node proccess.

If the bot crashes, pm2 starts up again.

Install pm2

sudo npm install pm2 -g

zap's People

Contributors

viniciuspereiras avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.