Skip to content

Instantly share code, notes, and snippets.

@kypkyp
Last active December 25, 2016 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kypkyp/70f612793d20d3fd843712373afdfff0 to your computer and use it in GitHub Desktop.
Save kypkyp/70f612793d20d3fd843712373afdfff0 to your computer and use it in GitHub Desktop.
controller.hears(['sudo tweet '], 'direct_mention,mention,ambient', function(bot, message) {
if(message.channel === "C2Z3UJWAW"){
var output = message.text.slice(10,message.text.length);
var name;
if(output.indexOf('@') === -1 && output.indexOf('[by') === -1 && output.indexOf('twitter.com') === -1 && output.indexOf('t.co') === -1){
/* 生のIDから名前を特定する */
// DEBUG
if(/*Math.random() < 0.25*/true){
bot.api.users.info({user: message.user}, function(error,response){
name = response.user.name;
output = output + " [by " + name + "]";
});
}
twitterClient.post('statuses/update', {status: "[from #kyp_memo]" + output}, function(error, tweet, response) {
if(!error){
bot.say({
channel:"C2Z3UJWAW",
text:"https://twitter.com/_kypu/status/" + tweet.id_str,
username:"この事象は記録・報告されます。"
});
}else{
bot.say({
channel:"C2Z3UJWAW",
text:"ERROR"
});
}
});
}
}else{
bot.say({
channel:"C2Z3UJWAW",
text:"DO NOT SEND REPLY",
username:"BOT"
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment