Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
いまの
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('') === -1 && output.indexOf('[by') === -1 && output.indexOf('twitter.com') === -1 && output.indexOf('t.co') === -1){
// DEBUG
if(Math.random() < 0.25){
bot.api.users.info({user: message.user}, function(error,response){
name = response.user.name;
output = output + " [by " + name + "]";
console.log("not_anonymous");
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{
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"
});
}
});
}
console.log(output);
console.log(name);
}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