Skip to content

Instantly share code, notes, and snippets.

@ikr7
Last active December 26, 2015 08:19
Show Gist options
  • Save ikr7/7121407 to your computer and use it in GitHub Desktop.
Save ikr7/7121407 to your computer and use it in GitHub Desktop.
https://github.com/ikr7/Twitter-Commands ではるアイコン鯖のログイン数おしえてくれるやつ
//@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