Supbot API | Whatsapp Group Chatbot API | Developement update #3

in #utopian-io6 years ago


supbot banner

While working with Supbot API to make tutorials, I realized that, ConsoleCommand was very tedious to work with and the design for Schedule and ScheduleTask was very confusing. So before I make the tutorial with such bad design I had to change things and add new features to make it more friendly.

Repository

https://github.com/adsau59/supbot
Commit1
Commit2

What is Supbot API?

Supbot API is a Whatsapp Group Chatbot API, Showcase video.

Whatsapp is the most used messenger platform, but the lack of bot support made it very tedious to perform some operations that other platform with bot support performs easily.

Supbot API uses Selenium to automate Whatsapp Web to read and collect data, runs business logic and perform different actions defined by the developer, it provides various features to developers to create their own features and add it inside Whatsapp itself.

Objective

  • To create bot support on the most used messenger platform out there.
  • To create a way for developers to make their own features inside whatsapp itself.
  • To teach developers how to use Supbot API using video tutorials.

Technology Stack

Supbot is made using

New Features

Created HelpCC Console Command

Why?

  • Working with Console Commands was very tedious, as when the developer wants to use a command, they had to look up its usage in the documentation.
  • A way was needed to check which commands are available and their usage during runtime.

How?

  • In the ConsoleCommand abstract class, an abstract getHelper() method was created which returned a Helper object which contained 3 Strings, template, example, description.
  • When help console command is used with a target console command, the getHelper() of the target console command is used to generate a message which is printed in the console.

Schedule and ScheduleTask rework

Why?

  • Schedule and ScheduleTask was very confusing to work with, as by the previous design a detaTime was given to reschedule the task, but when the task was missed, it had to be rescheduled manually by code by the developer, hence two different ways to do same thing added a lot of confusion.
  • A simpler method was required to reschedule the tasks so that developing schedule task is much more friendly.

How?

  • In Schedule, reScheduleDeltaTime variable was removed completely and the method which used it, nextSchedule() was also removed.
  • ScheduleTask was changed from abstract class to interface, as there was no need for it to be an abstract class.
  • Created ScheduleCC Console Command, which includes commands to create, delete, show schedules which made working with schedule much more friendly.
  • Removed ScheduleCreateCC and ScheduleDBDeleteCC, as they did the same things as ScheduleCC.

Created ReScheduler

Why?

  • While making a ScheduleTask, developer is required to define nextSchedule() method which uses the previous schedule date in string format and have to return a date in string format for the next schedule.
  • Implementing such method is tedious as it includes a lot of verbose, hence a helper methods for such task will make it much more friendly.

How?

  • Two most used methods for re scheduling, viz. AfterDaysSameTime and AfterSecondsFromNow was created as a static method inside ReScheduler class.
  • These methods can be used inside nextSchedule() method in ScheduleTask to return the date directly from these methods.
  • AfterDaysSameTime reschedules on the same time as before, but after specified days, it is used to reschedule daily, weekly, monthly, yearly tasks.
  • AfterSecondsFromNow reschedules seconds after current time, it is used for tasks which run every x secs, minutes, hours.

Roadmap

Development for Supbot API has finished, but as developers are using the API, they request new features or some bad design in the bot is noticed, I will try my best to add/change it in the bot.

How to contribute?

You can contribute this project by,

  • Using the the API and creating issue when any bug is encountered.
  • Helping me in the development by bug squashing or developing new features. (If you want to do this, contact me so that we can collaborate.)
  • Let me know if you have any good feature ideas.

Contact

If you have any problems or you want to contact me for feature ideas or want to collaborate in development you can contact me on DefineX Community discord server

GitHub Account

https://github.com/adsau59

Sort:  

Thanks for the contribution, @adam-saudagar! I didn't realise WhatsApp didn't have any bot support and that's honestly very strange. It's great to see you have managed to find a way around this and are implementing useful features for people to use!

Your commit messages and the comments/documentation you had added are really good. It definitely makes it very easy to understand what's happening in the code. One thing I'd like to recommend is using a linter, as there are some minor inconsistencies in the code itself (like the indentation), but other than it looks great!


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

wow, that was a fast, thanks for reviewing my post,

can you let me know where specifically there was inconsistencies in indentation, I do use intellij idea it should take care of it.

Have a great day 😄

It's my pleasure! For example in here

public Helper getHelper() {
    return new Helper(
            "group show\n" +
                    "group add <gid>\n" +
                    "group remove <gid>",
            "group add group1",
            "Add, Remove, Show groups that can be recognized by the bot"
    );
}

I think the strings (each continuation line) should be indented by the same amount, but I could be wrong since I don't use Java much. There are also some things with too much vertical whitespace and missing horizontal whitespace (e.g. between if and the opening bracket). Maybe SonarLint could help with stuff like that (never used it personally).

Thank you for your review, @amosbastian!

So far this week you've reviewed 5 contributions. Keep up the good work!

Hi @adam-saudagar!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @adam-saudagar!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.33
TRX 0.11
JST 0.034
BTC 66363.68
ETH 3207.73
USDT 1.00
SBD 4.27