Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Tiny JavaScript for Chatzilla, I need a bit of help with a small notification script
Neo-SiN
post Sep 21 2008, 06:43 PM
Post #1
Atomican
Master




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.

CODE
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....
CODE
function PlaySound(){
window.location = "D:\Apps\SeaMonkey\connect.wav"
}
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 23rd April 2014 - 09:47 PM