HiveBot - Easy & real-time automation on top of Hive Blockchain
HiveBot
HiveBot is an open-source free library that provides real-time automation on top of Hive Blockchain with a very simple API. It is very useful for the new comers who want to develop applications on Hive, It can be easily used to perform automated tasks without having to go through node's mechanism and tricky API.
This is basically an abstraction on top of the official JavaScript library of Hive, which is somehow a low-level API and is not easy to be used for newcomers of the platform.
Similar library was published by @p0o about 3 Years ago for Steem Blockchain called steem-bot
(GitHub Repo). Although it still works, it hasn't been updated in a very long time and its limited to Steem. This is a modified version of that library which is able to work on Hive's API and provide same and more functionalities.
Features
It has most of the common operations included. At this moment it is possible to monitor these actions:
- Receiving Deposits (For selected or all accounts)
- New Posts (For selected or all accounts)
- New Comments (For selected or all accounts)
Every action above can be optionally used to trigger an automatic response which can:
- Send HBD
- Send Hive
- Upvote
- Downvote
- Comment/Reply
Installation
NPM package is available. You should be fine to use it with any supported node-js version but feel free to report any issue here:
npm install hive-bot --save
Then include the package on top of your file:
const { HiveBot } = require('hive-bot');
How to use?
It has a very easy setup. For Instance, lets say you just want to monitor every deposit on the account poloniex
, you will start by defining the constructor:
const bot = new HiveBot({});
// or with username and keys (no need in this case):
// const bot = new HiveBot({username, postingKey, activeKey});
After than we call a function for the bot API to trigger a response whenever our target account (poloniex
) receive deposits:
// you can add more than one target users
const targetUsers = ['poloniex']
// first param will be target user and 2nd handler
bot.onDeposit(targetUsers, (data, responder) => {
console.log(data);
// no need to use responder since we are just monitoring
// on each deposit it will show a message like this
// { from: 'ali-h', to: 'poloniex', amount: '358 HIVE', memo: 'GbH4HgV35Ygv'}
});
Now after all the functions are declared you only have to start the bot like this:
// this function will start the bot and keep it open
bot.start();
Just simple as this, this is only one example of many possibilities, you may visit HiveBot's GitHub Repo for complete explanation and more examples.
- Depositing HIVE or HBD from users click here
- Notifying on every Deposit, Comment & Post (without arguments) click here
- Auto voting on every new post from a list of users click here
- Change RPC node click here
- Error handling click here
Further Development
This package is still under development and I have many more features planned to implement very soon, like support for Communities, Hive-Engine tokens and detecting commands or mentions in comments (like @tipu curate!
or !trdo
) which are very useful to create curation and more dynamic bots. This package is using Semantic versioning so you don't have to worry about changes in API breaking your bot. Feel free to use it and give your feedback.
Links
GitHub Repository
NPM Package
GitHub Profile
Steemit Profile
Discord: Ali H#7057
[email protected]
Thanks for this post.