Skip to content

Instantly share code, notes, and snippets.

@code-with-sam
Created January 8, 2018 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save code-with-sam/0864e91b85377a2f5b497007a2fcd5dd to your computer and use it in GitHub Desktop.
Save code-with-sam/0864e91b85377a2f5b497007a2fcd5dd to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>
<script>
console.log('hello, is this working')
// Tutorial
const ACCOUNT_NAME = ''
const ACCOUNT_WIF = ''
const FRIEND_LIST = ['sam', 'fred', 'sarah', 'lucy']
steem.api.setOptions({ url: 'wss://rpc.buildteam.io' });
steem.api.streamTransactions('head', (err, result) => {
console.log(result)
let txType = result.operations[0][0]
let txData = result.operations[0][1]
if(txType == 'comment') {
checkAuthor(txData)
}
});
function checkAuthor(txData){
if (txData.parent_author == '' && isFriend(txData.author)){
sendVote(txData.author, txData.permlink)
}
}
function isFriend(name){
return (FRIEND_LIST.indexOf(name) > -1);
}
function sendVote(author, permlink){
steem.broadcast.vote(ACCOUNT_WIF, ACCOUNT_NAME, author, permlink, 10000, function(err, result) {
console.log(result);
});
}
</script>
</head>
<body></body>
</html>
@nkgokul
Copy link

nkgokul commented Jan 20, 2018

For this particular version of js file can you post the code for post comments?

var parentAuthor = 'author1';
var parentPermlink = 'permlink;
var commentPermlink = steem.formatter.commentPermlink(parentAuthor, parentPermlink);
var postTitle = WELCOME_COMMENT_TITLE;
var postBody = WELCOME_COMMENT_BODY;

steem.broadcast.comment(ACCOUNT_WIF, parentAuthor, parentPermlink, ACCOUNT_NAME,
commentPermlink, postTitle, postBody,
{"tags":["tag1"]},
function(err, result) {
console.log(result);
});

The above code doesn't seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment