Welcome back, developers.
Greetings to all Steem enthusiasts! In today's lecture, we will learn how to install the beem library for interacting with the Steem blockchain, as well as how to cast a vote on a post.

Summary |
---|
We established the necessary environment for developing a Python-based Discord bot during our first lecture. In our second lecture we create a discord bot token, configure the bot and generate the invite link. We used the invite link and added the bot to our server. In our third lecture, we will bring the Community-Bot online in our local environment.
In the 4th lecture, we successfully developed our initial bot command, !info. We also learned how to create functions and retrieve data using the requests library in 5th lecture. We implemented the !info command in 6th lecture which is used fetch the information of any steem user.
In the 7th lecture, we learned how to send an embedded message with columns, images, and a profile image. In lecture 8th we learn how to generate a report for the community. In lecture 9th we learned how to develop a report and create a text file, then attach it to a Discord bot. In 10th lecture we learned how to get a single-author report for a community. In today's lecture, we will learn how to install the beem library to interact with the Steem blockchain and how to case vote to a post.
Procedure |
---|
- First of all, we need to install beem. Beem is a Python library for interacting with the Steem blockchain. Type
pip install beem
in your PyCharm terminal and hit enter. Make sure you are using Python 3.8.
- Now we need to create an instance for the Steem. We will create an instance in the utils.py. So that we can access it anywhere in our project easily. Import from beem import Steem first and then add the private posting key and steem_vote_instance in Utils.
# private posting key of voter account
self.voter_username = 'faisalamin'
# private posting key of voter account
self.voter_private_posting_key = ''
# Nodes for the steem instance
self.steem_nodes = "https://api.steemit.com"
# steem vote instances
self.steem_vote_instance = Steem(node=self.steem_nodes, keys=self.voter_private_posting_key)
- Now add a command !vote in our command list. We will use this command to cast a vote with the percentage given by the user to the bot.
# bot commands
self.commands = ['!info', '!report', '!vote']
- Now implement the command in main.py. Our command will have 3 parameters. Command itself, post link, and vote weight. We will extract the permlink (Permanent Link) from the post link.
# !vote command
if command == utils.commands[2]:
if len(props) == 3:
post_link = str(props[1]).split('/')
post_link.reverse()
perm_link = post_link[0]
post_author = post_link[1]
identifier = f'{post_author}/{perm_link}'
weight = float(props[2])
await message.channel.typing()
try:
steem = utils.steem_vote_instance
except Exception as e:
await message.channel.send("Error: " + str(e))
- Now we need to use the steem instance to cast the vote and check if it is successfully casted or not by checking the trx_id.
# !vote command
if command == utils.commands[2]:
if len(props) == 3:
post_link = str(props[1]).split('/')
post_link.reverse()
perm_link = post_link[0]
post_author = post_link[1]
identifier = f'{post_author}/{perm_link}'
weight = float(props[2])
await message.channel.typing()
try:
steem = utils.steem_vote_instance
response = steem.vote(weight=weight, identifier=identifier, account=utils.voter_username, )
if response.get('trx_id'):
await message.reply(f'Voted at {weight}%')
else:
await message.reply(f'Failed')
except Exception as e:
await message.channel.send("Error: " + str(e))
- Let's run and test the command
Github |
---|
Steem Discord Bot Series |
---|
Lecture #1: Develop a Discord bot for your Steem Community
Lecture #2: How to Add a Bot to Your Discord Server
Lecture #3: Bring the Steem Discord Bot Online
Lecture #4: First Bot Command
lecture #5: Retrieving Steemit Account Information using SDS
Lecture #6: Implementing !info Command
Lecture #7: Discord Embed Reply with User Info
Lecture #8: Generate Community Report
Lecture #9: Attach Community Report
Lecture #10: Generate Author Report for Community
SteemPro Official |
---|
Download SteemPro Mobile
https://play.google.com/store/apps/details?id=com.steempro.mobileVisit here.
https://www.steempro.comSteemPro Discord
Official Discord Server
Cc: @blacks
Cc: @rme
Cc: @hungry-griffin
Cc: @steemchiller
Cc: @steemcurator01
Cc: @pennsif
Cc: @future.witness
Cc: @stephenkendal
Cc: @justyy
Best Regards @faisalamin
Hello testing the steem community bot created by @faisalamin
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hello testing the steem community bot created by @faisalamin
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit