Skip to content

Instantly share code, notes, and snippets.

@mattbasta
Created July 10, 2012 20:17
Show Gist options
  • Save mattbasta/3085950 to your computer and use it in GitHub Desktop.
Save mattbasta/3085950 to your computer and use it in GitHub Desktop.
Hugbot
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 + ": >--:)--<");
}
}
});
@benbrittain
Copy link

Does not approve of the time limit on hugs. Some interns are really sad.

@mattbasta
Copy link
Author

this is a very old version of hugbot. The current hugbot has many different features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment