:white_square_button: WhatsApp chat from commandline/console/cli using GoogleChrome puppeteer

Overview

Whatspup

Use Whatsapp from commandline/console/cli using GoogleChrome puppeteer! πŸ˜„

Features

  • βœ… Send and receive messages
  • βœ… Read Receipts
  • βœ… Switch between users to chat with
  • βœ… Popup notifications for new chat messages
  • βœ… Privacy settings for popup notifications
  • βœ… One-time authentication, no need to scan QR code again and again
  • βœ… Windowless/headless (hidden) mode
  • βœ… Colorful chat messages

Of course, it is not possible to send/receive picture messages from command line.

Screenshot

Main Window

Requirements

  • Node v8+
  • puppeteer v0.13.0+

Tested on Windows with Node v8.9.1 and puppeteer v0.13.0

Installation

  • Clone this repository. git clone https://github.com/sarfraznawaz2005/whatspup.git
  • Type npm install
  • Type node chat.js USERNAME (case-sensitive)
  • Chrome will open up, now just scan Whatsapp QR Code once via whatsapp app in your mobile
  • Wait for connection and start typing your messages πŸ˜„

NOTE: Once you have connected by scanning QR code, your session will be saved so you won't have to scan it again and again unless you revoke from whatsapp app or by deleting tmp folder.

Commands

Changing User

You can switch chat with another user anytime by typing on console: --chat USERNAME (case-sensitive)

NOTE: USERNAME is supposed to be a person with whom you have already initiated a conversation in whatsapp. In other words, we use a selector to click that user's name from conversations list.

Clear Chat Screen

To clear chat screen, type --clear.

Options

You can set various options in config.js file.

Others

  • You can send common emojis directly by typing :smile:, :lol:, :happy:, :love:, :wink: OR ;-), :-), <3, etc

Contribute

You are welcome to contribute to this project.

Disclaimer

This project is not affiliated with official whatsapp in any sense.

