 >SockoBot is trying to be the only tool you'll ever need on your Discord Server or Facebook Page when it comes to steem, while also being easily expandable to anyone that knows a bit of Python. ## SockoBot * [github repository](https://github.com/Jestemkioskiem/steem-sockobot) * [author](https://github.com/Jestemkioskiem/) ## Languages * Python 3.6 ### New Features #### What feature(s) did you add? In this update, I addressed some of the requests suggested to me by @venalbe over [here](https://steemit.com/utopian-io/@venalbe/sockobot-ideas-for-a-monkey-faced-bot-round-01). Namely, I've added the ```$wallet``` and ```$blocktrades``` (now known as ```$convert```) commands. On top of that, I've decided to bring a command for showing just the Steem Power and delegations of the user - ```$sp```. To deal with these issues, I've added 2 new functions that aided me in creating these functionalities, but will also be really useful if the bot ever expands in these directions, ```calculate_steem_power()``` and ```calculate_estimated_acc_value()```. On top of that, I've updated the ```$price``` function to work with all the coins just like the facebook version of the bot does. ##### Commands: * The ```wallet``` command was added, which fetches and displays data that can be found in the **wallet** page of steemit.com and most other big apps, namely:  You can see the code here: ```python elif text.lower().startswith('wallet'): try: user_name = text.split(' ')[1] except IndexError: await client.send_message(msg.channel, str("Too few arguments provided")) return 0 acc = Account(user_name, steemd_instance=s) url = requests.get('https://steemitimages.com/u/' + user_name + '/avatar/small', allow_redirects=True).url vests = float(acc['vesting_shares'].replace('VESTS', '')) sp = calculate_steem_power(vests) rec_vests = float(acc['received_vesting_shares'].replace('VESTS', '')) rec_sp = calculate_steem_power(rec_vests) del_vests = float(acc['delegated_vesting_shares'].replace('VESTS', '')) del_sp = calculate_steem_power(del_vests) sp_diff = round(rec_sp - del_sp, 2) voting_power = round(float(Account(user_name)['voting_power'] / 100), 2) estimated_upvote = round(calculate_estimated_upvote(user_name), 2) embed=discord.Embed(color=0xe3b13c) embed.set_author(name='@' + user_name, icon_url=url) embed.add_field(name="Steem", value=str(str(acc['balance'].replace('STEEM', ''))), inline=True) embed.add_field(name="Steem Dollars", value=str(acc['sbd_balance'].replace('SBD', '')), inline=True) if sp_diff >= 0: embed.add_field(name="Steem Power", value=str(sp) + " ( +" + str(sp_diff) + ")", inline=True) else: embed.add_field(name="Steem Power", value=str(sp) + " ( " + str(sp_diff) + ")", inline=True) embed.add_field(name="Estimated Account Value", value=str(calculate_estimated_acc_value(user_name)), inline=True) embed.add_field(name="Estimated Vote Value", value=str(estimated_upvote) + " $", inline=True) embed.set_footer(text="SockoBot - a Steem bot by Vctr#5566 (@jestemkioskiem)") await client.send_message(msg.channel, embed=embed) ``` * The ```convert``` command was added, which takes an amount and 2 coins as arguments and displays the amount you can receive upon conversion.  You can see the code here: ```python elif text.lower().startswith('convert'): try: value = text.split(' ')[1] coin1 = text.split(' ')[2].lower() coin2 = text.split(' ')[3].lower() except IndexError: await client.send_message(msg.channel, str("Too few arguments provided")) return None try: price1 = cmc.ticker(coin1, limit="3", convert="USD")[0].get("price_usd", "none") price2 = cmc.ticker(coin2, limit="3", convert="USD")[0].get("price_usd", "none") except Exception: await client.send_message(msg.channel, str("You need to provide the full name of the coin (as per coinmarketcap).")) conv_rate = float(price1)/float(price2) outcome = float(value) * conv_rate await client.send_message(msg.channel, str("You can receive " + str(outcome) + " **" + coin2 + "** for " + str(value) + " **" + coin1 + "**." )) ``` * The ```sp``` command was added, which fetches and displays the steem power and delegations of a given user.  You can see the code here: ```python elif text.lower().startswith('sp'): try: user_name = text.split(' ')[1] except IndexError: await client.send_message(msg.channel, str("Too few arguments provided")) return 0 acc = Account(user_name, steemd_instance=s) url = requests.get('https://steemitimages.com/u/' + user_name + '/avatar/small', allow_redirects=True).url vests = float(acc['vesting_shares'].replace('VESTS', '')) sp = calculate_steem_power(vests) rec_vests = float(acc['received_vesting_shares'].replace('VESTS', '')) rec_sp = calculate_steem_power(rec_vests) del_vests = float(acc['delegated_vesting_shares'].replace('VESTS', '')) del_sp = calculate_steem_power(del_vests) sp_diff = round(rec_sp - del_sp, 2) embed=discord.Embed(color=0xe3b13c) embed.set_author(name='@' + user_name, icon_url=url) embed.add_field(name="Steem Power", value=str(sp), inline=True) if sp_diff >= 0: embed.add_field(name="Delegations", value="+" + str(sp_diff), inline=True) else: embed.add_field(name="Delegations", value=str(sp_diff), inline=True) await client.send_message(msg.channel, embed=embed) ``` ##### Functions: * The ```calculate_estimated_acc_value()``` function was added, which takes ```user_name``` as an input, and returns the estimated account value based on current prices of **STEEM** and **SBD** (fetched from coinmarketcap) You can see the code here: ```python steem_price = float(cmc.ticker('steem', limit="3", convert="USD")[0].get("price_usd", "none")) sbd_price = float(cmc.ticker('steem-dollars', limit="3", convert="USD")[0].get("price_usd", "none")) acc = Account(user_name, steemd_instance=s) vests = float(acc['vesting_shares'].replace('VESTS', '')) sp = calculate_steem_power(vests) steem_balance = float(acc['balance'].replace('STEEM', '')) sbd_balance = float(acc['sbd_balance'].replace('SBD', '')) outcome = round(((sp + steem_balance) * steem_price ) + (sbd_balance * sbd_price), 2) return str(outcome) + " USD" ``` * The ```calculate_steem_power()``` function was added, which takes ```VESTS``` as an input, and returns a value of **STEEM POWER** based on information from the blockchain. You can see the code here: ```python post = '{"id":1,"jsonrpc":"2.0","method":"get_dynamic_global_properties", "params": []}' response = session_post('https://api.steemit.com', post) data = json.loads(response.text) data = data['result'] total_vesting_fund_steem = float(data['total_vesting_fund_steem'].replace('STEEM', '')) total_vesting_shares = float(data['total_vesting_shares'].replace('VESTS', '')) return round(total_vesting_fund_steem * (float(vests)/total_vesting_shares), 2) ``` ##### Other On top of that, some other small changes were made: * The bot will now respond to the ```$price``` command the same way the facebook version does - it works with all the coins & tokens listed on coinmarketcap instead of just SBD, STEEM and BTC. ```python elif text.lower().startswith('price'): try: coin = text.split(' ')[1].lower() except IndexError: return str("Too few arguments provided") try: value = cmc.ticker(coin, limit="3", convert="USD")[0].get("price_usd", "none") await client.send_message(msg.channel, str("The current price of **"+ coin +"** is: *" + str(value) + "* USD.")) except Exception: await client.send_message(msg.channel, str("You need to provide the full name of the coin (as per coinmarketcap).")) ``` ### How did you implement it/them? All of the code is visible above, it can also be accessed in the commit [87e2a43](https://github.com/Jestemkioskiem/steem-sockobot/commit/87e2a436857eaa3b26ea11cc7579c6b790f92f7c). ### Bonus All of the code above has been ported and altered to work with the [sockobot-fb](https://github.com/Jestemkioskiem/steem-sockobot-fb) version of the bot that works in Facebook's Messenger! * ```wallet```  * ```convert```  * ```sp```  <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@jestemkioskiem/sockobot-adding-3-new-commands-and-updating-old-code">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | jestemkioskiem | ||||||
