Created
December 25, 2016 08:08
-
-
Save kypkyp/4150de77e50337c616a08510dbeb5f38 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('@') === -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