Last active
December 26, 2015 08:19
-
-
Save ikr7/7121407 to your computer and use it in GitHub Desktop.
https://github.com/ikr7/Twitter-Commands ではるアイコン鯖のログイン数おしえてくれるやつ
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
//@sn はるアイコン鯖 | |
module.exports = function(twi, data, cfg){ | |
var http = require('http'); | |
var options = { | |
'host': 'api.haruicon.com', | |
'path': '/?g=twiIdInList', | |
'method': 'GET', | |
}; | |
var text = '@' + data.user.screen_name + ' '; | |
var req = http.request(options, function(res){ | |
var resBody = ''; | |
res.setEncoding('utf8'); | |
res.on('data', function(chunk){ | |
resBody += chunk; | |
}); | |
res.on('end', function(){ | |
resBody = JSON.parse(resBody); | |
var users = []; | |
if(resBody.playerCount == 0){ | |
text += '(◞‸◟)<はるアイコン鯖に誰もいないよ'; | |
}else{ | |
for(user in resBody.idList){ | |
users.push(resBody.idList[user].twitterId + 'さん'); | |
} | |
text += '(╹◡╹)<' + users.join('と') + 'がログインしています'; | |
} | |
twi.post('/statuses/update.json', { | |
'status': text, | |
'in_reply_to_status_id': data.id | |
}, function(err, res){ | |
if(!err){ | |
console.log(res); | |
}else{ | |
console.error(err); | |
} | |
}); | |
}); | |
}).on('error', function(err){ | |
console.error(err); | |
}); | |
req.end(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment