Hi, in this contribution I would like you to present my WIP BotAPI. It allows programmers to create their own steem bots within few hours.
The main idea of this BotAPI is to structure repetitive code and make programmers life easier.
This API uses SteemJ library to connect with steem blockchain.
When programmer uses this API, he has clear idea how this bot works.
It's simple workflow,:
Get config data->feed bot with live data->check if those informations are enough to take actions by proper rules->repeat previous step with next action->go to feeding step.
To make bot working indefinitely we just put him in never ending loop kind of code and it's good to go.
Now, I would like to show you basic and kinda explained structure of proposed bot which is expected when using this API:
- Programmer gets general bot configuration from files. I created example bot preparation in
- Once configuration is loaded, programmer needs to implement
Botinterface. Example implementation is in
BotRandomUpvoter. Bot extends thread itself so it's multihreaded in example.
initmethod passes all required informations for bot. Currently it contains "user" variable which will be removed in future API versions.
startmethod starts bot. Well, most methods are self explaining. The one interesting is
getAllRequiredKeyProperties. This method propagates all required configuration keys to be passed to bot. In this API you are going to see
getAllRequiredKeyPropertiesmethod in more places. It is useful when you want to make sure that bot gets all configuration from config files. I used
Propertiesclass to load data. My example implementations of bots contains all cool class used. Once you prepared
Botclass, now let's see next step.
- In this step programmer should start implementing bot logic. In my example
Threadclass is responsible for bot logic. First what needs to be implemented is "feeding" bot with user informations. To do it, you need to implement
HelpInformationinterface for different information getters. If you get informations, you should add them to
HashMap<String, Argument>and return it to a bot.
Argumentclass is responsible for storing data and representing that in expected way. Example bot implementation is good place to look at until proper documentation is going to be prepared.
- If we have got all needed informations, our bot should take some actions, but it won't do anything without proper rules which will help bot to decide whether to take action or not. Well, you can implement as many actions as you want. The same is with rules. Order of those rules might be important so there are
LinkedListclass used in
All those informations provided above should give you an idea if you would like to use this API. Let's say this stage is still alpha, but I improve it every weekend so I'm going to post more contributions regardless to this project.
To learn how to use this API, I suggest you reading this first as it's good starting point.
You can already use example bot parts to build your own bot. If you run this library, you will be able to test example bot and see how
Obviously, my future functionalities will be:
- Fully complete 2 example bot implementations
- Simplify this API even more
- Write proper documentation
- Add more pre-implemented bot parts.
Posted on Utopian.io - Rewarding Open Source Contributors