Steem Voice A0.5 - Write a comment and upvote using your voice !
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:
![](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmR3wrmWvKw7t5hZARwMR9STyz2GhNCV9hFrXgTrdZPJ6N/Seperator.png)
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')
![](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmR3wrmWvKw7t5hZARwMR9STyz2GhNCV9hFrXgTrdZPJ6N/Seperator.png)
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:
![](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmR3wrmWvKw7t5hZARwMR9STyz2GhNCV9hFrXgTrdZPJ6N/Seperator.png)
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:
![](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmR3wrmWvKw7t5hZARwMR9STyz2GhNCV9hFrXgTrdZPJ6N/Seperator.png)
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
Great set of updates.
Do you think you can also support downvoting? I see that you limit percent to positive values.
I will try to come up with a formula for that.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Thank you so much :)
Good idea! I'll make sure to add that in the next update. Please let me know when you do!Thank you for your review, @emrebeyler! Keep up the good work!
Hi @fancybrothers!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Hey, @fancybrothers!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Congratulations @fancybrothers! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
To support your work, I also upvoted your post!