Jump to content


Photo

Tiny JavaScript for Chatzilla


  • Please log in to reply
No replies to this topic

#1 Neo-SiN

Neo-SiN

    Master

  • Atomican
  • 935 posts

Posted 21 September 2008 - 06:43 PM

Hi, I'm just trying to write a notification script for Chatzilla, that will play a sound when someone enters a certain phrase.

Basicall, I want Chatzilla to play a .wav sound file if someone enters the phrase:

"Hello" *wildcard* "Bob"

So the sound would play if someone says: "Hello my name is bob", but wouldn't play on "Hi, I'm bob" or "Hello, I'm Mike".

The only problem is that I've never worked with JavaScript. I found some code that does basically what I want, I just need to modify it a little. It appears to be notifying based on events rather than on matching text, so I'm not really sure.

plugin.id = "message-notify";

plugin.init =
function _init(glob) {
	plugin.major = 1;
	plugin.minor = 0;
	plugin.version = plugin.major + "." + plugin.minor + " ( 8 Jun 2007)";
	plugin.description = "Notifies the user on any messages to a channel. " +
						"By James Ross 

<silver@warwickcompsoc.co.uk>.";
	
	plugin.prefary.push(["sound", "beep", ""]);
	plugin.prefary.push(["attention", true, ""]);
	
	return "OK";
}

plugin.enable =
function _enable() {
	client.eventPump.addHook([{ set: "channel", type: "privmsg"},
							  { set: "channel", type: "action"},
							  { set: "channel", type: "notice"},
							  { set: "channel", type: "join"},
							  { set: "channel", type: "part"},
							  { set: "channel", type: "quit"},
							  { set: "channel", type: "kick"}],
							 plugin.onMessage, plugin.id + "-channel-hook");
	
	return true;
}

plugin.disable =
function _disable() {
	client.eventPump.removeHookByName(plugin.id + "-channel-hook");
	
	return true;
}

plugin.onMessage =
function _onMessage(e) {
	try {
		if (plugin.prefs["sound"] && !window.isFocused)
			playSounds(plugin.prefs["sound"]);
		if (plugin.prefs["attention"] && !window.isFocused)
			window.getAttention();
	} catch(ex) {
		showErrorDlg(ex);
	}
}

And apparently I can play a sound like so....
function PlaySound(){
window.location = "D:\Apps\SeaMonkey\connect.wav"
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users