Created
February 6, 2018 16:46
-
-
Save kirkins/80ea266d82340ab245d373fd072ad362 to your computer and use it in GitHub Desktop.
A small script that displays comments live in terminal for a steem post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Script that displays comments from a steem post in terminal. | |
// Use by passing username and permlink via terminal command. | |
// Example: comments.js kirkins frog-aquarium--2018-02-06-01-56-07 | |
// by: Philip Kirkbride (@kirkins) | |
const steem = require('steem'); | |
const logUpdate = require('log-update'); | |
const frames = ['-', '\\', '|', '/']; | |
let i = 0; | |
let args = process.argv.slice(2); | |
setInterval(() => { | |
const frame = frames[i = ++i % frames.length]; | |
steem.api.getContentReplies(args[0], args[1], function(err, result) { | |
let textToRender = "\n\n"; | |
result.forEach(function(comment) { | |
textToRender += comment.author; | |
textToRender += ": "; | |
textToRender += comment.body; | |
textToRender += "\n"; | |
}); | |
logUpdate( | |
`${frame} Comments ${frame} ` | |
+ textToRender | |
+ "\n" | |
); | |
}); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment