Ep.4 Scheduler | Supbot Whatsapp Chatbot API
What Will I Learn?
- What is Scheduler used for in Supbot API?
- How Scheduler works in Supbot API?
- How to use Scheduler in Supbot API?
- Java Development Kit, IDEA intellij
- Google Chrome, Selenium Chrome Webdrivers
- Supbot API
- Natty, natural language date parser
Resources for this Tutorial:
Outline and Overview
In this Supbot tutorial we will take a look on Scheduler.
What is Scheduler used for?
It is used in two ways,
- Periodic Task,
Tasks which are performed on an interval, like daily, weekly, yearly tasks
- Timed Task,
Tasks which are scheduled for a specific time, like reminders
How does Scheduler works?
Scheduler in Supbot API works using 3 componnets,
ScheduleTask is an interface with 3 methods,
task(): This method is used is executed when the schedule is arrived.
taskMissed(): This method is used is executed when the schedule is missed.
getNextSchedule(): This method is used to reschedule the date for the next schedule, can return null if the schedule is to be destroyed after running.
- ScheduleTask implements
- Schedule class encapsulates ScheduleTask, the date for schedule and the timer object.
- Schedule also calculates the delay for the Schedule when the bot is launched.
ScheduleManager has two jobs,
- First is to add the schedule to the database when it is added,
- and Second is to reload the schedule back when the bot is started.
How to use Scheduler?
There are two methods to use Scheduler,
- Static Method
- Dynamic Method
Static Method of creating Scheduler is used when you want to create the schedule yourself and has to be initialized just once.
In order to create Scheduler using static method you have to,
- Create a class which implements ScheduleTask.
- Add the class object of the class you made into ScheduleTaskInitializer using
Bot.getScheduleTaskInitializer.add()method in the
addThingsInBotmethod in the Main class.
- then use
schedule createconsole command to initialize the Schedule.
Dynamic Method of creating Scheduler is used when you want the clients to create the schedule or it has to be initialized multiple times.
In order to create Scheduler using dynamic method you have to,
- Create a class which implements ScheduleTask.
- Create a Schedule Object using it.
- Add it into ScheduleManager using
After we learn about Scheduler, we will look both of these methods in the video tutorial by creating,
- GoodMorning Scheduler, which sends good morning messege every morning, and
- RemindMe Command, which creates a reminder for the time the client specifies using
Creating the GoodMorning Scheduler you will learn how to create Schedule using Static method and creating RemindMe Command you will learn how to create Schedule using Dynamic method.
This will create an understanding for you by which you can use both of these methods when it is required when you create your own features.
If you have any problems or you want to contact me on DefineX Community discord server
Thank you for your contribution to the video tutorial category.
In this tutorial, the word 'schedule' is used a lot. You mispronounced the word and this can be very annoying to the listener. So what you need to do is to look up the words that occur frequently and make sure you know how to pronounce the words. This will help to improve your audio presentation greatly.
I look forward to your next presentation.
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.
Thanks for the review,
Sorry for the echo, just bought a new microphone to create vids, will try to configure it better
and for the "schedule",
In India, we use UK English pronunciation. Check this out
Thank you for your review, @rosatravels! Keep up the good work!
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
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!
Congratulations @adam-saudagar! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
Do not miss the last post from @steemitboard: