 #### What Will I Learn? This Tutorial Series is all about creating a basic steem bid-based upvoting bot. We are basically coming to an end with this and the next tutorial for the series of how to create an upvote bot. In this part I want to cover how your upvote bot can create comments under the post it has upvoted, since some bots use this behaviour to seek attention. An Example:  #### Requirements - Please read my previous part([Click here](https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-6)) #### Difficulty - Basic #### Tutorial Contents ### Posting Comments Posting comments in steemit work exactly the same as creating posts since both is seen as comments. The difference between a comment and a post is, a post does not have a parent comment / author - a comment does. Creating a post can be done with one single function: ``` javascript function sendComment(vote) { const permlink = 're-' + vote.author.replace(/\./g, '') + '-' + vote.permlink + '-' + new Date().toISOString().replace(/-|:|\./g, '').toLowerCase(); const comments = config.comments; // Broadcast the comment steem.broadcast.comment(config.private_posting_key, vote.author, vote.permlink, account.name, permlink, permlink, comment, '{"app":"upvoter/"}', function (err, result) { if (!err && result) { console.log('Posted comment: ' + permlink); } else { console.log('Error posting comment: ' + permlink + ', Error: ' + err); } }); } ``` - **Permlink:** The permlink is needed and we will generate the permlink via steemits standard convention. Simply copy it and leave it like this. - **Comments:** We will come to this part later. Basically we will create an array of possible comments our bot can post in our config and randomly select one. - `steem.broadcast.comment(wif, parentAuthor, parentPermlink, author, permlink, title, body, jsonMetadata, function(err, result) {...}` is used to broadcast a comment to the blockchain. Since a comment does not have a title we use the permlink too. `wif` equals our `private_posting_key` and `jsonMetadata` is just some metadata, change the value for app to everything you like. Now after we created the function we need to call it. The best place is after we successfully voted ``` javascript steem.broadcast.vote(config.private_posting_key, account.name, vote.author, vote.permlink, 10000, function (err, result) { if (err && !result) { console.log('Voting failed: ' + err); return; } sendComment(vote); if (callback) { callback(); } }); ``` ### Random comments A bot which always comment the same sentence under the posts it upvoted would be way to boring and way to lame. An awesome bot is able to post different comments ! Head over to your config.json and add some possible comments your bot should post, e.g: ``` javascript "comments": [ "Hi! I've just found you and this is crazy, but here's my vote so follow me maybe?", "You got an upvote from UpVote making your revenue going UUUUUPPPPP", "Voted for you my fellow steemian! Thanks for paying", ] ``` Now go back to the line `const comments = config.comments;` inside of your index.js and add following code below ``` javascript const comment = comments[Math.floor(Math.random() * comments.length)]; ``` This small line does: - Choses a random number between 0-1 (Math.random()) - Multiply it with the amount of comments our bot uses - Round down the solution to have Integer values - Select the comment with index = solution from the comments list #### Try it  ### [Full Source Code](https://gist.github.com/caspernikus/a33fd21e78a6acfceeb462428ccf1745) #### Curriculum - [Part 1 - The Setup](https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-1) - [Part 2 - The next Step](https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-2) - [Part 3 - Refund](https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-3) - [Part 4 - Post Age](https://utopian.io/utopian-io/@moonrise/tutorial-basic-build-your-own-steem-upvote-bot-javascript-part-4) - [Part 5 - More refunding](https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-5) - [Part 6 - Save data locally](https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-6) <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-7">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | moonrise | ||||||
---|---|---|---|---|---|---|---|
permlink | tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-7 | ||||||
category | utopian-io | ||||||
json_metadata | {"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":63857882,"name":"steem-js","full_name":"steemit/steem-js","html_url":"https://github.com/steemit/steem-js","fork":false,"owner":{"login":"steemit"}},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","steemit","steemjs","development","tutorial"],"users":["moonrise"],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1518181210/v2orbly0kqveiukxrps0.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1518181363/y61sxzvg5ctrvcvpx5le.png","https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-6","https://res.cloudinary.com/hpiynhbhq/image/upload/v1518185058/fkj0dsxlvebc16ms1sxw.png","https://gist.github.com/caspernikus/a33fd21e78a6acfceeb462428ccf1745","https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-1","https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-2","https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-3","https://utopian.io/utopian-io/@moonrise/tutorial-basic-build-your-own-steem-upvote-bot-javascript-part-4","https://utopian.io/utopian-io/@moonrise/tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-5"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1518181210/v2orbly0kqveiukxrps0.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1518181363/y61sxzvg5ctrvcvpx5le.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1518185058/fkj0dsxlvebc16ms1sxw.png"],"moderator":{"account":"jestemkioskiem","time":"2018-02-09T14:15:58.444Z","reviewed":true,"pending":false,"flagged":false}} | ||||||
created | 2018-02-09 14:10:57 | ||||||
last_update | 2018-02-09 14:15:57 | ||||||
depth | 0 | ||||||
children | 3 | ||||||
last_payout | 2018-02-16 14:10:57 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 59.500 HBD | ||||||
curator_payout_value | 25.796 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 5,180 | ||||||
author_reputation | 10,047,335,281,671 | ||||||
root_title | "TUTORIAL - Beginner - Build your own Steem Upvote Bot - JavaScript - Part 7" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 36,178,382 | ||||||
net_rshares | 14,634,399,234,882 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
adol | 0 | 511,321,077,380 | 50% | ||
mr-anderson | 0 | 526,340,139 | 100% | ||
mckeever | 0 | 142,625,706 | 10% | ||
thatmemeguy | 0 | 6,677,628,494 | 50% | ||
dyancuex | 0 | 1,092,193,766 | 50% | ||
jdc | 0 | 567,079,312 | 20% | ||
bargolis | 0 | 586,274,054 | 5% | ||
flurgx | 0 | 19,219,366,955 | 15% | ||
flauwy | 0 | 258,122,048,497 | 50% | ||
jmromero | 0 | 4,343,145,744 | 50% | ||
mahdiyari | 0 | 11,872,401,962 | 20% | ||
ronimm | 0 | 10,226,663,689 | 100% | ||
mufasatoldyou | 0 | 7,277,229,299 | 100% | ||
tensor | 0 | 5,347,427,195 | 50% | ||
makrotheblack | 0 | 2,817,775,903 | 50% | ||
simonluisi | 0 | 1,772,785,833 | 100% | ||
thinkkniht | 0 | 500,079,142 | 75% | ||
onos | 0 | 7,952,814,135 | 100% | ||
sandan | 0 | 199,406,144 | 100% | ||
cifer | 0 | 6,532,164,492 | 80% | ||
tradeownsystems | 0 | 436,297,180 | 100% | ||
jesdn16 | 0 | 3,389,475,623 | 100% | ||
garudi | 0 | 1,760,837,681 | 24% | ||
stoodkev | 0 | 13,770,158,625 | 10% | ||
ansonoxy | 0 | 2,362,659,623 | 100% | ||
jamesbarraclough | 0 | 13,459,356,696 | 100% | ||
espoem | 0 | 25,096,963,956 | 50% | ||
yabapmatt | 0 | 277,402,669,157 | 100% | ||
missaelcastillo | 0 | 23,957,532,105 | 100% | ||
idlebright | 0 | 3,130,374,115 | 50% | ||
coolguy123 | 0 | 18,546,357,722 | 7% | ||
odebgaming | 0 | 439,187,313 | 100% | ||
fknmayhem | 0 | 1,955,558,825 | 15% | ||
utopian-io | 0 | 13,264,425,808,458 | 8.76% | ||
mdtipo | 0 | 430,146,440 | 100% | ||
kslo | 0 | 2,095,402,319 | 50% | ||
nathalie13 | 0 | 1,133,321,421 | 100% | ||
not-a-bird | 0 | 865,013,835 | 15% | ||
adhew | 0 | 61,532,000 | 10% | ||
bitopia | 0 | 2,251,268,886 | 100% | ||
berkaytekinsen | 0 | 1,419,082,027 | 100% | ||
cyber.explorer | 0 | 749,799,078 | 100% | ||
tstinfo | 0 | 2,842,180,311 | 50% | ||
evilest-fiend | 0 | 1,822,528,384 | 100% | ||
steemitstats | 0 | 2,051,504,914 | 5% | ||
syedubair | 0 | 6,319,861,096 | 50% | ||
navx | 0 | 1,958,287,074 | 70% | ||
family.app | 0 | 130,952,110 | 100% | ||
cgbartow | 0 | 368,975,753 | 50% | ||
varja | 0 | 306,768,699 | 50% | ||
maphics | 0 | 102,052,182 | 100% | ||
dethclad | 0 | 1,587,375,061 | 50% | ||
sebastiengllmt | 0 | 306,775,823 | 50% | ||
utopian-1up | 0 | 14,050,046,666 | 100% | ||
luoq | 0 | 9,553,767,597 | 100% | ||
zlatkamrs | 0 | 181,030,513 | 30% | ||
amosbastian | 0 | 8,186,430,496 | 50% | ||
tdre | 0 | 606,811,260 | 100% | ||
bobsthinking | 0 | 2,428,732,631 | 100% | ||
proffgodswill | 0 | 61,609,892 | 10% | ||
sweeverdev | 0 | 1,052,002,634 | 50% | ||
steem4all | 0 | 54,987,430 | 50% | ||
jerybanfield | 0 | 90,143,089 | 50% | ||
abelcachay | 0 | 1,133,211,685 | 100% | ||
utube | 0 | 73,445,662 | 50% | ||
marianarojas | 0 | 1,133,499,423 | 100% | ||
curx | 0 | 8,862,646,751 | 50% | ||
rhotimee | 0 | 1,139,922,222 | 50% | ||
blogger-funda | 0 | 435,278,325 | 100% | ||
jrmiller87 | 0 | 2,318,854,788 | 100% | ||
deejee | 0 | 122,754,283 | 20% | ||
rsteem | 0 | 121,155,381 | 50% | ||
moonrise | 0 | 5,437,459,269 | 100% | ||
e-babil | 0 | 501,654,004 | 35% | ||
neneandy | 0 | 2,997,955,377 | 50% | ||
mikeb570 | 0 | 9,228,961,997 | 75% | ||
sportscontest | 0 | 67,364,210 | 50% | ||
annepage | 0 | 599,524,430 | 100% | ||
urbangladiator | 0 | 436,295,000 | 100% | ||
penghuren | 0 | 8,231,649,540 | 50% | ||
fantasycrypto | 0 | 185,048,231 | 50% | ||
yeswanth | 0 | 617,202,083 | 100% | ||
exploreand | 0 | 10,022,269,309 | 50% | ||
steemassistant | 0 | 444,592,709 | 100% | ||
nenya | 0 | 113,875,227 | 25% | ||
punwik | 0 | 251,806,455 | 50% | ||
photohunter1 | 0 | 89,938,773 | 100% | ||
photohunter2 | 0 | 101,941,638 | 100% | ||
photohunter3 | 0 | 99,522,367 | 100% | ||
photohunter4 | 0 | 84,863,723 | 100% | ||
photohunter5 | 0 | 82,365,206 | 100% | ||
howtosteem | 0 | 3,191,983,600 | 100% | ||
saahir | 0 | 726,571,238 | 50% | ||
roj | 0 | 1,030,791,356 | 100% | ||
kid1412 | 0 | 240,039,663 | 50% | ||
jeanettaqueen | 0 | 230,673,828 | 50% | ||
ziqifuady | 0 | 386,826,451 | 100% | ||
nightdragon | 0 | 210,032,406 | 50% | ||
nafestw | 0 | 570,649,117 | 100% | ||
jacintoelbarouki | 0 | 218,226,383 | 50% | ||
opulence | 0 | 1,788,521,195 | 50% | ||
phbr | 0 | 73,774,067 | 10% | ||
genoner | 0 | 273,654,259 | 50% | ||
dexter24 | 0 | 224,278,710 | 50% |
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 | jestemkioskiem |
---|---|
permlink | re-moonrise-tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-7-20180209t141610502z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-02-09 14:16:12 |
last_update | 2018-02-09 14:16:12 |
depth | 1 |
children | 0 |
last_payout | 2018-02-16 14:16:12 |
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 | 172 |
author_reputation | 41,292,066,961,817 |
root_title | "TUTORIAL - Beginner - Build your own Steem Upvote Bot - JavaScript - Part 7" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 36,179,489 |
net_rshares | 0 |
@moonrise, I like your contribution to open source project, so I upvote to support you.
author | steemitstats |
---|---|
permlink | 20180209t141512860z-post |
category | utopian-io |
json_metadata | {"tags":["utopian-io"]} |
created | 2018-02-09 14:15:15 |
last_update | 2018-02-09 14:15:15 |
depth | 1 |
children | 0 |
last_payout | 2018-02-16 14:15:15 |
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 | 87 |
author_reputation | 351,882,871,185 |
root_title | "TUTORIAL - Beginner - Build your own Steem Upvote Bot - JavaScript - Part 7" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 36,179,289 |
net_rshares | 0 |
### Hey @moonrise I am @utopian-io. I have just upvoted you! #### Achievements - WOW WOW WOW People loved what you did here. GREAT JOB! - 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-moonrise-tutorial-beginner-build-your-own-steem-upvote-bot-javascript-part-7-20180211t082933484z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-02-11 08:29:33 |
last_update | 2018-02-11 08:29:33 |
depth | 1 |
children | 0 |
last_payout | 2018-02-18 08:29:33 |
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,141 |
author_reputation | 152,955,367,999,756 |
root_title | "TUTORIAL - Beginner - Build your own Steem Upvote Bot - JavaScript - Part 7" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 36,617,189 |
net_rshares | 0 |