2 # IrcHooks.pl: IRC Hooks stuff.
5 # NOTE: Based on code by Kevin Lenzo & Patrick Cole (c) 1997
8 if (&IsParam("useStrict")) { use strict; }
12 my ($self, $event) = @_;
13 my $nick = $event->nick();
14 my $chan = ($event->to)[0];
16 &DEBUG("on_generic: nick => '$nick'.");
17 &DEBUG("on_generic: chan => '$chan'.");
19 foreach ($event->args) {
20 &DEBUG("on_generic: args => '$_'.");
25 my ($self, $event) = @_;
26 my ($nick, @args) = ($event->nick, $event->args);
27 my $chan = ($event->to)[0];
31 if ($chan eq $ident) {
32 &status("* [$nick] @args");
34 &status("* $nick/$chan @args");
39 my ($self, $event) = @_;
40 my $msg = ($event->args)[0];
41 my $sock = ($event->to)[0];
42 my $nick = lc $event->nick();
44 if (!exists $nuh{$nick}) {
45 &DEBUG("chat: nuh{$nick} doesn't exist; trying WHOIS .");
50 ### set vars that would have been set in hookMsg.
51 $userHandle = ""; # reset.
55 $orig{message} = $msg;
57 $uh = (split /\!/, $nuh)[1];
61 if (!exists $dcc{'CHATvrfy'}{$nick}) {
62 $userHandle = &verifyUser($who, $nuh);
63 my $crypto = $users{$userHandle}{PASS};
66 if ($userHandle eq "_default") {
67 &WARN("DCC CHAT: _default/guest not allowed.");
71 ### TODO: prevent users without CRYPT chatting.
72 if (!defined $crypto) {
73 &DEBUG("todo: dcc close chat");
74 &msg($who, "nope, no guest logins allowed...");
78 if (&ckpasswd($msg, $crypto)) {
79 # stolen from eggdrop.
80 $self->privmsg($sock, "Connected to $ident");
81 $self->privmsg($sock, "Commands start with '.' (like '.quit' or '.help')");
82 $self->privmsg($sock, "Everything else goes out to the party line.");
84 &dccStatus(2) unless (exists $sched{"dccStatus"}{RUNNING});
89 &status("DCC CHAT: incorrect pass; closing connection.");
90 &DEBUG("chat: sock => '$sock'.");
92 delete $dcc{'CHAT'}{$nick};
93 &DEBUG("chat: after closing sock. FIXME");
94 ### BUG: close seizes bot. why?
98 &status("DCC CHAT: user $nick is here!");
99 &DCCBroadcast("*** $nick ($uh) joined the party line.");
101 $dcc{'CHATvrfy'}{$nick} = $userHandle;
103 return if ($userHandle eq "_default");
105 &dccsay($nick,"Flags: $users{$userHandle}{FLAGS}");
111 &status("$b_red=$b_cyan$who$b_red=$ob $message");
113 if ($message =~ s/^\.//) { # dcc chat commands.
114 ### TODO: make use of &Forker(); here?
115 &loadMyModule( $myModules{'ircdcc'} );
117 &DCCBroadcast("#$who# $message","m");
119 my $retval = &userDCC();
120 return unless (defined $retval);
121 return if ($retval eq $noreply);
123 $conn->privmsg($dcc{'CHAT'}{$who}, "Invalid command.");
125 } else { # dcc chat arena.
127 foreach (keys %{ $dcc{'CHAT'} }) {
128 $conn->privmsg($dcc{'CHAT'}{$_}, "<$who> $orig{message}");
132 return 'DCC CHAT MESSAGE';
139 $ident ||= $param{'ircNick'}; # hack.
140 $ircstats{'ConnectTime'} = time();
141 $ircstats{'ConnectCount'}++;
142 $ircstats{'OffTime'} += time() - $ircstats{'DisconnectTime'}
143 if (defined $ircstats{'DisconnectTime'});
146 if (!exists $users{_default}) {
147 &status("!!! First time run... adding _default user.");
148 $users{_default}{FLAGS} = "mrt";
149 $users{_default}{HOSTS}{"*!*@*"} = 1;
152 if (scalar keys %users < 2) {
154 &status("!!! Ok. Now type '/msg $ident PASS <pass>' to get master access through DCC CHAT.");
157 # end of first time run.
159 if (&IsChanConf("wingate")) {
160 my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
164 next unless (/^(\S+)\*$/);
165 push(@wingateBad, $_);
171 &ScheduleThis(1, \&setupSchedulers);
175 if (&IsParam("ircUMode")) {
176 &VERB("Attempting change of user modes to $param{'ircUMode'}.", 2);
177 if ($param{'ircUMode'} !~ /^[-+]/) {
178 &WARN("ircUMode had no +- prefix; adding +");
179 $param{'ircUMode'} = "+".$param{'ircUMode'};
182 &rawout("MODE $ident $param{'ircUMode'}");
185 &status("End of motd. Now lets join some channels...");
186 if (!scalar @joinchan) {
187 &WARN("joinchan array is empty!!!");
188 @joinchan = &getJoinChans(1);
191 # unfortunately, Net::IRC does not implement this :(
192 # invalid command... what is it?
193 # &rawout("NOTIFY $ident");
194 # &DEBUG("adding self to NOTIFY list.");
200 my ($self, $event) = @_;
201 # &DEBUG("endofwho: chan => $chan");
202 $chan ||= ($event->args)[1];
203 # &DEBUG("endofwho: chan => $chan");
205 if (exists $cache{countryStats}) {
211 my ($self, $event) = @_;
212 my $type = uc( ($event->args)[1] );
213 my $nick = lc $event->nick();
215 # pity Net::IRC doesn't store nuh. Here's a hack :)
216 if (!exists $nuh{lc $nick}) {
218 $nuh{$nick} = "GETTING-NOW"; # trying.
222 if ($type eq 'SEND') { # GET for us.
223 # incoming DCC SEND. we're receiving a file.
224 my $get = ($event->args)[2];
225 open(DCCGET,">$get");
227 $self->new_get($nick,
234 } elsif ($type eq 'GET') { # SEND for us?
235 &status("DCC: Initializing SEND for $nick.");
236 $self->new_send($event->args);
238 } elsif ($type eq 'CHAT') {
239 &status("DCC: Initializing CHAT for $nick.");
240 $self->new_chat($event);
243 &WARN("${b_green}DCC $type$ob (1)");
248 my ($self, $event) = @_;
249 my $nick = $event->nick();
250 my $sock = ($event->to)[0];
252 # DCC CHAT close on fork exit workaround.
253 if ($bot_pid != $$) {
254 &WARN("run-away fork; exiting.");
258 if (exists $dcc{'SEND'}{$nick} and -f "$param{tempDir}/$nick.txt") {
259 &status("${b_green}DCC SEND$ob close from $b_cyan$nick$ob");
261 &status("dcc_close: purging $nick.txt from Debian.pl");
262 unlink "$param{tempDir}/$nick.txt";
264 delete $dcc{'SEND'}{$nick};
265 } elsif (exists $dcc{'CHAT'}{$nick} and $dcc{'CHAT'}{$nick} eq $sock) {
266 &status("${b_green}DCC CHAT$ob close from $b_cyan$nick$ob");
267 delete $dcc{'CHAT'}{$nick};
268 delete $dcc{'CHATvrfy'}{$nick};
270 &status("${b_green}DCC$ob UNKNOWN close from $b_cyan$nick$ob (2)");
275 my ($self, $event) = @_;
276 my $type = uc( ($event->args)[0] );
277 my $nick = lc $event->nick();
278 my $sock = ($event->to)[0];
282 ### BUG: who is set to bot's nick?
285 if ($type eq 'SEND') {
286 &status("${b_green}DCC lGET$ob established with $b_cyan$nick$ob");
288 } elsif ($type eq 'CHAT') {
290 ### TODO: run ScheduleThis inside on_dcc_open_chat recursively
291 ### 1,3,5,10 seconds then fail.
292 if ($nuh{$nick} eq "GETTING-NOW") {
293 &ScheduleThis(3/60, "on_dcc_open_chat", $nick, $sock);
295 on_dcc_open_chat(undef, $nick, $sock);
298 } elsif ($type eq 'SEND') {
299 &DEBUG("Starting DCC receive.");
300 foreach ($event->args) {
305 &WARN("${b_green}DCC $type$ob (3)");
309 # really custom sub to get NUH since Net::IRC doesn't appear to support
311 sub on_dcc_open_chat {
312 my(undef, $nick, $sock) = @_;
314 if ($nuh{$nick} eq "GETTING-NOW") {
315 &DEBUG("getting nuh for $nick failed. FIXME.");
319 &status("${b_green}DCC CHAT$ob established with $b_cyan$nick$ob $b_yellow($ob$nuh{$nick}$b_yellow)$ob");
321 &verifyUser($nick, $nuh{lc $nick});
323 if (!exists $users{$userHandle}{HOSTS}) {
324 &pSReply("you have no hosts defined in my user file; rejecting.");
329 my $crypto = $users{$userHandle}{PASS};
330 $dcc{'CHAT'}{$nick} = $sock;
332 # todo: don't make DCC CHAT established in the first place.
333 if ($userHandle eq "_default") {
334 &dccsay($nick, "_default/guest not allowed");
339 if (defined $crypto) {
340 &status("DCC CHAT: going to use ".$nick."'s crypt.");
341 &dccsay($nick,"Enter your password.");
343 # &dccsay($nick,"Welcome to blootbot DCC CHAT interface, $userHandle.");
348 my ($self, $event) = @_;
349 my $from = $event->from();
350 my $what = ($event->args)[0];
352 &status("disconnect from $from ($what).");
353 $ircstats{'DisconnectTime'} = time();
354 $ircstats{'DisconnectReason'} = $what;
355 $ircstats{'DisconnectCount'}++;
356 $ircstats{'TotalTime'} += time() - $ircstats{'ConnectTime'};
358 # clear any variables on reconnection.
362 if (!$self->connect()) {
363 &WARN("not connected? help me. gonna call ircCheck() in 60s");
364 &ScheduleThis(1, "ircCheck");
365 # &ScheduleThis(10, "ircCheck");
366 # &ScheduleThis(30, "ircCheck");
371 my ($self, $event) = @_;
372 my $chan = ($event->args)[1];
374 # sync time should be done in on_endofwho like in BitchX
375 if (exists $cache{jointime}{$chan}) {
376 my $delta_time = sprintf("%.03f", &timedelta($cache{jointime}{$chan}) );
377 $delta_time = 0 if ($delta_time < 0);
378 if ($delta_time > 100) {
379 &WARN("endofnames: delta_time > 100 ($delta_time)");
382 &status("$b_blue$chan$ob: sync in ${delta_time}s.");
385 rawout("MODE $chan");
389 foreach ("o","v","") {
390 my $count = scalar(keys %{ $channels{$chan}{$_} });
391 next unless ($count);
393 $txt = "total" if ($_ eq "");
394 $txt = "voice" if ($_ eq "v");
395 $txt = "ops" if ($_ eq "o");
397 push(@array, "$count $txt");
399 my $chanstats = join(' || ', @array);
400 &status("$b_blue$chan$ob: [$chanstats]");
402 &chanServCheck($chan);
403 # schedule used to solve ircu (OPN) "target too fast" problems.
404 $conn->schedule(5, sub { &joinNextChan(); } );
408 my ($self, $event) = @_;
409 my (@args) = ($event->args);
416 my ($self, $event) = @_;
417 my $chan = lc( ($event->args)[0] );
418 my $nick = $event->nick;
420 if ($nick =~ /^\Q$ident\E$/) {
421 &DEBUG("on_invite: self invite.");
426 if (exists $chanconf{$chan}) {
427 if (&validChan($chan)) {
428 &msg($who, "i'm already in \002$chan\002.");
432 &status("invited to $b_blue$chan$ob by $b_cyan$nick$ob");
438 my ($self, $event) = @_;
439 my ($user,$host) = split(/\@/, $event->userhost);
440 $chan = lc( ($event->to)[0] ); # CASING!!!!
441 $who = $event->nick();
444 $chanstats{$chan}{'Join'}++;
445 $userstats{lc $who}{'Join'} = time() if (&IsChanConf("seenStats"));
447 &joinfloodCheck($who, $chan, $event->userhost);
451 if (exists $netsplit{lc $who}) {
452 delete $netsplit{lc $who};
455 if (!scalar keys %netsplit) {
456 &DEBUG("on_join: netsplit hash is now empty!");
457 undef %netsplitservers;
458 &netsplitCheck(); # any point in running this?
463 if ($netsplit and !exists $cache{netsplit}) {
464 &VERB("on_join: ok.... re-running chanlimitCheck in 60.",2);
465 $conn->schedule(60, sub {
467 delete $cache{netsplit};
470 $cache{netsplit} = time();
473 # how to tell if there's a netjoin???
475 my $netsplitstr = "";
476 $netsplitstr = " $b_yellow\[${ob}NETSPLIT VICTIM$b_yellow]$ob" if ($netsplit);
477 &status(">>> join/$b_blue$chan$ob $b_cyan$who$ob $b_yellow($ob$user\@$host$b_yellow)$ob$netsplitstr");
479 $channels{$chan}{''}{$who}++;
480 $nuh = $who."!".$user."\@".$host;
481 $nuh{lc $who} = $nuh unless (exists $nuh{lc $who});
485 push(@bans, keys %{ $bans{$chan} }) if (exists $bans{$chan});
486 push(@bans, keys %{ $bans{"*"} }) if (exists $bans{"*"});
493 next unless ($nuh =~ /^$mask$/i);
495 ### TODO: check $channels{$chan}{'b'} if ban already exists.
496 foreach (keys %{ $channels{$chan}{'b'} }) {
497 &DEBUG(" bans_on_chan($chan) => $_");
500 my $reason = "no reason";
501 foreach ($chan, "*") {
502 next unless (exists $bans{$_});
503 next unless (exists $bans{$_}{$ban});
505 my @array = @{ $bans{$_}{$ban} };
507 $reason = $array[4] if ($array[4]);
512 &kick($who, $chan, $reason);
517 # no need to go further.
518 return if ($netsplit);
521 if ($who eq $ident or $who =~ /^$ident$/i) {
522 if (defined( my $whojoin = $cache{join}{$chan} )) {
523 &msg($chan, "Okay, I'm here. (courtesy of $whojoin)");
524 delete $cache{join}{$chan};
527 ### TODO: move this to &joinchan()?
528 $cache{jointime}{$chan} = &timeget();
535 &rootWarn($who,$user,$host,$chan) if (
536 &IsChanConf("rootWarn") &&
537 $user =~ /^r(oo|ew|00)t$/i
541 if (&IsChanConf("news") && &IsChanConf("newsKeepRead")) {
542 if (!&loadMyModule("news")) { # just in case.
543 &DEBUG("could not load news.");
545 &News::latest($chan);
550 # &chanLimitVerify($chan);
557 my ($self, $event) = @_;
558 my ($chan,$reason) = $event->args;
559 my $kicker = $event->nick;
560 my $kickee = ($event->to)[0];
561 my $uh = $event->userhost();
563 &status(">>> kick/$b_blue$chan$ob [$b$kickee!$uh$ob] by $b_cyan$kicker$ob $b_yellow($ob$reason$b_yellow)$ob");
565 $chan = lc $chan; # forgot about this, found by xsdg, 20001229.
566 $chanstats{$chan}{'Kick'}++;
568 if ($kickee eq $ident) {
569 &clearChanVars($chan);
571 &status("SELF attempting to rejoin lost channel $chan");
574 &delUserInfo($kickee,$chan);
579 my ($self, $event) = @_;
580 my ($user, $host) = split(/\@/, $event->userhost);
581 my @args = $event->args();
582 my $nick = $event->nick();
583 $chan = ($event->to)[0];
587 if ($nick eq $chan) { # UMODE
588 &status(">>> mode $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
590 &status(">>> mode/$b_blue$chan$ob $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
591 &hookMode($nick, @args);
596 my ($self, $event) = @_;
597 my ($myself, undef,@args) = $event->args();
598 my $nick = $event->nick();
599 $chan = ($event->args())[1];
601 &hookMode($nick, @args);
605 my ($self, $event) = @_;
606 my $nick = $event->nick;
607 my $msg = ($event->args)[0];
609 ($user,$host) = split(/\@/, $event->userhost);
610 $uh = $event->userhost();
611 $nuh = $nick."!".$uh;
614 if ($nick eq $ident) { # hopefully ourselves.
615 if ($msg eq "TEST") {
616 &status("IRCTEST: Yes, we're alive.");
617 delete $cache{connect};
622 &hookMsg('private', undef, $nick, $msg);
629 my ($self, $event) = @_;
630 my @args = $event->args;
631 my $chan = lc $args[2]; # CASING, the last of them!
633 foreach (split / /, @args[3..$#args]) {
634 $channels{$chan}{'o'}{$_}++ if s/\@//;
635 $channels{$chan}{'v'}{$_}++ if s/\+//;
636 $channels{$chan}{''}{$_}++;
641 my ($self, $event) = @_;
642 my $nick = $event->nick();
643 my $newnick = ($event->args)[0];
645 if (exists $netsplit{lc $newnick}) {
646 &status("Netsplit: $newnick/$nick came back from netsplit and changed to original nick! removing from hash.");
647 delete $netsplit{lc $newnick};
648 &netsplitCheck() if (time() != $sched{netsplitCheck}{TIME});
652 foreach $chan (keys %channels) {
653 foreach $mode (keys %{ $channels{$chan} }) {
654 next unless (exists $channels{$chan}{$mode}{$nick});
656 $channels{$chan}{$mode}{$newnick} = $channels{$chan}{$mode}{$nick};
659 # todo: do %flood* aswell.
661 &delUserInfo($nick, keys %channels);
662 $nuh{lc $newnick} = $nuh{lc $nick};
663 delete $nuh{lc $nick};
665 if ($nick eq $ident) {
666 &status(">>> I materialized into $b_green$newnick$ob from $nick");
669 &status(">>> $b_cyan$nick$ob materializes into $b_green$newnick$ob");
671 if ($nick =~ /^\Q$param{'ircNick'}\E$/i) {
679 my $nick = $self->nick;
680 my $newnick = $nick."-";
682 &status("nick taken ($nick); preparing nick change.");
685 $conn->schedule(5, sub {
686 &status("nick taken; changing to temporary nick ($nick -> $newnick).");
692 my ($self, $event) = @_;
693 my $nick = $event->nick();
694 my $chan = ($event->to)[0];
695 my $args = ($event->args)[0];
697 if ($nick =~ /^NickServ$/i) { # nickserv.
698 &status("NickServ: <== '$args'");
701 $check++ if ($args =~ /^This nickname is registered/i);
702 $check++ if ($args =~ /nickname.*owned/i);
705 &status("nickserv told us to register; doing it.");
707 if (&IsParam("nickServ_pass")) {
708 &status("NickServ: ==> Identifying.");
709 &rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
712 &status("We can't tell nickserv a passwd ;(");
717 if ($args =~ /^Password a/i) {
720 foreach ( &ChanConfList("chanServ_ops") ) {
721 next unless &chanServCheck($_);
723 &DEBUG("nickserv activated or restarted; doing chanserv check.");
729 } elsif ($nick =~ /^ChanServ$/i) { # chanserv.
730 &status("ChanServ: <== '$args'.");
733 if ($chan =~ /^$mask{chan}$/) { # channel notice.
734 &status("-$nick/$chan- $args");
736 $server = $nick unless (defined $server);
737 &status("-$nick- $args"); # private or server notice.
743 my ($self, $event) = @_;
744 my $chan = ($event->to)[0];
745 my $nick = $event->nick;
747 &status("!!! other called.");
748 &status("!!! $event->args");
752 my ($self, $event) = @_;
753 $chan = lc( ($event->to)[0] ); # CASING!!!
754 my $nick = $event->nick;
755 my $userhost = $event->userhost;
759 if (exists $floodjoin{$chan}{$nick}{Time}) {
760 delete $floodjoin{$chan}{$nick};
763 $chanstats{$chan}{'Part'}++;
764 &delUserInfo($nick,$chan);
765 if ($nick eq $ident) {
766 &DEBUG("on_part: ok, I left $chan... clearChanVars...");
767 &clearChanVars($chan);
770 if (!&IsNickInAnyChan($nick) and &IsChanConf("seenStats")) {
771 delete $userstats{lc $nick};
774 &status(">>> part/$b_blue$chan$ob $b_cyan$nick$ob $b_yellow($ob$userhost$b_yellow)$ob");
778 my ($self, $event) = @_;
779 my $nick = $event->nick;
781 $self->ctcp_reply($nick, join(' ', ($event->args)));
782 &status(">>> ${b_green}CTCP PING$ob request from $b_cyan$nick$ob received.");
786 my ($self, $event) = @_;
787 my $nick = $event->nick;
788 my $lag = time() - ($event->args)[1];
790 &status(">>> ${b_green}CTCP PING$ob reply from $b_cyan$nick$ob: $lag sec.");
794 my ($self, $event) = @_;
795 my $msg = ($event->args)[0];
796 $chan = lc( ($event->to)[0] ); # CASING.
797 my $nick = $event->nick;
799 $uh = $event->userhost();
800 $nuh = $nick."!".$uh;
802 # todo: move this out of hookMsg to here?
803 ($user,$host) = split(/\@/, $uh);
805 # rare case should this happen - catch it just in case.
806 if ($bot_pid != $$) {
807 &ERROR("run-away fork; exiting.");
812 $lastWho{$chan} = $nick;
813 ### TODO: use $nick or lc $nick?
814 if (&IsChanConf("seenStats")) {
815 $userstats{lc $nick}{'Count'}++;
816 $userstats{lc $nick}{'Time'} = time();
819 # would this slow things down?
820 if ($_ = &getChanConf("ircTextCounters")) {
821 foreach (split /[\s]+/) {
822 next unless ($msg =~ /^\Q$_\E$/i);
823 &VERB("textcounters: $_ matched for $who",2);
825 my $v = &dbGet("stats", "counter", "nick=".&dbQuote($who).
829 &dbReplace("stats", (nick => $who, type => $_, counter => $v) );
830 # does not work, atleast with old mysql!!! :(
831 # &dbReplace("stats", (nick => $who, type => $_, -counter => "counter+1") );
835 &hookMsg('public', $chan, $nick, $msg);
836 $chanstats{$chan}{'PublicMsg'}++;
843 my ($self, $event) = @_;
844 my $nick = $event->nick();
845 my $reason = ($event->args)[0];
850 ### $chan = $reason; # no.
853 foreach (keys %channels) {
854 # fixes inconsistent chanstats bug #1.
855 if (!&IsNickInChan($nick,$_)) {
859 $chanstats{$_}{'SignOff'}++;
862 if ($count == scalar keys %channels) {
863 &DEBUG("on_quit: nick $nick was not found in any chan.");
866 # should fix chanstats inconsistencies bug #2.
867 if ($reason =~ /^($mask{host})\s($mask{host})$/) { # netsplit.
868 $reason = "NETSPLIT: $1 <=> $2";
871 foreach $chan ( &getNickInChans($nick) ) {
872 next unless ( &IsChanConf("chanlimitcheck") );
873 next unless ( exists $channels{$_}{'l'} );
875 &DEBUG("on_quit: netsplit detected on $_; disabling chan limit.");
876 &rawout("MODE $_ -l");
879 $netsplit{lc $nick} = time();
880 if (!exists $netsplitservers{$1}{$2}) {
881 &status("netsplit detected between $1 and $2 at [".scalar(localtime)."]");
882 $netsplitservers{$1}{$2} = time();
886 my $chans = join(' ', &getNickInChans($nick) );
887 &status(">>> $b_cyan$nick$ob has signed off IRC $b_red($ob$reason$b_red)$ob [$chans]");
888 if ($nick =~ /^\Q$ident\E$/) {
889 &ERROR("^^^ THIS SHOULD NEVER HAPPEN (10).");
893 ### ok... lets clear out the cache
895 &delUserInfo($nick, keys %channels);
896 if (exists $nuh{lc $nick}) {
897 delete $nuh{lc $nick};
899 # well.. it's good but weird that this has happened - lets just
902 delete $userstats{lc $nick} if (&IsChanConf("seenStats"));
903 delete $chanstats{lc $nick};
907 if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$param{'ircNick'}\E$/i) {
908 &status("nickchange: own nickname became free; changing.");
909 &nick($param{'ircNick'});
913 sub on_targettoofast {
914 my ($self, $event) = @_;
915 my $nick = $event->nick();
916 my($me,$chan,$why) = $event->args();
918 ### TODO: incomplete.
919 if ($why =~ /.* wait (\d+) second/) {
924 &status("targettoofast: going to sleep for $max ($sleep)...");
927 &status("targettoofast: going to sleep for $sleep");
930 my $delta = time() - ($cache{sleepTime} || 0);
931 if ($delta > $max+2) {
933 $cache{sleepTime} = time();
939 if (!exists $cache{TargetTooFast}) {
940 &DEBUG("on_ttf: failed: $why");
941 $cache{TargetTooFast}++;
946 my ($self, $event) = @_;
948 if (scalar($event->args) == 1) { # change.
949 my $topic = ($event->args)[0];
950 my $chan = ($event->to)[0];
951 my $nick = $event->nick();
955 # race condition here. To fix, change '1' to '0'.
956 # This will keep track of topics set by bot only.
959 # this may be fixed at a later date with topic queueing.
962 $topic{$chan}{'Current'} = $topic if (1);
963 $chanstats{$chan}{'Topic'}++;
965 &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic");
967 my ($nick, $chan, $topic) = $event->args;
968 if (&IsChanConf("topic")) {
969 $topic{$chan}{'Current'} = $topic;
970 &topicAddHistory($chan,$topic);
973 $topic = &fixString($topic, 1);
974 &status(">>> topic/$b_blue$chan$ob is $topic");
979 my ($self, $event) = @_;
980 my ($myself,$chan,$setby,$time) = $event->args();
983 if (time() - $time > 60*60*24) {
984 $timestr = "at ". localtime $time;
986 $timestr = &Time2String(time() - $time) ." ago";
989 &status(">>> set by $b_cyan$setby$ob $timestr");
993 my ($self, $event) = @_;
994 my $nick = $event->nick();
997 if (scalar $event->args() != 1) { # old.
998 $ver = join ' ', $event->args();
999 $ver =~ s/^VERSION //;
1001 $ver = ($event->args())[0];
1004 if (grep /^\Q$nick\E$/i, @vernick) {
1005 &WARN("nick $nick found in vernick; skipping.");
1008 push(@vernick, $nick);
1010 if ($ver =~ /bitchx/i) {
1011 $ver{bitchx}{$nick} = $ver;
1013 } elsif ($ver =~ /xc\!|xchat/i) {
1014 $ver{xchat}{$nick} = $ver;
1016 } elsif ($ver =~ /irssi/i) {
1017 $ver{irssi}{$nick} = $ver;
1019 } elsif ($ver =~ /epic/i) {
1020 $ver{epic}{$nick} = $ver;
1022 } elsif ($ver =~ /mirc/i) {
1023 &DEBUG("verstats: mirc: $nick => '$ver'.");
1024 $ver{mirc}{$nick} = $ver;
1026 } elsif ($ver =~ /ircle/i) {
1027 $ver{ircle}{$nick} = $ver;
1029 } elsif ($ver =~ /ircII/i) {
1030 $ver{ircII}{$nick} = $ver;
1032 } elsif ($ver =~ /sirc /i) {
1033 $ver{sirc}{$nick} = $ver;
1035 } elsif ($ver =~ /kvirc/i) {
1036 $ver{kvirc}{$nick} = $ver;
1038 } elsif ($ver =~ /eggdrop/i) {
1039 $ver{eggdrop}{$nick} = $ver;
1041 } elsif ($ver =~ /xircon/i) {
1042 $ver{xircon}{$nick} = $ver;
1045 &DEBUG("verstats: other: $nick => '$ver'.");
1046 $ver{other}{$nick} = $ver;
1051 my ($self, $event) = @_;
1052 my $nick = $event->nick;
1054 &status(">>> ${b_green}CTCP VERSION$ob request from $b_cyan$nick$ob");
1055 $self->ctcp_reply($nick, "VERSION $bot_version");
1059 my ($self, $event) = @_;
1060 my @args = $event->args;
1061 my $str = $args[5]."!".$args[2]."\@".$args[3];
1063 if ($cache{on_who_Hack}) {
1064 $cache{nuhInfo}{lc $args[5]}{Nick} = $args[5];
1065 $cache{nuhInfo}{lc $args[5]}{User} = $args[2];
1066 $cache{nuhInfo}{lc $args[5]}{Host} = $args[3];
1067 $cache{nuhInfo}{lc $args[5]}{NUH} = "$args[5]!$args[2]\@$args[3]";
1071 if ($args[5] =~ /^nickserv$/i and !$nickserv) {
1072 &DEBUG("ok... we did a who for nickserv.");
1073 &rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
1076 $nuh{lc $args[5]} = $args[5]."!".$args[2]."\@".$args[3];
1080 my ($self, $event) = @_;
1081 my @args = $event->args;
1083 &DEBUG("on_whoisuser: @args");
1085 $nuh{lc $args[1]} = $args[1]."!".$args[2]."\@".$args[3];
1089 ### since joinnextchan is hooked onto on_endofnames, these are needed.
1093 my ($self, $event) = @_;
1094 my @args = $event->args;
1096 &DEBUG("on_chanfull: args => @args");
1101 my ($self, $event) = @_;
1102 my @args = $event->args;
1104 &DEBUG("on_inviteonly: args => @args");
1109 my ($self, $event) = @_;
1110 my @args = $event->args;
1112 &DEBUG("on_banned: args => @args");
1117 my ($self, $event) = @_;
1118 my @args = $event->args;
1120 &DEBUG("on_badchankey: args => @args");