---|---|---|---|---|---|---|---|
permlink | sockobot-adding-3-new-commands-and-updating-old-code | ||||||
category | utopian-io | ||||||
json_metadata | {"community":"utopian","app":"steemit/0.1","format":"markdown","repository":{"id":115289990,"name":"steem-sockobot","full_name":"Jestemkioskiem/steem-sockobot","html_url":"https://github.com/Jestemkioskiem/steem-sockobot","fork":false,"owner":{"login":"Jestemkioskiem"}},"pullRequests":[],"platform":"github","type":"development","tags":["utopian-io","sockobot","python","discord"],"users":["venalbe"],"links":["https://github.com/Jestemkioskiem/steem-sockobot","https://github.com/Jestemkioskiem/","https://steemit.com/utopian-io/@venalbe/sockobot-ideas-for-a-monkey-faced-bot-round-01","https://github.com/Jestemkioskiem/steem-sockobot/commit/87e2a436857eaa3b26ea11cc7579c6b790f92f7c","https://github.com/Jestemkioskiem/steem-sockobot-fb","https://utopian.io/utopian-io/@jestemkioskiem/sockobot-adding-3-new-commands-and-updating-old-code"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1517860639/wxkxg6pnxnqrraqygxhc.jpg","https://res.cloudinary.com/hpiynhbhq/image/upload/v1517861012/tnpiqefstq72nyb2d9gs.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1517861430/drslxcanwheez5gqhink.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1517861577/isxgmxfzaij5el5kyaog.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1517862380/ly0yol7shndp7zdof4ya.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1517862386/nokhuczxdqkhiljhvekd.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1517862383/rk9g443xikwwl3snpxmy.png"],"moderator":{"account":"vladimir-simovic","time":"2018-02-05T22:01:08.553Z","reviewed":true,"pending":false,"flagged":false}} | ||||||
created | 2018-02-05 20:29:06 | ||||||
last_update | 2018-02-05 22:25:39 | ||||||
depth | 0 | ||||||
children | 7 | ||||||
last_payout | 2018-02-12 20:29:06 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 130.820 HBD | ||||||
curator_payout_value | 56.099 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 9,070 | ||||||
author_reputation | 41,292,066,961,817 | ||||||
root_title | "[SockoBot] Adding 3 new commands and updating old code" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 35,227,814 | ||||||
net_rshares | 33,499,449,937,617 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
jamzed | 0 | 14,764,955,878 | 100% | ||
dailydogger | 0 | 14,685,581,241 | 100% | ||
miniature-tiger | 0 | 34,149,216,662 | 50% | ||
mys | 0 | 50,511,719,986 | 100% | ||
jacekw | 0 | 10,013,311,524 | 100% | ||
codingdefined | 0 | 22,331,385,212 | 75% | ||
sandan | 0 | 495,009,146 | 100% | ||
cifer | 0 | 5,501,940,069 | 80% | ||
mcfarhat | 0 | 29,118,629,575 | 25% | ||
bobdos | 0 | 2,474,060,648 | 5% | ||
hakan8686 | 0 | 853,664,391 | 100% | ||
utopian-io | 0 | 33,149,410,088,495 | 23.01% | ||
ihtiht | 0 | 4,691,914,689 | 100% | ||
mytechtrail | 0 | 79,780,152 | 100% | ||
astromaniak | 0 | 4,521,848,288 | 20% | ||
steemitstats | 0 | 2,068,873,112 | 5% | ||
venalbe | 0 | 15,449,053,019 | 100% | ||
arcjen02 | 0 | 3,303,475,547 | 100% | ||
emptyname | 0 | 3,341,355,024 | 100% | ||
piotr-galas | 0 | 3,113,019,831 | 100% | ||
amosbastian | 0 | 16,043,905,481 | 100% | ||
jestemkioskiem | 0 | 8,860,225,461 | 100% | ||
oschlypajac | 0 | 3,360,006,654 | 100% | ||
grzesiekb | 0 | 77,844,501,186 | 100% | ||
j4nke | 0 | 1,670,374,638 | 100% | ||
villaincandle | 0 | 2,786,246,651 | 100% | ||
average-guy | 0 | 847,184,181 | 100% | ||
mciszczon | 0 | 2,383,197,336 | 100% | ||
wrestlingworld | 0 | 575,108,067 | 100% | ||
apocz | 0 | 1,662,520,217 | 100% | ||
szymciojazda | 0 | 2,709,988,478 | 100% | ||
yovanek | 0 | 615,287,443 | 100% | ||
koscian | 0 | 2,407,373,498 | 100% | ||
michaelizer | 0 | 819,385,285 | 75% | ||
steemit-01 | 0 | 613,979,866 | 100% | ||
chelsea.bear | 0 | 2,078,851,323 | 5% | ||
zangerek | 0 | 610,730,407 | 100% | ||
claraquarius | 0 | 1,871,104,482 | 5% | ||
fazlurrahman | 0 | 261,146,655 | 100% | ||
wailay | 0 | 549,937,819 | 100% |
Nice work bro! I've been meaning to install a bot on one of my discord channels and make it available for users .. will look into using your bot then !!
author | mcfarhat |
---|---|
permlink | re-jestemkioskiem-sockobot-adding-3-new-commands-and-updating-old-code-20180206t153013871z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-02-06 15:30:21 |
last_update | 2018-02-06 15:30:21 |
depth | 1 |
children | 1 |
last_payout | 2018-02-13 15:30:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.046 HBD |
curator_payout_value | 0.015 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 152 |
author_reputation | 150,651,671,367,256 |
root_title | "[SockoBot] Adding 3 new commands and updating old code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 35,431,228 |
net_rshares | 9,326,675,848 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
jestemkioskiem | 0 | 9,326,675,848 | 100% |
Hey! The README file is slightly outdated but I'll make sure it's up to date today, thank you for considering my bot <3. If you have any questions or suggestions, you know where to find me.
author | jestemkioskiem |
---|---|
permlink | re-mcfarhat-re-jestemkioskiem-sockobot-adding-3-new-commands-and-updating-old-code-20180207t120007279z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-02-07 13:00:09 |
last_update | 2018-02-07 13:00:09 |
depth | 2 |
children | 0 |
last_payout | 2018-02-14 13:00:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 189 |
author_reputation | 41,292,066,961,817 |
root_title | "[SockoBot] Adding 3 new commands and updating old code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 35,657,776 |
net_rshares | 0 |
@jestemkioskiem, Approve is not my ability, but I can upvote you.
author | steemitstats |
---|---|
permlink | 20180205t203213844z-post |
category | utopian-io |
json_metadata | {"tags":["utopian-io"]} |
created | 2018-02-05 20:32:03 |
last_update | 2018-02-05 20:32:03 |
depth | 1 |
children | 0 |
last_payout | 2018-02-12 20:32:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 65 |
author_reputation | 351,882,871,185 |
root_title | "[SockoBot] Adding 3 new commands and updating old code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 35,228,371 |
net_rshares | 0 |
### Hey @jestemkioskiem I am @utopian-io. I have just upvoted you! #### Achievements - You have less than 500 followers. Just gave you a gift to help you succeed! - Seems like you contribute quite often. AMAZING! #### Community-Driven Witness! I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER! - <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a> - <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a> - Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a> [](https://steemit.com/~witnesses) **Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
author | utopian-io |
---|---|
permlink | re-jestemkioskiem-sockobot-adding-3-new-commands-and-updating-old-code-20180207t232345549z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-02-07 23:23:45 |
last_update | 2018-02-07 23:23:45 |
depth | 1 |
children | 0 |
last_payout | 2018-02-14 23:23:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,090 |
author_reputation | 152,955,367,999,756 |
root_title | "[SockoBot] Adding 3 new commands and updating old code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 35,773,034 |
net_rshares | 0 |
ahah you've been so fast implementing them! glad you liked the suggestion! Looking forward to use Sockobot, ciao!
author | venalbe |
---|---|
permlink | re-jestemkioskiem-sockobot-adding-3-new-commands-and-updating-old-code-20180205t205112800z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-02-05 20:51:12 |
last_update | 2018-02-05 20:51:12 |
depth | 1 |
children | 0 |
last_payout | 2018-02-12 20:51:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.050 HBD |
curator_payout_value | 0.003 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 113 |
author_reputation | 2,357,857,338,750 |
root_title | "[SockoBot] Adding 3 new commands and updating old code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 35,232,066 |
net_rshares | 8,020,835,680 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
jestemkioskiem | 0 | 8,020,835,680 | 100% |
Thank you for the contribution. It has been approved. You can contact us on [Discord](https://discord.gg/uTyJkNm). **[[utopian-moderator]](https://utopian.io/moderators)**
author | vladimir-simovic |
---|---|
permlink | re-jestemkioskiem-sockobot-adding-3-new-commands-and-updating-old-code-20180205t220132366z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"links":["https://discord.gg/uTyJkNm","https://utopian.io/moderators"],"app":"steemit/0.1"} |
created | 2018-02-05 22:01:33 |
last_update | 2018-02-05 22:01:33 |
depth | 1 |
children | 1 |
last_payout | 2018-02-12 22:01:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.334 HBD |
curator_payout_value | 0.444 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 172 |
author_reputation | 56,930,790,558,862 |
root_title | "[SockoBot] Adding 3 new commands and updating old code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 35,245,071 |
net_rshares | 259,145,118,095 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
utopian.tip | 0 | 259,145,118,095 | 22.92% |
Hey @vladimir-simovic, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
author | utopian.tip |
---|---|
permlink | re-re-jestemkioskiem-sockobot-adding-3-new-commands-and-updating-old-code-20180205t220132366z-20180206t133840 |
category | utopian-io |
json_metadata | "" |
created | 2018-02-06 13:38:42 |
last_update | 2018-02-06 13:38:42 |
depth | 2 |
children | 0 |
last_payout | 2018-02-13 13:38:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 166 |
author_reputation | 238,310,597,885 |
root_title | "[SockoBot] Adding 3 new commands and updating old code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 35,407,570 |
net_rshares | 0 |