Created
July 10, 2012 20:17
-
-
Save mattbasta/3085950 to your computer and use it in GitHub Desktop.
Hugbot
This file contains hidden or 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
var irc = require('irc'); | |
var client = new irc.Client('irc.mozilla.org', 'hugbot', { | |
channels: ['#amo', '#webdev', '#interns'], | |
}); | |
huggable = {}; | |
hugdelay = {}; | |
function contains(message, list) { | |
for(var i=0;i<list.length;i++) { | |
var l = list[i]; | |
if(message.indexOf(l) > -1) | |
return true; | |
} | |
} | |
client.addListener('message', function(from, to, message) { | |
if(hugdelay[from]) | |
return; | |
hugdelay[from] = true; | |
setTimeout(function() {delete hugdelay[from];}, 1000 * 60 * 60); | |
if(contains(message, [":(", ":-(", ":'(", ":'-(", "QQ", ":C", "T_T"])) { | |
console.log(from + ": " + message); | |
if(from == "cvan") | |
client.say(to, "man up, cvan"); | |
else | |
client.say(to, "(" +from + ")"); | |
} else if (contains(message.toLowerCase(), | |
["hate this", "sad", "i need a hug", | |
"i'm sad", "fml", "this is crap", | |
"i need a drink"])) { | |
if(from == "cvan") | |
return; | |
huggable[from] = true; | |
console.log(from + ": " + "Needs a hug >> " + message); | |
client.say(to, from + ": need a hug, bro?"); | |
} else if (message.substr(0, 7) == "hugbot:") { | |
tlm = message.toLowerCase(); | |
if(tlm.indexOf("botsnack") > -1) { | |
// Botsnack! | |
client.say(to, from + ": *BURP*"); | |
} else if(contains(tlm, ["yes", "yup", "yeah", "yep"]) && | |
from in huggable) { // Offer hugs! | |
delete huggable[from]; | |
client.say(to, from + ": >--:)--<"); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is a very old version of hugbot. The current hugbot has many different features.