 >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 FB [github repository](https://github.com/Jestemkioskiem/steem-sockobot-fb) [author](https://github.com/Jestemkioskiem/) # Languages * Python 3.6 * SQL ## New Features #### What feature(s) did you add? In this important update, the whole reason for porting SockoBot to a more personal environment - Facebook's messenger - is about to show. A database (which for the purpose of this bot is **SQLite**, but can easily be expanded to any other) was introduced, which allows a lot of future functionality. For now, thanks to it 4 new functionalities were provided: * The ```register``` command was added, which allows the user to tie his messengerID (which has no connection to their facebook account - so their personal information doesn't get stored anywhere) to any steem account by just providing its username. * The ```unregister``` command was added, which allows the user to remove his messengerID from the database, as well as register under a new nickname. * The ```vote``` command now automatically pulls the username from the database if the user doesn't provide any other username as an argument. * The ```payout``` command now automatically pulls the username from the database if the user doesn't provide any other username as an argument. On top of that, some other small changes were made: * The bot will now correctly reply with ```"Too few arguments provided"``` if a command requires an argument, but didn't receive one. * The ```calculate_estimated_upvote``` will now correctly calculate the upvote if the user delegates some of his SP. * The ```command``` function now takes ```user_id``` as an argument, which is supposed to be used with the messengerID. ## How did you implement it/them? A total of 4 functions were added, and their returns were used in the ```command``` function. They are all a mix of **Python 3** and **SQL**. ```python def data_entry(username, user_id): c.execute('CREATE TABLE IF NOT EXISTS users(unix REAL, datestamp TEXT, username TEXT, user_id INTEGER)') unix = time.time() datestamp = str(datetime.datetime.fromtimestamp(unix).strftime('%Y-%m-%d %H:%M:%S')) c.execute("INSERT INTO users (unix, datestamp, username, user_id) VALUES (?, ?, ?, ?)", (unix, datestamp, username, user_id)) conn.commit() ``` The ```data_entry``` function pairs the messengerID and the provided username in the database, giving it an UNIX and a datestamp as well. ```python def data_check(user_id): c.execute("SELECT user_id FROM users WHERE user_id=?", (user_id,)) data = c.fetchall() if not data: return False else: return True ``` The ```data_check``` function checks if the ```user_id``` is already stored in the database and returns ```True``` or ```False``` ```python def data_removal(user_id): c.execute("DELETE FROM users WHERE user_id = ?", (user_id,)) conn.commit() ``` The ```data_removal``` function removes the messengerID and the whole row tied to it from the database. ```python def data_name_check(user_id): row = c.execute("SELECT username FROM users where user_id = ?", (user_id,)).fetchone() username = row[0] return username ``` The ```data_name_check``` function returns the username that the user is registered under. ### Finale On top of that, the ```command``` function has changed a lot to welcome these changes. All the changes can be found in these commits: [61d0ac5](https://github.com/Jestemkioskiem/steem-sockobot-fb/commit/61d0ac5a785e1d4a9d1b01284506c94b8d869c71) , [8518453](https://github.com/Jestemkioskiem/steem-sockobot-fb/commit/85184535f91b52b909bbdf66092b8a67f93e3832), [ec2f039](https://github.com/Jestemkioskiem/steem-sockobot-fb/commit/ec2f039442049759a2663eeab914c990f71e0b3d); The code was properly commented in the last commit and prepared for future improvements. <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@jestemkioskiem/sockobot-adding-database-functionality-to-the-messenger-bot">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | jestemkioskiem | ||||||
---|---|---|---|---|---|---|---|
permlink | sockobot-adding-database-functionality-to-the-messenger-bot | ||||||
category | utopian-io | ||||||
json_metadata | {"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":118528363,"name":"steem-sockobot-fb","full_name":"Jestemkioskiem/steem-sockobot-fb","html_url":"https://github.com/Jestemkioskiem/steem-sockobot-fb","fork":false,"owner":{"login":"Jestemkioskiem"}},"pullRequests":[],"platform":"github","type":"development","tags":["utopian-io","sockobot","python"],"users":["jestemkioskiem"],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1516714139/dylwfwpmazxjxkgzvqzq.jpg","https://github.com/Jestemkioskiem/steem-sockobot-fb","https://github.com/Jestemkioskiem/","https://github.com/Jestemkioskiem/steem-sockobot-fb/commit/61d0ac5a785e1d4a9d1b01284506c94b8d869c71","https://github.com/Jestemkioskiem/steem-sockobot-fb/commit/85184535f91b52b909bbdf66092b8a67f93e3832","https://github.com/Jestemkioskiem/steem-sockobot-fb/commit/ec2f039442049759a2663eeab914c990f71e0b3d"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1516714139/dylwfwpmazxjxkgzvqzq.jpg"],"moderator":{"account":"justyy","time":"2018-01-26T20:15:30.684Z","reviewed":true,"pending":false,"flagged":false}} | ||||||
created | 2018-01-26 15:52:21 | ||||||
last_update | 2018-01-26 20:15:30 | ||||||
depth | 0 | ||||||
children | 3 | ||||||
last_payout | 2018-02-02 15:52:21 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 51.570 HBD | ||||||
curator_payout_value | 22.047 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 4,284 | ||||||
author_reputation | 41,292,066,961,817 | ||||||
root_title | "[SockoBot] Adding Database Functionality to the messenger bot." | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 32,505,293 | ||||||
net_rshares | 10,131,478,233,127 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ubg | 0 | 203,095,594 | 1% | ||
dailydogger | 0 | 10,712,331,989 | 100% | ||
miniature-tiger | 0 | 59,775,871,507 | 100% | ||
mys | 0 | 45,461,842,964 | 100% | ||
safrizal91 | 0 | 0 | 1% | ||
jacekw | 0 | 10,381,953,336 | 100% | ||
codingdefined | 0 | 13,870,166,199 | 50% | ||
cifer | 0 | 2,772,372,319 | 90% | ||
olo2552 | 0 | 935,554,805 | 100% | ||
utopian-io | 0 | 9,943,140,891,711 | 7.29% | ||
avenal | 0 | 4,777,503,230 | 100% | ||
mytechtrail | 0 | 98,805,189 | 100% | ||
smarthamster72 | 0 | 227,366,228 | 1% | ||
arcjen02 | 0 | 2,128,864,387 | 100% | ||
amosbastian | 0 | 14,389,052,929 | 100% | ||
jestemkioskiem | 0 | 8,521,828,127 | 100% | ||
oschlypajac | 0 | 3,451,377,422 | 100% | ||
j4nke | 0 | 1,736,331,421 | 100% | ||
average-guy | 0 | 827,864,072 | 100% | ||
mciszczon | 0 | 2,849,220,164 | 100% | ||
jrmiller87 | 0 | 2,423,661,784 | 100% | ||
yovanek | 0 | 617,934,961 | 100% | ||
dominico2000 | 0 | 614,120,491 | 100% | ||
zuhrasalisah | 0 | 602,183,685 | 100% | ||
bjoernb | 0 | 595,504,405 | 100% | ||
tiotioahmad | 0 | 362,534,208 | 100% |
Thank you for the contribution. It has been approved. Is it safe/ok to expose the PAGE_ACCESS_TOKEN [here](https://github.com/Jestemkioskiem/steem-sockobot-fb/commit/85184535f91b52b909bbdf66092b8a67f93e3832)? You can contact us on [Discord](https://discord.gg/uTyJkNm). **[[utopian-moderator]](https://utopian.io/moderators)**
author | justyy |
---|---|
permlink | re-jestemkioskiem-sockobot-adding-database-functionality-to-the-messenger-bot-20180126t201602390z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-26 20:16:06 |
last_update | 2018-01-26 20:16:06 |
depth | 1 |
children | 1 |
last_payout | 2018-02-02 20:16:06 |
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 | 330 |
author_reputation | 280,616,224,641,976 |
root_title | "[SockoBot] Adding Database Functionality to the messenger bot." |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 32,556,919 |
net_rshares | 0 |
It is safe as it can only be used if the bot is registered to a webhook using developers.facebook.com, which is tied to my personal Facebook account. That being said, just to be sure, I'll be changing the page once the development process is over. Thank you for your concern!
author | jestemkioskiem |
---|---|
permlink | re-justyy-re-jestemkioskiem-sockobot-adding-database-functionality-to-the-messenger-bot-20180126t204317739z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-26 20:43:18 |
last_update | 2018-01-26 20:49:39 |
depth | 2 |
children | 0 |
last_payout | 2018-02-02 20:43:18 |
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 | 275 |
author_reputation | 41,292,066,961,817 |
root_title | "[SockoBot] Adding Database Functionality to the messenger bot." |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 32,562,254 |
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-database-functionality-to-the-messenger-bot-20180127t160539646z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-27 16:05:39 |
last_update | 2018-01-27 16:05:39 |
depth | 1 |
children | 0 |
last_payout | 2018-02-03 16:05:39 |
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 Database Functionality to the messenger bot." |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 32,773,471 |
net_rshares | 0 |