Last active
June 20, 2017 04:44
-
-
Save gc373/369adff6abe891162915c3a4ff6a4e68 to your computer and use it in GitHub Desktop.
mastodon-police
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
{ | |
"name": "t.co-police", | |
"version": "1.0.0", | |
"description": "", | |
"main": "police.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "gc373", | |
"license": "MIT", | |
"dependencies": { | |
"mastodon-api": "^1.3.0" | |
} | |
} |
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
var Masto = require('mastodon-api') | |
const M = new Masto({ | |
access_token: '***** token *****', | |
timeout_ms: 60 * 1000, | |
api_url: 'https://****** your site *******/api/v1/', | |
}) | |
const MESSAGE = "\r\n動くな、Mastodon警察だ。壁に手をつけ。いまお前が使ったリンクはt.coだな…?" | |
function post(id, reply_id) { | |
console.log({ status: "@" + id + MESSAGE, in_reply_to_id: reply_id }); | |
M.post('statuses', { status: "@" + id + MESSAGE, in_reply_to_id: reply_id }, function (err, a, b) { | |
console.log(JSON.stringify(err, null, "\t")); | |
}) | |
} | |
const streamPub = M.stream('streaming/public') // streaming/public でやったら死ぬかも | |
streamPub.on('message', (msg) => { | |
if (msg.event == 'update' && msg.data.content.match(/.https:\/\/t\.co./)) { | |
post(msg.data.account.acct, msg.data.id); | |
} | |
}) | |
streamPub.on('error', (err) => { | |
console.log(err) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mastodon-apiを1.3にしたから空白入らないかも?:innocent: