#!/usr/bin/perl -w IRC::register("Auto-reop Script", "1.0", "", ""); IRC::print "\0035:: Loading Auto-reop Script ::\003 \n"; IRC::add_message_handler("INBOUND", "inbound_handler"); # leave a channel sub inbound_handler { my($line) = @_; # IRC::print "inbound_handler() ''$line''\n"; # :Joker31!~marc@hevea.stna.dgac.fr PART #stna :Joker31 # :Joker31!~marc@hevea.stna.dgac.fr KICK #linux Joker31 :Joker31'' if($line =~ m/:(.+?)\!(.+?) PART (.*) :(.*)/o || $line =~ m/:(.+?)\!(.+?) KICK (.*) (.*) :(.*)/o) { $part_nick = $1; $addr = $2; $chan = $3; $who = $4; # IRC::print "[PART|KICK]:: nick = $part_nick, addr=$addr, chan=$chan, who=$who\n"; $serv = IRC::get_info(3); $me = IRC::get_info(1); # if this is me who leave chan, just quit return undef if($me eq $part_nick); # get userlist on this chan @list = IRC::user_list($chan,$serv); # IRC::print "user list, me=$me, chan=$chan, serv=$serv\n"; $count = 0; while(@list > 0) { ($nick,$addr,$op,$voice,$foo) = splice(@list,0,5); # don't count the user who just part in this list. next if($nick eq $part_nick); # register if I am op or not. $me_op = $op if($me eq $nick); $count++; # IRC::print " ** $nick : $addr : $op : $voice\n"; } # if I am not OP, and the last on this chan, just leave and enter again to gain OP !!! if($count ==1 && $me_op == 0) { IRC::print "Auto-reop::I'm the last on $chan, try re-op $chan\n"; IRC::command("/leave $chan"); IRC::command("/join $chan"); } } # return undef : continue, return 1 : last plugin (hook) ! return undef; }