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

@danitech/wa-web-api

v1.2.4

Published

WhatsApp Web API - TypeScript/JavaScript. ditenagai oleh library: Baileys.

Downloads

123

Readme

WhatsApp Web API - TypeScript/JavaScript

WhatsApp Web API ini ditenagai oleh library: Baileys

Instalasi

Menggunakan Npm

npm i @danitech/wa-web-api

Atau Menggunakan Yarn

yarn add @danitech/wa-web-api

Contoh Kode

./package.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

{
  "ignore": ["index.js"],
  "ext": "js"
}

./index.js

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

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

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")