Comments
  • Initializing...

    Initializing...

    When run chat.js appear a message Initializing.. -open browser ok -i scan the qr ok

    • and return to console a seconds after appear a message.

    ╔══════════════╗ β•‘ β•‘ β•‘ Whatspup β•‘ β•‘ β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β• Initializing...

    Unhandled Rejection at: Promise Promise { Error: waiting failed: timeout 30000ms exceeded at Timeout.WaitTask._timeoutTimer.setTimeout (/home/al/Descargas/whatspup-master/node_modules/puppeteer/lib/FrameManager.js:789:58) at ontimeout (timers.js:458:11) at tryOnTimeout (timers.js:296:5) at Timer.listOnTimeout (timers.js:259:5) } reason: Error: waiting failed: timeout 30000ms exceeded at Timeout.WaitTask._timeoutTimer.setTimeout (/home/al/Descargas/whatspup-master/node_modules/puppeteer/lib/FrameManager.js:789:58) at ontimeout (timers.js:458:11) at tryOnTimeout (timers.js:296:5) at Timer.listOnTimeout (timers.js:259:5)

    opened by alloanva 3
  • I got this error!

    I got this error!

    Unhandled Rejection at: Promise Promise { <rejected> Error: waiting failed: timeout 30000ms exceeded at Timeout.WaitTask._timeoutTimer.setTimeout (C:\Users\Adiel\Downloads\whatspup-master\whatspup-master\node_modules\puppeteer\lib\FrameManager.js:695:58) at ontimeout (timers.js:478:11) at tryOnTimeout (timers.js:302:5) at Timer.listOnTimeout (timers.js:262:5) } reason: Error: waiting failed: timeout 30000ms exceeded at Timeout.WaitTask._timeoutTimer.setTimeout (C:\Users\Adiel\Downloads\whatspup-master\whatspup-master\node_modules\puppeteer\lib\FrameManager.js:695:58) at ontimeout (timers.js:478:11) at tryOnTimeout (timers.js:302:5) at Timer.listOnTimeout (timers.js:262:5)

    opened by GilbertoBitt 3
  • Not work in invisible/headless mode

    Not work in invisible/headless mode

    when headless is true, not work why? is an issue from puppeteer?

    I try run 'web.whatsapp.com' and take screenshot http://i.cubeupload.com/RmJXwC.png with headless mode

    opened by nicobytes 3
  • Fix headless not working

    Fix headless not working

    It seen that it only works headless if setRequestInterception is true and there is and event listener on the requests :open_hands:

    I really don't know why, but that way is working

    opened by arcps 2
  • when try to launch throw a error

    when try to launch throw a error

    22:39:38 - warn: Error: Failed to launch chrome! [25780:25780:0221/223938.126938:FATAL:zygote_host_impl_linux.cc(124)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox. #0 0x55696ba448ec base::debug::StackTrace::StackTrace()

    opened by alloanva 2
  • Fix selecting chats that were off-screen

    Fix selecting chats that were off-screen

    Hello! Great project! I was recently working on a puppeteer project integrating with WhatsApp and I wanted to contribute here where I could.

    Surprisingly the document can't select the chat elements that are off-screen; options were to scroll to it, or search for it, so I added a search.

    Also adds package-lock for consistent versions with npm ci.

    I found that SIGINT kept re-opening the browser with "Do you want to restore pages?" So I handled SIGINT with a browser close.

    Hope this makes sense, and that you can find this useful!

    Thanks for the inspiration! :)

    opened by bozdoz 1
  • Forcing empty cache and hard reload

    Forcing empty cache and hard reload

    IΒ΄ve achieved a login without showing Chromes window here: https://github.com/yeikiu/waar but keep getting the annoying Google Chrome 36+ error on random moments. When it does by clicking right click on refresh and choosing Force empty cache and hard reloadit then shows the QR. You think we can trigger that from within puppeteer as a fallback startegy?

    opened by yeikiu 1
  • Having issues waiting for images to be loaded from groups

    Having issues waiting for images to be loaded from groups

    HI bro, when people send images the code get blocked until all images in the group chat window get loaded, did you had the same issue? do you know how to fix it? this is the part of the code that give me a timeout error;

    `lastMessageGlobal : async function readLastOtherPersonMessage(page,name) {

      	let message = '';
    
          //let name = await this.currentUser(page);
        
          if (!name) {
            return false;
          } 
    
       	//scroll last message
    	await page.evaluate((selector) => {
            try {
    			 document.querySelector(selector).scrollIntoView({behavior: 'smooth',block:'end'});  
    		} catch (err) { 
                console.log(err); 
    		}  
    	}, selector.last_message); 
    	
    	 
      // read last message sent by other user
      message = await page.evaluate((selector) => {
    
        let nodes = document.querySelectorAll(selector);
        let el = nodes[nodes.length - 1];  
    
        if (!el) {
          return '';
        }
    
    
       let picNodes = el.querySelectorAll("img[src*='blob']");
       let isPicture = picNodes[picNodes.length - 1];
    
       if (isPicture) {
         return 'Picture Message';
       }
    
        // check if it is gif message
       let gifNodes = el.querySelectorAll("div[style*='background-image']");
       let isGif = gifNodes[gifNodes.length - 1];
    
       if (isGif) {
         return 'Gif Message';
       }
    
        // check if it is video message
        let vidNodes = el.querySelectorAll(".video-thumb");
        let isVideo = vidNodes[vidNodes.length - 1];
    
        if (isVideo) {
          return 'Video Message';
        }
    
        // check if it is voice message
        let audioNodes = el.querySelectorAll("audio");
        let isAudio = audioNodes[audioNodes.length - 1];
    
        if (isAudio) {
          return 'Voice Message';
        }
    
        // check if it is emoji message
        let emojiNodes = el.querySelectorAll("div.selectable-text img.selectable-text");
        let isEmoji = emojiNodes[emojiNodes.length - 1];
    
        if (isEmoji) { 
    		
    		var emoArray = [];
        	var imgEmoji = 'https://web.whatsapp.com'+document.querySelector('._2DV1k').getAttribute('src'); 
        	var imgLocal = './public/images/emoji/88179f049c0d1d26c823d2954ecb54a7_w_e1854-64.png'; 
    
        	emoArray = ['emoji',imgEmoji,imgLocal];
    
          	return emoArray;
        }
    
        // text message
        nodes = el.querySelectorAll('span.selectable-text');
        el = nodes[nodes.length - 1];
    
        return el ? el.innerHTML : '';
    
      }, selector.last_message);
    
    	//if message is array lets prepare it to be an string
    	if(Array.isArray(message) == true && message[0] == "emoji"){
    
              	message = await this.getEmoji(message);
              	
        }
        
    	//get ligatures
    	var ligatureName		= await this.ligatures(page,name);
      	var ligatureMessage 	= await this.ligatures(page,message);
      	let user 				= await this.currentUser(page);
      //load from session
      last_received_message = ssn.last_received_message;
    
      if (message && user == name) {
        if (last_received_message || ssn.messagesCount == 0) {
          if (Array.isArray(message) == false && last_received_message != message) {
    
            ssn.last_received_message = message;
    
            this.print(ligatureName + ": " + ligatureMessage, config.received_message_color); 
            return ligatureMessage;
    
          }
        }
        else {
          ssn.last_received_message = message; 
          ssn.messagesCount = (ssn.messagesCount + 1);
          console.log('count: ',ssn.messagesCount);
          return ligatureMessage;
        }
    
      }
    }`
    

    I have changed the code a little bit to adapt it to my apps need ... please help.

    opened by amprodes 1
  • Bump minimist from 1.2.5 to 1.2.6

    Bump minimist from 1.2.5 to 1.2.6

    Bumps minimist from 1.2.5 to 1.2.6.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump ws from 6.2.1 to 6.2.2

    Bump ws from 6.2.1 to 6.2.2

    Bumps ws from 6.2.1 to 6.2.2.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump node-notifier from 5.4.3 to 8.0.1

    Bump node-notifier from 5.4.3 to 8.0.1

    Bumps node-notifier from 5.4.3 to 8.0.1.

    Changelog

    Sourced from node-notifier's changelog.

    v8.0.1

    • fixes possible injection issue for notify-send

    v8.0.0

    Breaking changes:

    • Expire time for notify-send is made to match macOS and Windows with default time of 10 seconds. The API is changed to take seconds as input and converting it to milliseconds before passing it on to notify-send. See #341.

    v7.0.2

    • Updates dependencies
    • Fixes issue with haning Windows notifications when disabled (#335)

    v7.0.1

    • Fixes import of uuid, removes deprecation warnings

    v7.0.0

    Features

    • NotifySend support for app-name (#299, see docs)

    Breaking Changes

    • All notify messages now have auto bound context to make it easier to pass as variables/arguments (#306)
    • Updated snoreToast to version 0.7.0 with new input features (#293)
    • Breaking snoreToast: Sanitizing data now changes "timedout" to "timeout"

    v6.0.0

    Breaking Changes

    • Dropped support for node v6. As of v6 we currently support node versions 8, 10, and 12 (latest).
    • Updated to the latest version of SnoreToast. This removes support for the wait option in that environment as it is now always on. Prepares the way for other new features added to the WindowsToaster.

    Other

    • Update to latest version of dependencies.
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Showing longer history

    Showing longer history

    Is it possible to implement a larger storage of the history of a conversation?

    Currently: After opening a chat, you only get to see the last message you received.

    My hope: Would it be possible to retrieve the last N number of messages, so I can see what I missed, while in another chat.

    opened by lfb0801 0
  • Split typing of messages and the stream of messages

    Split typing of messages and the stream of messages

    Would it be possible to have a separate section of the screen dedicated to typing a message?

    Currently if you get a response from someone it disturbs the typing of your message.

    opened by lfb0801 0
  • Group mention feature

    Group mention feature

    Mentioning @contact@

    async function typeMessage(message) {
    
      let fs = []
    
      let parts = message.split('\n');
    
      for (var i = 0; i < parts.length; i++) {
        fs.push({type: 'down', command: 'Shift'})
        fs.push({type: 'press', command: 'Enter'})
        fs.push({type: 'up', command: 'Shift'})
    
        //Mentioning @contact@
        if(parts[i].includes('@')) {
          let parts2 = parts[i].split('@');
    
    
          for (var j = 0; j < parts2.length; j++) {
            let contact = parts2[j].slice(0,1) === ' ' ? parts2[j].slice(1,parts2[j].length) : parts2[j]
    
            if(contact.length > 3 && parts[i].indexOf('@' + contact) >= 0) {
              fs.push({type: 'type', command: '@' + contact.slice(0, -1), wait: 1000})
              fs.push({type: 'press', command: 'Enter', wait: 500})
            }
            else {
              fs.push({type: 'type', command: contact})
            }
    
          }
    
        }
        else {
          fs.push({type: 'type', command: parts[i]})
        }
      }
    
      for(let i = 0; i < fs.length; i++) {
        await page.keyboard[fs[i].type](fs[i].command)
        await wait(fs[i].wait ? fs[i].wait : 100)
      }
    
      await page.keyboard.press('Enter');
      ...
    
    opened by mattu36 0
Owner
Sarfraz Ahmed
A self-taught programmer from Karachi, Pakistan mainly involved in PHP, MySQL, HTML/CSS, JavaScript/jQuery for around 10+ years now.
Sarfraz Ahmed
A group listening chat app that utilizes the spotify api to enable the users to queue, pause, change songs, as well as chat with each other

Next.js + Tailwind CSS Example This example shows how to use Tailwind CSS (v3.0) with Next.js. It follows the steps outlined in the official Tailwind

Zach McLean 1 Dec 19, 2021
$2y$10$pCG0Qzwi0AhuaYCFpydbS.c3PHUJGu3AJreDudGce.Zd/UV.HQyLe 262 Nov 21, 2022
Pretty diff to html javascript cli (diff2html-cli)

diff2html-cli Diff to Html generates pretty HTML diffs from unified and git diff output in your terminal Table of Contents Features Online Example Dis

Rodrigo Fernandes 404 Dec 19, 2022
LinkFree CLI is a command line tool that helps you to create your LinkFree profile through CLI.

LinkFree CLI LinkFree CLI is a command line tool that helps you to create your LinkFree profile through CLI. Demo Using the CLI (Commands) Note First

Pradumna Saraf 32 Dec 26, 2022
Test your internet connection speed and ping using speedtest.net from the CLI

speed-test Test your internet connection speed and ping using speedtest.net from the CLI Install Ensure you have Node.js version 8+ installed. Then ru

Sindre Sorhus 3.8k Jan 7, 2023
A CLI for peer-to-peer file sharing using the Hypercore Protocol.

A CLI for peer-to-peer file sharing (and more) using the Hypercore Protocol.

Hypercore Protocol 207 Dec 30, 2022
DataENV is a cli tool that allows you to save data temporarily using your terminal.

DataEnv CLI Instllation npm install -g dataenv Usage Table of Contents LocalStorage npx dataenv save Parameters npx dataenv show Parameters npx dataen

PGamerX 2 Feb 5, 2022
Infinite Red's cutting edge React Native project boilerplate, along with a CLI, component/model generators, and more!

Ignite - the hottest React Native boilerplate Battle-tested React Native boilerplate The culmination of five years of constant React Native developmen

Infinite Red, Inc. 14.7k Dec 29, 2022
CLI tool for running Yeoman generators

yo What's Yeoman? Yeoman helps you to kickstart new projects, prescribing best practices and tools to help you stay productive. To do so, we provide a

Yeoman 3.6k Dec 30, 2022
Distributed, realtime CLI for live Node apps.

Vantage = CLI + SSH + REPL for your live node app. In one line: require("vantage")().listen(4000); What just happened? That's voodoo magic: show me th

dc 3.5k Dec 30, 2022
download torrents with node from the CLI

torrent Download torrents from the command line usage torrent <magnet link OR path to .torrent file> Download a torrent from a magnet link to torre

Max Ogden 619 Dec 26, 2022
:notes: Control iTunes via CLI

itunes-remote Control iTunes via your terminal ?? Using JXA via osascript via Node.js. Requirements Node.js (v0.12.7 or greater) Mac OS X (Yosemite 10

Michael KΓΌhnel 422 Nov 19, 2022
Add stdin support to any CLI app that accepts file input

tmpin Add stdin support to any CLI app that accepts file input It pipes stdin to a temp file and spawns the chosen app with the temp file path as the

Sindre Sorhus 121 Oct 3, 2022
Node.js Open CLI Framework. Built with πŸ’œ by Heroku.

oclif: Node.JS Open CLI Framework ?? Description ?? Getting Started Tutorial ✨ Features ?? Requirements ?? CLI Types ?? Usage ?? Examples ?? Commands

oclif 8k Jan 4, 2023
Git commit CLI

commitme Based on this gist by @gustavopch Installation You can install this on your package using npm i -D commitme or run it once using npx commitme

Roz 7 Jun 6, 2021
An extension geared towards Spotify users with larger libraries; view all your playlists that contain a specific song with the click of a button. Designed for Spicetify (https://github.com/khanhas/spicetify-cli)

ViewPlaylistsWithSong An extension developed for Spicetify that allows you to view all the playlists in your library that contain a certain song. Idea

null 21 Dec 13, 2022
HMSC (How Much Stuffs CLI) analyst for your files and folders

HMSC ?? About HMSC (How Much Stuffs CLI) analyst for your files and folders ?? Screenshot ?? Requirements Node.js NPM ?? Installation $ npm i -g hmsc

Abdullah Veliyev 26 Jan 10, 2022
A C++ based command-line (CLI) program that lets you manage your tasks

COMMAND LINE INTERFACE TODO APP a command-line (CLI) program that lets you manage your tasks. The specification for this project is written down as te

Rahul Prabhakar 1 Dec 25, 2021
A CLI progam show teminal outputs as gradients.

GRADIENT-TERMINAL A CLI progam to display teminal outputs as gradients. Requirements For Installation, you will only need Node.js. Install $ git clone

Ritin George 34 Jan 3, 2023