Created
January 27, 2018 23:24
-
-
Save eliyastein/434cd9334f6aa75cfe789f5c562647d1 to your computer and use it in GitHub Desktop.
Advanced Steem Monitoring
This file contains 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
let steem = require('steem'); | |
var Slack = require('slack-node'); | |
steem.api.setOptions({ url: 'https://api.steemit.com' }); | |
webhook = '[WebHook URL]'; | |
let criteria = []; | |
criteria.push({ author: 'sha256md5' }); | |
criteria.push({ author: 'imaginary_username_2' }); | |
criteria.push({ author: 'imaginary_username_3' }); | |
let slack = new Slack(); | |
slack.setWebhook(webhook); | |
function slackpost(post){ | |
slack.webhook({ | |
channel: "#test", | |
username: "test", | |
text: post | |
}, (err, response) => { | |
console.log(response); | |
}); | |
} | |
steem.api.streamOperations((err, result) => { | |
console.log(result[1]); | |
let valid = false; | |
let resultBody = result[1]; | |
criteria.map((c)=>{ | |
let rules = Object.keys(c); | |
rules.map((r)=>{ | |
resultBody[r] == c[r] ? valid = true : valid = false; | |
}); | |
if (valid){ | |
let post = result[1].author + " made a post on Steemit!"; | |
slackpost(post); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment