in #utopian-io2 years ago (edited)

Hi, I would like you to present my WIP BotAPI. This API provides fast and efficient way to write you own bot in short amount of time.

I had to repost this updated version because previous post "disappeared" and was not reviewed in time. I hope, this time it is going to be reviewed and accepted.

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 structure of what to do when creating a bot.

Now I'm going to show you recomended workflow when using this API:

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.

My future functionalities and goals which I need to achieve 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 to speed up bot creation

Posted on - Rewarding Open Source Contributors


Your contribution cannot be approved because it does not follow the Utopian Rules.

We have the following rule:

The repository must contain a readme file with usage and install instructions, as well as an appropriate open source license.

Your readme file does not contain example usage and installation steps.

Should you choose to proceed with this projuct, in your next contribution, please provide the following:

  1. Installation steps (Java, maven, or eclipse, etc.)
  2. Sample implementation (i.e., voting bot)
  3. Steps to run the bot

I see value in it because it's writte in Java and the promise that it will lessen the time to develop a bot based on rules.

You can contact us on Discord.

Hey @eastmael, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!