GithubHelp home page GithubHelp logo

chr-onicles / whatsapp-bot Goto Github PK

View Code? Open in Web Editor NEW
19.0 1.0 7.0 100.84 MB

My whatsapp bot/Personal assistant ~Ethereal~ Time active: [April 2022 - Sept 2022]

TypeScript 100.00%
bot whatsapp whatsapp-bot whatsapp-web automation whatsapp-web-automation whatsapp-web-js

whatsapp-bot's Introduction

Whatsapp-bot


This is a whatsapp bot created initially for EPiC Devs (wait who?) but now widely used by 100+ '22 final year Computer Science students to make academic life a tiny bit easier. It uses a Whatsapp web library and acts just like a regular user. It was built on a node server and is currently deployed to Heroku in order to make it available 24/7...or so I thought. The bot uses a MongoDB cloud database to supplement its functionalities.


Table of contents


โœ Overview

The problem

Timetables are always a pain to memorize, going through hundreds of messages from class group chats to filter out important information is equally tiresome. But worst of them all is trooping all the way to class just to find out it was cancelled a few minutes/hours prior. I'm also sure we've all been through that moment where almost everyone forgets what exactly the assignment given was about or the exact deadline. I'm not even going to talk about the number of times resources for a particular course can be requested in a single day ๐Ÿ˜ญ

But...

Wait for it



What if someone could always remind you when it's time for class on your favorite messaging platform? ๐Ÿ˜ฎ

What if you don't have to ever memorize any timetable? ๐Ÿ˜ช

What if someone always forwards important messages and links from class groups automatically to your dm? ๐Ÿคฏ

What if someone always keeps track of your assignments and reminds you when it's close to the deadline?๐Ÿฅบ

What if someone can consistently send all resources for a particular course anytime they are requested? ๐Ÿ˜ฒ

.
.
.
Ladies and gentlemen, I present to you.... "Ethereal", a whatsapp personal assistant... or bot if you will.

Standing ovation


My solution

Ethereal seeks to make life easier for '22 final year Computer Science students by:

  • Forwarding important announcements and links from class groups to our dms.
  • Reminding us individually about the times we have class.
  • Getting our timetable for the week, and for the current day depending on the elective each of us offers in as little as 4 quick interactions (< 20secs) or by typing 1 command (< 10secs); As opposed to annoyingly asking someone else who may or may not be available at that moment.
  • Sending all course materials (PDFs, powerpoints etc) for any course as and when requested.
  • Reminding and giving us detailed descriptions of assignments we have for each course.

๐ŸŽฅ Demo


โœจ Features

  • Get timetable for the day (depending on elective) โœ…
  • Get timetable for the week (depending on elective) โœ…
  • Get course materials (ppt, docs, pdfs), etc โœ…
  • Get exams timetable โœ…
  • Receive reminders for classes daily (depending on elective) โœ…
  • Forward important announcements and links from class groups โœ…
  • Anti-spam โœ…
  • Blacklist users โœ…
  • Get current assignments and their details (depending on courses) ๐Ÿšง [WIP]

โšก Commands

Command Description
!acknowledge ๐Ÿ’Ž Remove users from blacklist
!blacklist ๐Ÿ’Ž Get users who have been blacklisted
!botadmins Get current bot admins
!class Get the classes for the day, depending on user's elective
!classgroup (add | remove) ๐Ÿ’Ž Recognize a whatsapp group as an official class group
!classgroups Get a list of all the official whatsapp class group links
!classes Get the classes for the week, depending on user's elective
!demote๐Ÿ’Ž Demote a bot admin
!env๐Ÿ’Ž Check the environment the bot is running in (Production/Development)
!everyone๐Ÿ’Ž Ping everyone in a group
!exams Get the current exams timetable
!grouplink Get the current group's invite link
!help <cmd> Get more info on specific commands
!ignore๐Ÿ’Ž Blacklist a user
!menu Get commands available to a user sent to their DM in a whatsapp list
!mute๐Ÿ’Ž Mute the bot
!notifs status๐Ÿ’Ž Get class notifications status
!notifs (enable all | disable all)๐Ÿ’Ž Enable/Disable all class notifications for the day
!notify (enable | disable) Turn on/off class notifications
!ping Check bot's response time in ms
!promote๐Ÿ’Ž Promote a user to be a bot admin
!slides Get all courses materials (slides, books etc.)
!sourcecode Get the bot's source code
!status๐Ÿ’Ž Get the bot's diagnostics
!subs๐Ÿ’Ž Get all users who have subscribed to be notified for class
!unmute๐Ÿ’Ž Unmute the bot

๐Ÿ’Ž = Commands that can only be used when you are a bot admin.


๐Ÿงฐ Built with


Who are EPiC Devs

EPiC Devs introduction


This was painfully done in a README in 2021 when we coined the name for our project :)
I definitely didn't take too much time on this :)))

We are a group of exquisitely talented, focused and diligent individuals who consistently exceed expectations. Credits to both of my colleagues for inspiring some of the features of the bot.

Check us out!:


Credits

Shout out to the following people for ideas and support:


โš  Disclaimer

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or affiliates. The official WhatsApp website can be found at https://whatsapp.com . "WhatsApp" as well as names, brands, emblems and related images are registered trademarks of their respective owners.


PS:

I recommend Better Comments to see comments with keywords highlighted differently in order to have more insight into the codebase

Feel free to hit me up if you do have interest in it (๐Ÿ“ฉEmail)

whatsapp-bot's People

Contributors

chr-onicles avatar dependabot[bot] avatar piyushduggal-source avatar

Stargazers

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

Watchers

 avatar

whatsapp-bot's Issues

Spamming bot with ping or any command

Add more logic to handle scenarios where a user types the same command several times in a short amount of time.

Typical consequence is, the bot should mute the user (ignore the user's commands for some time) in order to prevent overloading the bot or causing unexpected outcomes.

This should be in situations/groups where everyone can access the bot.

Add command for bot to delete the last thing it sent

=> !del last , !del all to delete all bot responses in a chat that can be deleted for everyone. This means Iโ€™ll have to store all bot messages and replies in order to have access to them to delete them. I don't know if itโ€™s worth it.

Concept of permissions to use bot commands

In certain whatsapp groups like EPiC Devs, the bot should respond to everyone, but in certain class groups, the bot should respond to only specific people which can be changed by a simple command, perhaps !give perms *username* or !talk to *username*.

Another scenario can be where everyone can use certain utility commands that are necessary for a class group like !classes, !class but other commands would be reserved for only users with the required permissions.

Add command to check bot updates

Add a command like !updates to see the most recent updates for the bot, or even still broadcast to a specific group of users the updates for the bot whenever they are any.

Get all class group links

Bot should send the list of all current class whatsapp groups with !groups or !grouplinks for next semester.

NB:

  • Bot would have to be admin in all those groups in order to generate its own invite code for any group.
  • Bot would have to somehow know which groups are class groups (Don't use group names because they are mutable, use the chat's id.user and store this somewhere safe...maybe database)
  • Send list of group links as plain text and not whatsapp list to reduce the number of steps to get to the actual link.

Bot disconnects for unknown reasons after deployment

After being deployed to Heroku, the bot disconnects for reasons unknown.

This causes a need for rescanning the QR code needed for the whatsapp account the bot uses to be authorized, but I'm unable to know when this occurs as I can't get notified by any means. I'll only realize the bot is not responding when I type a command on whatsapp and get no response from it.

At this point usually, the server is still running, but the bot instance gets disconnected and therefore needs to be reauthorized. It handles this by sending an endless stream of QR codes waiting to be scanned by me.

Local auth might solve this as the bot can automatically restore a previous session, but it only works when the bot is hosted locally. Heroku completely ignores the auth session files even when they are pushed to github and therefore requires a new QR code scan every time the bot is redeployed.

Another possible solution may be remote auth in addition to using a storage bucket like what AWS provides albeit at a fee.

Add blacklist feature

Bot should be able to ignore certain users deemed "malicious" by admins with !ignore <user> and revert it with !acknowledge <user>.

Aliases would be a bonus.

Forward messages with links to EPiC Devs group

Bot should forward messages containing links from class groups to EPiC Devs group. Some sort of filtering can take place to remove links specifically for advertisements (like ones containing "instagram").

Expand notify command in Whatsapp list

Expand notify command in list to appear as:

!notify enable and !notify disable to reduce friction in using command currently and avoid unnecessary errors on the user's side.

Add feature to add and remove assignments

Bot should be able to add assignments with the following info:

  • Course
  • Description
  • Due date

It should also be able to remove assignments with a command. Data would be persisted through a deployed database.

It should either broadcast to relevant persons through dm or groups that an assignment has been added, while expired assigments(assignments whose due dates have passed) should be removed unnoticed (or not?).

Add remindme feature

Add a simple remindme feature like Tatsumaki in Discord.
It takes in some arguments like what to remind about and the interval, and sends the reminder after the stipulated time.

Eg: !remindme Register for Computer Course in 30mins

Categorize console logs

Example:

console.log("[CLIENT INFO] Client has been authenticated "); // for logs, not random debugging

Will make it easier for debugging using console logs from Heroku
Inspiration -> Mhankbarbar bot

Add poll feature

Add a poll feature for where users will be polled about command or features they may want pertaining to the bot

The 30 minute reminder for the last class of the day is sent multiple times

The 30 minute reminder for the last class of the day is sent as many times as users subscribed to be notified.

So currently, since there are 4 people subscribed, it sends the 30 minute notification for the last class 4 times consecutively.

Expected behaviour:
The 30 minute reminder is supposed to be sent once to all subscribed users.

Start tracking releases

Track releases when:

  • Stable remote auth is implemented by the whatsapp-web.js library PR #1450
  • Codebase is rewritten in a scalable manner
  • Codebase is migrated to Typescript
  • Lists and buttons bugs are fixed by wweb.js library PR #1636

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.