Specify the app name in a post or comment using beem | Steem Discord Bot Python #13

in hive-151113 •  last year 

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.

lec13.png

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, In 11th lecture learned how to install the beem library to interact with the Steem blockchain and how to case vote to a post.

In 12th lecture, we learned how to use the Beem Python library to send comments on a post. In today's lecture, we will learn how we can specify our app name using the options in the Comment metho in Beem library. When a user publishes a post or a comment our app name will be added to the JSON response of that post. Let's get started.

Procedure
  • We will use the !send command which is already configured in the 12th lecture. We will add a parameter to the Comment method provided by the beem API.
response = comment.reply(body=body, author=utils.voter_username, meta={'app': 'steemlite/0.1.2'})

image.png

  • We also need to make some fixes. The identifier is with @ so there is no need to write it again in the success message.
 comment = Comment(authorperm=identifier, blockchain_instance=steem)
                    response = comment.reply(body=body, author=utils.voter_username, meta={'app': 'steemlite/0.1.2'})
                    if response.get('trx_id'):
                        await message.reply(f'Comment sent to https://www.steemit.com/{identifier}')
                    else:
                        await message.reply(f'Failed')

  • Let's check if the app name is showing in the JSON response or not. Here is the direct JSON response link for the published comment.

https://steemit.com/hive-151113/@faisalamin/re-cast-a-vote-using-beem-20231009t103920z.json

image.png

Github
Steem Discord Bot Series
SteemPro Official

Cc: @blacks
Cc: @rme
Cc: @hungry-griffin
Cc: @steemchiller
Cc: @steemcurator01
Cc: @pennsif
Cc: @future.witness
Cc: @stephenkendal
Cc: @justyy


Best Regards @faisalamin

Download SteemPro Mobile

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:  

well done

Congratulations, your post has been upvoted by @dsc-r2cornell, which is the curating account for @R2cornell's Discord Community.

Manually curated by @jasonmunapasee

r2cornell_curation_banner.png