#!/usr/bin/perl # Created: Sapan Bhatia 24.2.2002 # # 1. Make files called "hushmen" and "ircppl" in your home directory, # listing irc nicks (one nick/line) you want to be notified for (hushmen to be # notified when the user posts a message and ircppl for when the person joins). # # 2. Write a script called "sendsms" that sends the text in the environment # variable "$MESSAGE" to you. # IRC::register("SMS-notify", "0.1", "", ""); IRC::print("\0035Loading sms-notify plugin - by Sapan Bhatia"); IRC::add_message_handler("PRIVMSG", "notice_handler"); IRC::add_message_handler("JOIN", "join_handler"); IRC::add_message_handler("PART", "part_handler"); my @talk; sub part_handler { return 0; } sub happy_to_see { my $nick=shift(@_); my $fil=shift(@_); my $path=$ENV{'HOME'}."/.$fil"; open fil, $path; my $ret = 0; my @l=; foreach $guy (@l) { $guy =~ s/\n//g; if ($nick =~ /$guy/) { $ret = 1; last; } } return $ret; } sub spoke { my $who=shift(@_); if ($talk{$who} == 1) { return 1; } else { return 0; } } sub notice_handler { my $a=shift(@_); $a =~ m/([[:alnum:]_\-\,\.\+\=\~]*)[\!\s@].*PRIVMSG(.*)/; my $nick = $1; my $chan = $2; $chan =~ m/(.*)\:/; my $c = $1; if (happy_to_see($nick,"hushmen") && !spoke($nick)) { my $msg = "\0035$nick spake on channel $c\n"; $ENV{'MESSAGE'}=$msg; system("sendsms &"); $talk{$nick}=1; IRC::print("\0035$msg\n"); } return 0; } sub join_handler { my $a=shift(@_); $a =~ m/(.*)JOIN(.*)/; my $nick = $1; my $chan = $2; if (happy_to_see($nick,"ircppl")) { my $msg = "\0035$nick is online on channel $chan\n"; $ENV{'MESSAGE'}=$msg; system("sendsms &"); } return 0; }