Git Product home page Git Product logo

whatspup's Introduction

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 v1.0.0+
  • Chrome browser

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.

whatspup's People

Contributors

bidinzky avatar dependabot[bot] avatar gabriel-tandil avatar sarfraznawaz2005 avatar sarfrazonsupport avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whatspup's Issues

Timeout 30S

Hi,

I have 30 seconds timeout error with "pupeteer" after "Initializating...".

On MacOS.

Any problem ?

test issue

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

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.

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?

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

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');
  ...

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)

Do not work on mac

It almost work on mac but it's stuck at "initialisation...".

Also, in the phone app the connexion is name Windows 8.1 while I'm on mac.

Error receiving messages

I receive messages from who I'm chatting with now, but I don't receive messages from other users.
What is happening?
Than you.

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)

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.

Session in headless

The session seems working since it's not asking for QR code again, instead, it shows the image below.

image

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.