Skip to content

Instantly share code, notes, and snippets.

@devyn
Created March 16, 2012 08:46
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 devyn/2049194 to your computer and use it in GitHub Desktop.
Save devyn/2049194 to your computer and use it in GitHub Desktop.
An example of a pink petal
module.exports = function (hub, name) {
// We register ourself as darkf_dix and are returned a handle that
// allows us to subscribe to or unsubscribe from events.
hub.register (name || "darkf_dix", function (handle) {
// The first argument specifies what item to subscribe to events from.
// If null or undefined, the default is "*". The second argument
// specifies what kind of events to accept. If left null or undefined,
// it defaults to the special event kind "*", which matches any kind of
// event.
handle.subscribe ("irc/*", "message", function (e) {
if (e.data.from.match (/^darkf/)) {
if (e.data.body.match (/\bdicks\b/i)) {
// Don't propagate the message if it contains the whole word 'dicks'.
} else {
e.data.body = "dicks dicks dicks dicks dicks";
e.next ();
}
} else {
e.next ();
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment