npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

steem-bot

v0.8.1

Published

Easy automation on top of Steem blockchain

Downloads

8

Readme

SteemBot

SteemBot provides real-time automation on top of Steem blockchain with a very simple API. You can use it to quickly bootstrap an automated task with Steem without having much understanding about the node's mechanism and tricky API.

This library is basically an abstraction on top of the official JavaScript library of Steem, called Steem-js which is somehow a low-level API and is not easy to be used for newcomers of the platform.

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:

npm install steem-bot --save

Then include the package on top of your file:

const SteemBot = require('steem-bot').default
// or if your environment supports import/export:
import SteemBot from 'steem-bot';

How to use?

Start with defining the constructor. You should define the constructor based on the type of operations you need to perform. If you are just observing the blockchain no argument is required. But if you need to post anything you would need to define your username and private postingKey. Also you would need to define your activeKey if you need to transfer STEEM or SBD.

// monitoring all the deposits to poloniex and bittrex accounts real-time
const targetUsers = ['poloniex', 'bittrex'];

const bot = new SteemBot();
// or with username and keys:
// const bot = new SteemBot({username, postingKey, activeKey});

bot.onDeposit(targetUsers, (data) => {
  console.log(data); // { from: 'p0o', to: 'poloniex', amount: '10 STEEM', memo: 'GbH4HgV35Ygv'}
});

// this function will start the bot and keep it open
bot.start();

Examples

Here you can find some sample codes of things you can do with SteemBot.

API

The API is very consistent and follow the same set of rules.

Events

SteemBot constructor after declaration will provide some methods as events which you can use to trigger different behaviors for different users. The first argument of every event method is always targetUsers and the second one is handler function. If you omit targetUsers the first one will be handler function.

Events are listed below:

onDeposit

Used to trigger deposits. Examples:

// getting all the deposits for user "bittrex"
bot.onDeposit('bittrex', eventHandler);

// getting all the deposits for users "bittrex" and "poloniex"
bot.onDeposit(['bittrex', 'poloniex'], eventHandler);

// getting all the deposits from all users
bot.onDeposit(eventHandler);

onPost

Used to trigger all the posts. You can use it for one user, many users or all users of the platform similar to the deposit example above.

// getting all the posts submited by user "bittrex"
bot.onPost('bittrex', eventHandler);

// getting all the posts submitted from users "bittrex" and "poloniex"
bot.onPost(['bittrex', 'poloniex'], eventHandler);

// getting all the posts from all users
bot.onPost(eventHandler);

onComment

Used to trigger comments. You can use it for one user, many users or all users of the platform similar to the deposit example above.

// getting all the comments submited by user "bittrex"
bot.onComment('bittrex', handler);

// getting all the comments submitted from users "bittrex" and "poloniex"
bot.onComment(['bittrex', 'poloniex'], handler);

// getting all the comments from all users
bot.onComment(handler);

targetUsers

Could be simply one string with the username of a Steem account or an array of usernames. Omitting this parameter will require the event to trigger all users.

eventHandler

The handler function (as stated above as "handler") is a function with 2 arguments. This function will be examined for every block (each 3 seconds) and if is triggered by your hooks will be executed with 2 parameters. Data and Responder.

Data

Data is the first parameter of eventHandler and is an object directly returned from blockchain's streamOperations API. The contents of this object is different based on the event and would provide the data regarding the block's operation related to your event.

Responder

Responder is the second parameter of eventHandler and is a very powerful class which will help you to directly act on your events without doing all the low-level operations. For example you can easily use Responder to comment on the data received from your event, upvote or downvote them.

You can use responder like this:

bot.onPost(handlePost);

function handlePost(data, responder) {
  responder.upvote();
  responder.comment(`Hi @${data.author} there! I just upvoted you using SteemBot JavaScript library!`);
}

bot.start();

This snippet will upvote on any new post on Steem and leave a comment in that particular post (better not to execute it!)

Currently Responder provide you these methods to use:

Responder.comment(message)

  • message is a string containing your comment text.
  • Returns: bluebird standard promise

Responder.upvote(votingPercentage)

  • votingPercentage: is a float or string to indicate the voting percentage from 0 to 100%. If omitted default is 100%.
  • Returns: bluebird standard promise

Responder.downvote(votingPercentage)

  • votingPercentage: is a float or string to indicate the flagging percentage from 0 to 100%. If omitted default is 100%.
  • Returns: bluebird standard promise

Responder.sendSbd(amount, memo)

  • amount: is a float or string to indicate the amount of SBD to be sent from your account. You need to define the activeKey to SteemBot before using this feature.
  • memo: a string to be sent as memo.
  • Returns: bluebird standard promise

Responder.sendSteem(amount, memo)

  • amount: is a float or string to indicate the amount of STEEM to be sent from your account. You need to define the activeKey to SteemBot before using this feature.
  • memo: a string to be sent as memo.
  • Returns: bluebird standard promise

Memo Operations:

It's a common practice for bots (like randowhale, minnowbooster etc) to use a Steemit link in memos while depositing so the bot can use the link for any purpose (sending money or commenting). However, extracting the memo and performin low-level operations to use it is a headache, so SteemBot is providing helper methods to facilitate this process.

Responder.commentOnMemo(message) Works similiar to Responder.comment but you can use it on deposit events when users include steemit link as memo. See randowhale example for more info.

Responder.upvoteOnMemo(votingPercentage) Works similiar to Responder.upvote but you can use it on deposit events when users include steemit link as memo. See randowhale example for more info.

Responder.downvoteOnMemo(votingPercentage) Works similiar to Responder.downvote but you can use it on deposit events when users include steemit link as memo. See randowhale example for more info.

Further development

This package is still under development. Feel free to use it and feedback using github issues.

Versioning

This package is using Semantic versioning to make sure changes in API will not break your bots.