Last active
December 25, 2016 07:15
-
-
Save kypkyp/70f612793d20d3fd843712373afdfff0 to your computer and use it in GitHub Desktop.
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
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