Skip to content

Instantly share code, notes, and snippets.

@kypkyp
Created December 25, 2016 08:08
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/4150de77e50337c616a08510dbeb5f38 to your computer and use it in GitHub Desktop.
Save kypkyp/4150de77e50337c616a08510dbeb5f38 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('@') === -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