Java BotAPI to create advanced steem bots fast

in #utopian-io6 years ago

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:

  1. Programmer gets general bot configuration from files. I created example bot preparation in BotsPreparator class.
  2. Once configuration is loaded, programmer needs to implement Bot interface. Example implementation is in BotRandomUpvoter. Bot extends thread itself so it's multihreaded in example. init method passes all required informations for bot. Currently it contains "user" variable which will be removed in future API versions. start method 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 getAllRequiredKeyProperties method in more places. It is useful when you want to make sure that bot gets all configuration from config files. I used Properties class to load data. My example implementations of bots contains all cool class used. Once you prepared Bot class, now let's see next step.
  3. In this step programmer should start implementing bot logic. In my example run method from Thread class is responsible for bot logic. First what needs to be implemented is "feeding" bot with user informations. To do it, you need to implement HelpInformation interface for different information getters. If you get informations, you should add them to HashMap<String, Argument> and return it to a bot. Argument class 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.
  4. 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 LinkedList class used in BotRule interface or BotAction interface.

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 getAllRequiredKeyProperties and getAllRequiredRuntimeKeyProperties works.

Obviously, my future functionalities will be:

  1. Fully complete 2 example bot implementations
  2. Simplify this API even more
  3. Write proper documentation
  4. Add more pre-implemented bot parts.



Posted on Utopian.io - Rewarding Open Source Contributors

Coin Marketplace

STEEM 0.26
TRX 0.11
JST 0.033
BTC 64107.21
ETH 3073.84
USDT 1.00
SBD 3.88