Steem Voice
Hello everyone! Welcome back to the fifth development update of the Steem Voice app. This update is quite an interesting one because Steem Voice is now using V2 API thanks to the new update in flask-assistant
which is probably the core of this project. This migration could really help optimize the project and overcome a lot of the issues I faced developing Steem Voice. I altered a lot of the commands to be compatible with the new migration. I also did a whole lot of testing, checking every single command in the app.
New Features
V2 Migration
I hate to bore you with all the little details that I changed including the ones I changed in Dialog flow. To summarize it all here are some of the things that I changed.
app.config['ASSIST_ACTIONS_ON_GOOGLE'] = True # To enable Rich Messages
Is now
app.config['INTEGRATIONS'] = ['ACTIONS_ON_GOOGLE'] # To enable Rich Messages
V2 also requires you to add the project's ID so I made it into an environment variable like so:
assist = Assistant(app, route='/api', project_id=os.environ.get('project_id'))
Also img_alt
is no longer required and linkTitle
is now link_title
You can check out the migration's commit for more details.
Added a downvote command
Even though all that tweaking and testing took way more time that I thought, I couldn't leave the update there. So I made 3 new commands.
The down vote command is embedded into the upvote one added in the last update like so: (Thanks @emrebeyler for the suggestion)
def r_upvote(number,vote):
if (int(number)<=100) and (0<=int(number)):
global percent, votetype
votetype = vote
if votetype == 'upvote':
percent = int(number)
return ask('Would you like to confirm this upvote: %s percent' % percent).suggest('Yes','No')
else:
percent = -int(number)
return ask('Would you like to confirm this downvote: %s percent' % (-1*percent)).suggest('Yes','No')
else:
return ask('Please make sure to enter a valid percent')
As you can see I added a variable called vote type
which distinguishes if it's an upvote or a downvote. I also had to modify the broadcast function to make the conversation more "legit":
def r_broadcastupvote(yon):
try:
global percent, posts, Option, votetype
vote = Vote(sc.me()['name'], posts[Option]["author"], posts[Option]["permlink"], int(percent))
sc.broadcast([vote.to_operation_structure()])
if votetype =='upvote':
return ask('broadcasting upvote to %s' % posts[Option]['title'])
else:
return ask('broadcasting downvote to %s' % posts[Option]['title'])
except: # If the user didn't connect his account
return ask('Please connect your account before using this command')
Added a who is command
This is a simple command that shows you the name, description and avatar of a specific user. Here's the code for it:
def r_whois(username):
user = Steemian(username)
resp = ask('There you go')
resp.card(title='Name: %s' % user.data["json_metadata"]["profile"]['name'],
text='Description: %s' % user.data["json_metadata"]["profile"]['about'],
img_url='https://steemitimages.com/u/'+username+'/avatar',
)
return resp
Here's a video of the command:
Added a reguser command
This command allows new users to register their name in the database so that I can go through them manually and add synoyms to make it easier for the app to catch the username right. For now, I'm saving the database in a localfile called usernames.json
. This will surely change into a remote file later when I release the app. With that out of the way, here's the code for it:
def r_reguser():
try:
with open('usernames.json') as old:
database = json.load(old)
name = {sc.me()['name']:sc.me()['name']}
database.update(name)
with open('usernames.json', 'w') as new:
json.dump(database, new)
return ask('Done %s was sucessfully added.' % sc.me()['name'] )
except:
return ask('Please connect your account before using this command')
Here's a video of the command:
How to install
You can follow the guide I wrote in the third update
Roadmap
Next step is 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