All pastes #232640 Raw Edit

bothook.js

public javascript v1 · immutable
·published 2006-11-01 13:08 UTC
rendered paste body
const __id = "bothook plugin";const __maj_version = 0const __min_version = 1const __description = "Makes a bothook";var timearray = new Object();function initPlugin(glob) {    /* This function will be called when chatzilla first loads the plugin.     * We initialize some of the plugin object's properties, define a new     * command and some new prefs, and print out a message.     */         plugin.id = __id;    plugin.major = __maj_version;    plugin.minor = __min_version;        plugin.version = __maj_version + "." + __min_version    plugin.description = __description;    /* a global pref will be created for each item in the pref array.     * By adding these motif.* preferences, we're creating shortcuts     * that can be used with the /motif command.     */    var base = "http://www.hacksrus.com/~ginda/chatzilla/motifs/";       display(__id + " loaded from url " + plugin.url);}client.eventPump.addHook([{set:"channel", type:"privmsg"}], sayback, "sayback");function sayback(e) {	try {		var message = e.decodeParam(2);		var nick = e.user.unicodeName;				if (message == "!biertje") {			display("nick: " + nick);						var messagetime = Date.now();			display("date.now    : " + Date.now().toString());			display("messagetime: " + messagetime.toString());									//display(messagetime);			if ( timearray[nick] < messagetime || timearray[nick] == undefined ) {								setTimeout(					function(){							saytext("me geeft " + nick + " een lekker koud biertje. En neemt er zelf natuurlijk ook een :P.", e.channel)						}					, 0);				}							timearray[nick] = Date.now()+6000;			display("dumpobject timearray: " + dumpObject(timearray));			display("timearray[nick]: " + timearray[nick].toString());		}			}	catch (ex) {		client.displayHere("Error in message hook: " + ex, "ERROR");	}}function disablePlugin(status) {	display("disabling plugin...");	client.eventPump.removeHookByName("sayback");	return true;}function enablePlugin(status) {    display("enabling plugin...");    }function saytext(text, channel) {	channel.dispatch(text);}