LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Resistence is futile

[ILUG] Resistence is futile

kevin lyda kevin at suberic.net
Tue Mar 5 13:21:01 GMT 2002


On Tue, Mar 05, 2002 at 12:32:39PM +0000, Niall O Broin wrote:
> On Wed, Mar 06, 2002 at 12:38:50AM +1300, Vincent Cunniffe wrote:
> > Nope, IRC requires no client-side support, and X-Chat is very easy to
> > configure for things
> > like auto-connecting to favourite servers, etc.
> Yes, X-Chat works fine, and is a very important tool to me for work (would
> be even more important if we didn't live in the e-arsehole of Europe) BUT I
> don't like its sound configuration - it seems difficult to get reasonable
> noises like I can get on my Mac client for example.

i've been slowly tweaking this script for xchat.  i took autoresponder.pl
as a template and then ripped it's guts out.  Alert.pl is what i call
it (actually i call it ~/.xchat/autorun.pl since i dunno how else to
force xchat to load it automatically).  it will pop up a dialog window
(which i can dismiss by pressing return) if someone sends me a private
message or if my nick shows up in a message in a channel i'm on.

(conor, this is different then what i sent you, use this one).

kevin

--------8<-----snip------->8--------

#!/usr/bin/perl -w

use strict;

#######################################
#                                     #
# CONFIG start                        #
#                                     #
#######################################

# how to alert you - a %s element will be replaced with "theirNick: message"
my $alerter = ("xmessage -nearmouse -bg steelblue -fg wheat".
               " -default okay -timeout 600 %s"); 
### main
IRC::register("kevin's alert script", "0.1", "", "");
IRC::print("\0035++Loading kevin's alert script v0.1::\003 \n");
IRC::print("\0033++USE: /alert [on|off|toggle]\003\n");
IRC::print("\0033++turns alert on, off or toggles it\003\n");
IRC::print("\0033++USE: /alert_help\n");
IRC::print("\0033++print this commands\n");
IRC::print("\0034++alert is turned ON\003 \n");

### initialise handlers
IRC::add_message_handler("PRIVMSG", "alert_privmsg_hand_0_1");
IRC::add_command_handler("alert", "alert_cmd_alert_0_1");
IRC::add_command_handler("alert_help", "alert_cmd_help_0_1");

### globals
my $alert = 1;

### functions
sub
alert_privmsg_hand_0_1
{
    my $msg = shift(@_);

    my $me = IRC::get_info(1);
    if ($alert == 1) {
	#parse act. msg
	$msg =~ m/\:(.*?)\!(.*?)\sPRIVMSG\s(.*?)\s\:(.*)?/;
	my $msgNick = $1;
	my $msgFrom = $2;
	my $msgTo = $3;
	my $msgText = $4;
	if (($me eq $msgTo) or ($msgText =~ m/$me/i)) {
	    my $tmp_text = "$msgNick: $msgText";
	    $tmp_text =~ s/([^-\@\w: .'])/\\$1/g;
	    $tmp_text =~ s/'/'"\\'"'/g;
	    my $tmp_alerter = $alerter;
	    $tmp_alerter =~ s/\%s/$tmp_text/g;
	    system("sh -c '$tmp_alerter' &")
	}
    }
    return 0;
}


sub
alert_cmd_alert_0_1
{
    my $arg = shift;

    if (lc($arg) eq "on" ) {
	IRC::print("\0034++alert is turned ON\003 \n");
	$alert=1;
    } elsif(lc($arg) eq "off") {
	IRC::print("\0034++alert is turned OFF\003 \n");
	$alert=0;
    } elsif(lc($arg) eq "toggle") {
	&alert_cmd_alert_0_1($alert? "off": "on");
    } else {
	IRC::print("USE: /alert [on|off|toggle]\n");
	IRC::print("to turn alert on, off or toggles it\n");
    }
    return 1;
}

sub
alert_cmd_help_0_1
{
    IRC::print("\0035++kevin's alert script v0.1::\003 \n");
    IRC::print("\0033++USE: /alert [on|off|toggle]\003\n");
    IRC::print("\0033++turns alert on, off or toggles it\003\n");
    
    return 1;
}

-- 
kevin at suberic.net          buffy: come on, can't you put your foot down?!
fork()'ed on 37058400      giles: it *is* down.
meatspace place: orbit     buffy: one of these days you're going to have to
http://suberic.net/~kevin         get a grown up car.  --inca mummy girl




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell