Changes between Version 6 and Version 7 of Development/PlugIns/JavaScript


Ignore:
Timestamp:
Dec 10, 2006 6:20:19 PM (13 years ago)
Author:
timothy
Comment:

New example script

Legend:

Unmodified
Added
Removed
Modified
  • Development/PlugIns/JavaScript

    v6 v7  
    1919 
    2020---- 
     21 
     22= Example Plugin: Bug URL Reply = 
     23 
     24The following example will send a reply message to anyone that mentions the word "bug" or "bugs". This is a simple script that matches a regular expression on incomming messages and constructs a reply message to send.  '''Note: this script requires build [changeset:3450 3450] or later.''' 
     25 
     26{{{ 
     27#!text/x-javascript 
     28function processIncomingMessage(message, view) { 
     29        var bugRegex = new RegExp( '\\bbugs?\\b', 'gmi' ); 
     30        if( bugRegex.exec(message.bodyAsPlainText()) && ! message.senderIsLocalUser() ) { 
     31                var msg = new JVMutableChatMessage('', view.connection.localUser()); 
     32                msg.setBodyAsHTML(message.senderNickname() + ': <u>please</u> report any Colloquy bugs at http://colloquy.info?bugs'); 
     33                view.sendMessage(msg); 
     34                view.echoSentMessageToDisplay(msg); 
     35        } 
     36} 
     37}}} 
    2138 
    2239= Example Plugin: Grab URL Titles =