Skip to content

Instantly share code, notes, and snippets.

@kirkins
Created February 6, 2018 16:46
Show Gist options
  • Save kirkins/80ea266d82340ab245d373fd072ad362 to your computer and use it in GitHub Desktop.
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
// 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