Steem has a large catalogue of Programming Interfaces with which we can obtain the data found on the network such as: comments, accounts, voting power of an account, steem power, votes, etc....
To encapsulate and reduce the complexity of using these interfaces, some programmers such as @xeroc decided to create libraries in python (a very friendly programming language) and that users could use their creativity to exploit the potential of this platform.
In this post, the collaborator @fintechresearch teaches us a simple way to set up a self-answering comment bot, that is, with a program that we leave running on a computer, each time a post is commented to us, it responds automatically.
You don't need advanced programming skills, not even intermediate ones, just a basic knowledge of programming to be able to do it.
This tutorial will be divided into four simple steps:
- Installing the piston library
- Editing the program
- Running the program and testing
Suppose you have a machine with a Linux operating system distributing Debian or Ubuntu.
If you don't have a Linux operating system or a virtual machine, we recommend you to follow this small tutorial first: youtube tutorial
Installing the piston library
In this first step we will open our virtual machine and in our command line we will put the following instructions.
$ sudo apt-get install libffi-dev libssl-dev python-dev python3-pip
$ pip3 install piston-lib
And now
$ pip3 install steem --user --upgrade
$ pip3 install piston-cli
And if everything went well, we'll have installed the piston library and updated.
For more information or clarification of any step please log on to the official repository:
Editing the program
Since we have the piston library installed correctly from the command line, we will open the gedit text editor or whatever you prefer.
$ gedit autoreply_bot.py
Inside this file we will copy and paste the following python script and then make some modifications.
from piston import Steem
steem = Steem(wif="tu_posting_private_key") #editar
accountname = 'tu_cuenta_de_steemit' #editar
for comment in steem.stream_comments():
print('Author: '+ comment.author)
print('permlink: '+ comment.permlink)
if "@%s" % accountname in comment["body"]:
comment.reply("mensaje que quieras")# edit
In the parts where it is commented edit we will put the necessary data for the bot to work and save the file with ctrl + s.
To see the commented and explained code go to this link of pastebin
Program Testing
Since we have edited our code correctly we are going to add our library piston our user from which we will use the bot to comment.
$ piston set default_author xeroc
changing xeroc for the account we want to post.
Now it is time to run the program with the following command
$ python3 autoreply_bot.py
We'll see an output similar to this one:
Follow @fintechresearch and vote for @cultura. bitcoin as witness to see more content like this...
scroll down, type & vote:
Discord Channel: https://discord.gg/7RNhzkB
@CulturaBitcoin
(Español)
Cultura Bitcoin
-
Criptomonedas Profesionales Español
Doesnt work. Piston command has not been found when i want to install:
pip3 install piston-cli
On a centos 7, it does not work i get:
and to the bottom:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
this is breaking news
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice info.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
hello thank you for your contribution. indeed, when I launched "python3 autoreply_bot.py", I have the message "lost connection to note during wsconnect(): wss://node.steem.ws". Do you know why ? Many thanks
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit