X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FIRC%2FIrcHooks.pl;h=d105d8e366b8e981f28c55ce16a3fcb7c9eb49db;hb=d3faaba2ad8c02cdf10e1a9698592afc6ed928bc;hp=7b098ae13d07e732019b0859eb4eb5d14af750fd;hpb=94c400bd94f8964e202e06d8748b1871ce630aec;p=infobot.git diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 7b098ae..d105d8e 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -4,6 +4,7 @@ # Version: 20000126 # NOTE: Based on code by Kevin Lenzo & Patrick Cole (c) 1997 # +use vars qw(%chanconf); # GENERIC. TO COPY. sub on_generic { @@ -114,7 +115,7 @@ sub on_chat { if ($message =~ s/^\.//) { # dcc chat commands. ### TODO: make use of &Forker(); here? - &loadMyModule( $myModules{'ircdcc'} ); + &loadMyModule('UserDCC'); &DCCBroadcast("#$who# $message","m"); @@ -159,7 +160,7 @@ sub on_endofmotd { # first time run. if (!exists $users{_default}) { &status("!!! First time run... adding _default user."); - $users{_default}{FLAGS} = "mrt"; + $users{_default}{FLAGS} = "amrt"; $users{_default}{HOSTS}{"*!*@*"} = 1; } @@ -170,7 +171,7 @@ sub on_endofmotd { } # end of first time run. - if (&IsChanConf("wingate")) { + if (&IsChanConf('Wingate') > 0) { my $file = "$bot_base_dir/$param{'ircUser'}.wingate"; open(IN, $file); while () { @@ -209,7 +210,7 @@ sub on_endofmotd { } &status("End of motd. Now lets join some channels..."); - &joinNextChan(); + #&joinNextChan(); } sub on_endofwho { @@ -230,6 +231,8 @@ sub on_dcc { my $type = uc( ($event->args)[1] ); my $nick = lc $event->nick(); + &status("on_dcc type=$type nick=$nick sock=$sock"); + # pity Net::IRC doesn't store nuh. Here's a hack :) if (!exists $nuh{lc $nick}) { $conn->whois($nick); @@ -240,12 +243,16 @@ sub on_dcc { if ($type eq 'SEND') { # GET for us. # incoming DCC SEND. we're receiving a file. my $get = ($event->args)[2]; - open(DCCGET,">$get"); - - $conn->new_get($event, \*DCCGET); + &status("DCC: not Initializing GET from $nick to '$param{tempDir}/$get'"); + # FIXME: do we want to get anything? + return; + #open(DCCGET,">$param{tempDir}/$get"); + #$conn->new_get($event, \*DCCGET); } elsif ($type eq 'GET') { # SEND for us? - &status("DCC: Initializing SEND for $nick."); + &status("DCC: not Initializing SEND for $nick."); + # FIXME: do we want to do anything? + return; $conn->new_send($event->args); } elsif ($type eq 'CHAT') { @@ -273,7 +280,7 @@ sub on_dcc_close { if (exists $dcc{'SEND'}{$nick} and -f "$param{tempDir}/$nick.txt") { &status("${b_green}DCC SEND$ob close from $b_cyan$nick$ob"); - &status("dcc_close: purging $nick.txt from Debian.pl"); + &status("dcc_close: purging DCC send $nick.txt"); unlink "$param{tempDir}/$nick.txt"; delete $dcc{'SEND'}{$nick}; @@ -293,6 +300,8 @@ sub on_dcc_open { my $nick = lc $event->nick(); my $sock = ($event->to)[0]; + &status("on_dcc_open type=$type nick=$nick sock=$sock"); + $msgType = 'chat'; $type ||= "???"; ### BUG: who is set to bot's nick? @@ -312,9 +321,9 @@ sub on_dcc_open { } } elsif ($type eq 'SEND') { - &DEBUG("Starting DCC receive."); + &status("Starting DCC receive."); foreach ($event->args) { - &DEBUG(" => '$_'."); + &status(" => '$_'."); } } else { @@ -337,7 +346,7 @@ sub on_dcc_open_chat { &verifyUser($nick, $nuh{lc $nick}); if (!exists $users{$userHandle}{HOSTS}) { - &pSReply("you have no hosts defined in my user file; rejecting."); + &performStrictReply("you have no hosts defined in my user file; rejecting."); $sock->close(); return; } @@ -571,21 +580,24 @@ sub on_join { ### ROOTWARN: &rootWarn($who,$user,$host,$chan) if ( - &IsChanConf("rootWarn") && + &IsChanConf('RootWarn') > 0 && $user =~ /^~?r(oo|ew|00)t$/i ); + ### emit a message based on who just joined + &onjoin($who,$user,$host,$chan) if (&IsChanConf('OnJoin') > 0); + ### NEWS: - if (&IsChanConf("news") && &IsChanConf("newsKeepRead")) { - if (!&loadMyModule("news")) { # just in case. - &DEBUG("could not load news."); + if (&IsChanConf('News') > 0 && &IsChanConf('newsKeepRead') > 0) { + if (!&loadMyModule('News')) { # just in case. + &DEBUG('could not load news.'); } else { &News::latest($chan); } } ### botmail: - if (&IsChanConf("botmail")) { + if (&IsChanConf('botmail') > 0) { &botmail::check(lc $who); } @@ -710,9 +722,10 @@ sub on_nick { $nuh{lc $newnick} = $nuh{lc $nick}; delete $nuh{lc $nick}; - if ($nick eq $ident) { + if ($nick eq $conn->nick()) { &status(">>> I materialized into $b_green$newnick$ob from $nick"); - $ident = $newnick; + $ident = $newnick; + $conn->nick($newnick); } else { &status(">>> $b_cyan$nick$ob materializes into $b_green$newnick$ob"); my $mynick=$conn->nick(); @@ -725,22 +738,18 @@ sub on_nick { sub on_nick_taken { $conn = shift(@_); my $nick = $conn->nick(); - my $newnick = $nick.int(rand 10); + #my $newnick = $nick . int(rand 10); + my $newnick = $nick . "_"; - if ($nick eq $ident) { - &DEBUG("on_nick_tane: nick eq ident... wtf?"); - return; - } - - &DEBUG("on_nick_taken: ident => $ident"); + &DEBUG("on_nick_taken: nick => $nick"); &status("nick taken ($nick); preparing nick change."); $conn->whois($nick); - $conn->schedule(5, sub { + #$conn->schedule(5, sub { &status("nick taken; changing to temporary nick ($nick -> $newnick)."); &nick($newnick); - } ); + #} ); } sub on_notice { @@ -865,7 +874,7 @@ sub on_ping_reply { sub on_public { $conn = shift(@_); my ($event) = @_; - my $msg = ($event->args)[0]; + my $msg = ($event->args)[0]; $chan = lc( ($event->to)[0] ); # CASING. my $nick = $event->nick; $who = $nick; @@ -965,7 +974,7 @@ sub on_quit { # chanlimit code. foreach $chan ( &getNickInChans($nick) ) { - next unless ( &IsChanConf("chanlimitcheck") ); + next unless ( &IsChanConf("chanlimitcheck") > 0); next unless ( exists $channels{$_}{'l'} ); &DEBUG("on_quit: netsplit detected on $_; disabling chan limit."); @@ -981,9 +990,6 @@ sub on_quit { my $chans = join(' ', &getNickInChans($nick) ); &status(">>> $b_cyan$nick$ob has signed off IRC $b_red($ob$reason$b_red)$ob [$chans]"); - if ($nick =~ /^\Q$ident\E$/) { - &ERROR("^^^ THIS SHOULD NEVER HAPPEN (10)."); - } ### ### ok... lets clear out the cache @@ -999,10 +1005,10 @@ sub on_quit { delete $chanstats{lc $nick}; ### - # FIXME: does this work? - my $mynick = $conn->nick(); - if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$mynick\E$/i) { - &status("nickchange: own nickname became free; changing."); + # if we have a temp nick, and whoever is camping on our main nick leaves + # revert to main nick. Note that Net::IRC only knows our main nick + if ($nick eq $conn->nick()) { + &status("nickchange: own nick \"$nick\" became free; changing."); &nick($mynick); } } @@ -1064,7 +1070,7 @@ sub on_topic { &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic"); } else { # join. my ($nick, $chan, $topic) = $event->args; - if (&IsChanConf("topic")) { + if (&IsChanConf('Topic') > 0) { $topic{$chan}{'Current'} = $topic; &topicAddHistory($chan,$topic); } @@ -1241,8 +1247,8 @@ sub on_banned { my @args = $event->args; my $chan = $args[1]; - &status(">>> banned/$b_blue$chan$ob $b_cyan$args[0]$ob"); - #FIXME if $args[0] == me then kill autojoin! + &status(">>> banned/$b_blue$chan$ob $b_cyan$args[0]$ob, removing autojoin for $chan"); + delete $chanconf{$chan}{autojoin}; &joinNextChan(); } @@ -1250,8 +1256,10 @@ sub on_badchankey { $conn = shift(@_); my ($event) = @_; my @args = $event->args; + my $chan = $args[1]; - &DEBUG("on_badchankey: args => @args"); + &DEBUG("on_badchankey: args => @args, removing autojoin for $chan"); + delete $chanconf{$chan}{autojoin}; &joinNextChan(); } @@ -1264,4 +1272,11 @@ sub on_useronchan { &joinNextChan(); } +# TODO not used yet +sub on_stdin { + my $line = ; + chomp($line); + &FIXME("on_stdin: line => \"$line\""); +} + 1;