Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danitechid/wa-web-api
WhatsApp Web API - TypeScript/JavaScript. ditenagai oleh library: Baileys.
https://github.com/danitechid/wa-web-api
api baileys baileys-bot nodejs wa-bot wabot whatsapp whatsapp-api whatsapp-bot whatsapp-web whatsapp-web-api
Last synced: 26 days ago
JSON representation
WhatsApp Web API - TypeScript/JavaScript. ditenagai oleh library: Baileys.
- Host: GitHub
- URL: https://github.com/danitechid/wa-web-api
- Owner: danitechid
- License: isc
- Created: 2023-10-31T13:30:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-09T11:59:48.000Z (about 1 year ago)
- Last Synced: 2024-10-08T19:31:12.224Z (about 1 month ago)
- Topics: api, baileys, baileys-bot, nodejs, wa-bot, wabot, whatsapp, whatsapp-api, whatsapp-bot, whatsapp-web, whatsapp-web-api
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@danitech/wa-web-api
- Size: 50.8 KB
- Stars: 4
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# WhatsApp Web API - TypeScript/JavaScript
WhatsApp Web API ini ditenagai oleh library: Baileys## Instalasi
### Menggunakan Npm
```bash
npm i @danitech/wa-web-api
```### Atau Menggunakan Yarn
```bash
yarn add @danitech/wa-web-api
```## Contoh Kode
### ./package.json
```json
{
"name": "whatsapp-bot",
"version": "0.0.0",
"private": true,
"main": "index.js",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"dependencies": {
"@danitech/wa-web-api": "latest"
},
"devDependencies": {
"nodemon": "~3.0.1"
}
}
```### ./nodemon.json
```json
{
"ignore": ["index.js"],
"ext": "js"
}
```### ./index.js
```javascript
const wwa = require('@danitech/wa-web-api');
const fs = require('fs');
const chalk = require('chalk');
const config = require('./config/settings.js');
const client = require('./includes/client.js');const {
makeWASocket
} = wwa;const startServer = (config, client) => {
return makeWASocket(config, client);
};startServer(config, client);
```### ./config/settings.js
```javascript
module.exports = {
pairing_mode: true,
session_folder_name: 'session',
browser: ["Chrome (Linux)"],
public_mode: true,
prefix: '.',
bot: {
name: 'Bot Name'
},
owner: {
name: 'Owner Name',
number: '628xxx'
}
};
```### ./includes/client.js
```javascript
const chalk = require('chalk');
const config = require('../config/settings.js');module.exports = async ({
client,
messages
}) => {
try {
const body = messages.mtype === 'conversation' ? messages.message.conversation : messages.mtype === 'extendedTextMessage' ? messages.message.extendedTextMessage.text : '';
const budy = typeof messages.text === 'string' ? messages.text : '';
const command = body.startsWith(config.prefix) ? body.replace(config.prefix, '').trim().split(/ +/).shift().toLowerCase() : '';
const cleanCommand = command.replace(config.prefix, '');
const args = body.trim().split(/ +/).slice(1);
const query = q = args.join(' ');
const query1 = q1 = query.split('|')[0]
const query2 = q2 = query.split('|')[1]const ownerNumbers = config.owner.number;
const senderNumber = messages.sender.replace(/\D/g, '');
const senderName = messages.pushName || 'Undefined';
const isOwner = ownerNumbers.includes(messages.sender);if (!config.public_mode) {
if (!messages.key.fromMe) {
return;
};
};if (messages.message) {
client.readMessages([messages.key]);console.log(
chalk.bgMagenta(' [New Message] '),
chalk.cyanBright('Time: ') + chalk.greenBright(new Date()) + '\n',
chalk.cyanBright('Message: ') + chalk.greenBright(budy || messages.mtype) + '\n' +
chalk.cyanBright('From:'), chalk.greenBright(senderName), chalk.yellow('- ' + senderNumber) + '\n' +
chalk.cyanBright('Chat Type:'), chalk.greenBright(!messages.isGroup ? 'Private Chat' : 'Group Chat - ' + chalk.yellow(messages.chat))
);
};if (!body.startsWith(config.prefix) || body === config.prefix) {
return;
};switch (cleanCommand) {
case 'test': {
messages.reply('Ok, Success!');
break;
};
default: {
messages.reply(`Command: ${config.prefix}${cleanCommand}, tidak tersedia!`);
};
};
} catch (error) {
messages.reply('Terjadi kesalahan pada server.');
console.error(error);
};
};
```### Contoh kode/skrip bot WhatsApp lengkap
Klik disini untuk mengunduh proyek.## Informasi
* Pembuat / Pengembang: Dani Ramdani (Dani Techno.) - FullStack Engineer
* Kontak Pembuat / Pengembang: 0895 1254 5999 (WhatsApp), [email protected] (Email)## Terimakasih Kepada
* Dani Techno. - FullStack Engineer (Pembuat / Pengembang)
* @whiskeysockets/baileys (Penyedia Library "Baileys")