diff options
| author | 2016-01-07 19:55:36 -0700 | |
|---|---|---|
| committer | 2016-01-07 19:55:36 -0700 | |
| commit | 645cc36c05909b0ffd0ec9423e3633c8a1b8673b (patch) | |
| tree | 434152404ce86d9150c442cf71c474dfcc815c59 /lib | |
| parent | 1cb83fe999b03d2c913ca409650036a8d4dd462e (diff) | |
Use Tie::CPHash to make %::sn and %::sc case-insensitiveish.
Clean up commands.xml and fix some bugs
Add clone detection
Minimize some excessive warnings
Greatly improve syncing speed
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ASM/Classes.pm | 15 | ||||
| -rw-r--r-- | lib/ASM/Commander.pm | 5 | ||||
| -rw-r--r-- | lib/ASM/Event.pm | 46 | ||||
| -rw-r--r-- | lib/ASM/Services.pm | 9 |
4 files changed, 59 insertions, 16 deletions
diff --git a/lib/ASM/Classes.pm b/lib/ASM/Classes.pm index 2fae035..1f0e3ef 100644 --- a/lib/ASM/Classes.pm +++ b/lib/ASM/Classes.pm @@ -37,13 +37,26 @@ sub new "garbagemeter" => \&garbagemeter, "cyclebotnet" => \&cyclebotnet, "banevade" => \&banevade, - "urlcrunch" => \&urlcrunch + "urlcrunch" => \&urlcrunch, + "cloning" => \&cloning }; $self->{ftbl} = $tbl; bless($self); return $self; } +sub cloning { + my ($chk, $id, $event, $chan, $rev) = @_; + my $max = int($chk->{content}); + my @nicks = grep {($::sn{$_}->{host} eq $event->{host}) && (lc $chan ~~ $::sn{$_}->{mship})} keys %::sn; + # It's lines like these that make me love Perl no matter how much it drives dwfreed up a tree. + # Understanding how that line works is simple and is left as an exercise to the reader. + if ($#nicks >= $max) { + return ASM::Util->commaAndify(@nicks); + } + return 0; +} + sub garbagemeter { my ($chk, $id, $event, $chan, $rev) = @_; my @cut = split(/:/, $chk->{content}); diff --git a/lib/ASM/Commander.pm b/lib/ASM/Commander.pm index d864800..c1f93ef 100644 --- a/lib/ASM/Commander.pm +++ b/lib/ASM/Commander.pm @@ -35,7 +35,10 @@ sub command next unless (defined($command->{nohush}) && ($command->{nohush} eq "nohush")); } if (defined($command->{flag})) { #If the command is restricted, - if (!defined($::users->{person}->{$acct})) { #make sure the requester has an account + if (!defined($acct)) { + $fail = 1; + } + elsif (!defined($::users->{person}->{$acct})) { #make sure the requester has an account $fail = 1; } elsif (!defined($::users->{person}->{$acct}->{flags})) { #make sure the requester has flags defined diff --git a/lib/ASM/Event.pm b/lib/ASM/Event.pm index 04046c4..f057582 100644 --- a/lib/ASM/Event.pm +++ b/lib/ASM/Event.pm @@ -7,6 +7,7 @@ use IO::All; use POSIX qw(strftime); use Regexp::Wildcards; use HTTP::Request; +use Array::Utils qw(:all); sub new { @@ -144,7 +145,7 @@ sub on_pong if (($pongcount++ % 3) == 0) { #easiest way to do something roughly every 90 seconds $conn->sl('STATS p'); } - if ( @::syncqueue || $::netsplit_ignore_lag ) { + if ( @::syncqueue || $::netsplit_ignore_lag || $::pendingsync) { return; #we don't worry about lag if we've just started up and are still syncing, or just experienced a netsplit } if (($lag > 2) && ($lag < 5)) { @@ -216,9 +217,9 @@ sub on_connect { if (lc $event->{args}->[0] ne lc $::settings->{nick}) { ASM::Util->dprint('Attempting to regain my main nick', 'startup'); $conn->sl("NickServ regain $::settings->{nick} $::settings->{pass}"); - } else { - $conn->sl("NickServ identify $::settings->{nick} $::settings->{pass}"); - } + }# else { +# $conn->sl("NickServ identify $::settings->{nick} $::settings->{pass}"); +# } $conn->sl('CAP REQ :extended-join multi-prefix account-notify'); #god help you if you try to use this bot off freenode } @@ -232,12 +233,14 @@ sub on_join { $::sc{$chan} = {}; mkdir($::settings->{log}->{dir} . $chan); $::synced{$chan} = 0; - unless ( @::syncqueue ) { - $conn->sl('who ' . $chan . ' %tcnuhra,314'); - $conn->sl('mode ' . $chan); - $conn->sl('mode ' . $chan . ' bq'); - } - push @::syncqueue, $chan; + $::pendingsync++; +# unless ( (scalar @::syncqueue) > 4 ) { +# ASM::Util->dprint("Syncing $chan", "sync"); +# $conn->sl('who ' . $chan . ' %tcnuhra,314'); +# $conn->sl('mode ' . $chan); +# $conn->sl('mode ' . $chan . ' bq'); +# } +# push @::syncqueue, $chan; } $::sc{$chan}{users}{$nick} = {}; $::sc{$chan}{users}{$nick}{hostmask} = $event->{userhost}; @@ -421,6 +424,7 @@ sub blah { my ($self, $event) = @_; ASM::Util->dprint(Dumper($event), 'misc'); + return if ($event->{nick} =~ /\./); $::inspector->inspect($self, $event); } @@ -640,6 +644,7 @@ sub whoGotHit sub on_mode { my ($conn, $event) = @_; + return if ($event->{nick} =~ /\./); #if I ever want to track what modes ASM has on itself, this will have to die my $chan = lc $event->{to}->[0]; # holy shit, I feel so bad doing this # I have no idea how or why Net::IRC fucks up modes if they've got a ':' in one of the args @@ -829,13 +834,19 @@ sub on_whoxreply sub on_whoxover { my ($conn, $event) = @_; - my $chan = pop @::syncqueue; + $::pendingsync--; $::synced{lc $event->{args}->[1]} = 1; + if ($event->{args}->[1] ~~ @::syncqueue) { + my @diff = (lc $event->{args}->[1]); + @::syncqueue = array_diff(@::syncqueue, @diff); + } + my $chan = pop @::syncqueue; if (defined($chan) ){ + ASM::Util->dprint("Syncing $chan", "sync"); $conn->sl('who ' . $chan . ' %tcnuhra,314'); $conn->sl('mode ' . $chan); - $conn->sl('mode ' . $chan . ' bq'); - } else { + $conn->sl('mode ' . $chan . ' b'); + } elsif ($::pendingsync == 0) { my $size = `ps -p $$ h -o size`; my $cputime = `ps -p $$ h -o time`; chomp $size; chomp $cputime; @@ -862,6 +873,15 @@ sub on_whoxover if (scalar (keys %x)) { $conn->privmsg($::settings->{masterchan}, "Syncing appears to have failed for " . ASM::Util->commaAndify(keys %x)) unless $::no_autojoins; } + # There are some odd undefined values getting made somewhere, this is a nice way of fixing it + foreach my $nick (keys %::sn) { + if ( !defined($::sn{$nick}->{mship}) ) { + $::sn{$nick}->{mship} = []; + } + if (!defined($::sn{$nick}->{host})) { + $::sn{$nick}->{host} = ""; + } + } } } diff --git a/lib/ASM/Services.pm b/lib/ASM/Services.pm index f88ddac..7cbf1ff 100644 --- a/lib/ASM/Services.pm +++ b/lib/ASM/Services.pm @@ -38,7 +38,14 @@ sub doServices { $conn->join(join(',', @autojoins)); } $conn->sl("PING :" . time); - $conn->schedule(2, sub { $conn->privmsg($::settings->{masterchan}, 'Now joined to all channels in '. (time - $::starttime) . " seconds."); }); + foreach my $chan (@autojoins[0..1]) { + ASM::Util->dprint("Syncing $chan", "sync"); + $conn->sl('who ' . $chan . ' %tcnuhra,314'); + $conn->sl('mode ' . $chan); + $conn->sl('mode ' . $chan . ' b'); + } + @::syncqueue = @autojoins[1..$#autojoins]; +# $conn->schedule(2, sub { $conn->privmsg($::settings->{masterchan}, 'Now joined to all channels in '. (time - $::starttime) . " seconds."); }); } elsif ($event->{args}->[0] =~ /has been (killed|released)/ ) { |
