How to program your autorespond bot in Steemit

in steemit •  7 years ago  (edited)

blur-1853305_1920asdgadggadg.jpg
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:

  1. Installing the piston library
  2. Editing the program
  3. 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

1.PNG

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:

Piston

Editing the program

2.PNG

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

3.PNG

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:
4.PNG

Follow @fintechresearch and vote for @cultura. bitcoin as witness to see more content like this...


Vote here for diversity, vote for Cultura Bitcoin: https://steemit.com/~witnesses
scroll down, type & vote:

DQmfFRxgtjvbM8i8e8fTzq400.png


See you soon, fellows!


Discord Channel: https://discord.gg/7RNhzkB

@CulturaBitcoin

(Español)
Cultura Bitcoin

-

Criptomonedas Profesionales Español

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

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:

err.png

and to the bottom:

errrrr.png

this is breaking news

Nice info.

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