Steem Voice
Hello everyone! Welcome back to the fourth development update of the Steem Voice app. Following the comment of @emrebeyler on the last post I started off by changingclient_id
, client_secret
and server
into environment variables. I also changed my whole working environment. I started using Visual Studio Code and I made a batch file that automatically starts the server when I start debugging. I also switched from ngrok to localtunnel which made everything much easier because it allows you to set a fixed url unlike ngrok. Also, I couldn't figue out how to calculate max_mana in order to see if the users's available RC allows a potential delegation. If anyone knows how, I would appreciate the help.
With that out of the way, let's get into this update's new commands...
New Features
Added Transfer command
First, I added a basic command that allows the user to transfer Steem or SBD to another user using a Steemconnect link. All done using this simple code:
@assist.action('transfer')
def r_transfer(number,currency,username):
url = sc.hot_sign(
"transfer",
{
"to": username,
"amount": number+' '+currency.upper(),
},
)
return ask('Click the button below to continue with your transfer:').link_out('Transfer',url)
Here's a video of the command:
Added a userposts
command
To use this command, you can say something like What are the latest posts of (user). The app will then return the last 8 posts from that user's blog:
def r_userposts(username):
global posts
discussion_query = {
"tag": username.replace(' ', ''),
"limit": 8,
}
posts = s.get_discussions_by_blog(discussion_query)
resp = ask('There you go:').build_carousel()
for i in range(len(posts)):
resp.add_item(posts[i]['title'],
key=(str(i)),
description=resteem(username,posts[i]['author']),
img_url=getpostimg(i) # To get the avatar image of the delegatee
)
return resp
As you might have noticied I made a function called resteem which add a Resteemed description if the post is resteemed. Here's the code for it:
def resteem(username,author):
if username == author:
return ('A post by %s' % username)
else:
return ('Resteemed')
Added a comment command
Now let's get to the good stuff. This is probably my favourite command in the app. To use this command, the user have to use one of the navigation commands (What are the latest posts of (user) or What's _category in _tag (e.g what's new in science)) then he choses a post. After that, the app returns a card of the chosen post. To do so, I added suggestion chips and used the same previous code in all the commands:
@assist.action('userpostsrep')
@assist.action('r_openfeed')
@assist.action('trendingresp') # To show a card of the post chosen
def r_trendingresp(OPTION):
global posts, Option
Option = int(OPTION) # This is the key of the chosen post
postlink = 'https://steemit.com/@'+posts[Option]['author']+'/'+posts[Option]['permlink']
resp = ask('Click the button below to open the post')
date,time = posts[Option]['created'].split('T')
resp.card(title=posts[Option]['title'],
text=('A post by %s created on %s at %s' % (posts[Option]['author'],date,time)),
img_url=getpostimg(Option),
img_alt='test', # This field is required
link=postlink,
linkTitle='Open The post'
)
return resp.suggest('Upvote the post', 'Write a comment')
Now the user can choose to write a comment. When he does the app will ask the user (What do you wanna say?) the api is called again to this action:
@assist.action('commentconfirmation')
def r_comment(any):
global comment
comment = any
return ask('Would you like to confirm this comment: %s' % comment).suggest('Yes','No')
The action above allows the app to capture the user's comment in a global variable then asks for confirmation. Finally, another action is called which broadcasts the comment in case the user confirms the operation.
@assist.action('broadcastcomment')
def r_broadcastcomment(yon):
try:
global comment,posts,Option
if yon == 'Yes':
finalcomment = Comment(
sc.me()["name"], #author
randomperm(10), #permlink
comment, #body
parent_author=posts[Option]['author'],
parent_permlink=posts[Option]['permlink'],
)
sc.broadcast([finalcomment.to_operation_structure()])
return ask('broadcasting %s to %s' % (comment,posts[Option]['title']))
else:
return ask('Canceling comment')
except: # If the user didn't connect his account
return ask('Please connect your account before using this command')
Here's a video of the command in action:
Added an upvote command
This command uses the same principle as the previous one so I won't be getting into any details. Here's the code:
@assist.action('upvoteconfirmation')
def r_upvote(number):
if (int(number)<=100) and (0<=int(number)):
global percent
percent = number
return ask('Would you like to confirm this upvote: %s percent' % percent).suggest('Yes','No')
else:
return ask('Please make sure to enter a valid percent')
@assist.action('broadcastupvote')
def r_broadcastupvote(yon):
try:
global percent, posts, Option
vote = Vote(sc.me()['name'], posts[Option]["author"], posts[Option]["permlink"], int(percent))
sc.broadcast([vote.to_operation_structure()])
return ask('broadcasting upvote to %s' % posts[Option]['title'])
except: # If the user didn't connect his account
return ask('Please connect your account before using this command')
And, here's a video:
I forgot to show that the operation actually went through so here's a snap from steemd:


How to install
You can follow the guide I wrote in the third update
Roadmap
Next step is to add even more advanced commands. Then I'll probably start preparing for the release of the app like organizing the code and finding solutions to potential problems...
How to contribute?
Everyone is welcome to aid. You can contribute to the development of this project by creating a pull request to my repository. You can also get in touch with me on Discord at Fancybrothers#7429 or on Steem.chat at fancybrothers or simply leave your idea down below.
My Github account: https://github.com/Fancybrothers