diff options
| author | 2015-12-04 11:10:56 +0400 | |
|---|---|---|
| committer | 2015-12-04 11:10:56 +0400 | |
| commit | 9f74a4bf7bbe1695354a954e13912d74a4173b02 (patch) | |
| tree | 8d752896007dfa3e3e995b4b5d7aafe18af5482f /lib/ASM | |
| parent | 8573114bda2d6de4cf9360900b4d1e80f05db4b1 (diff) | |
Better services handling
Diffstat (limited to 'lib/ASM')
| -rw-r--r-- | lib/ASM/Event.pm | 17 | ||||
| -rw-r--r-- | lib/ASM/Services.pm | 11 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lib/ASM/Event.pm b/lib/ASM/Event.pm index f75ee42..f9ae609 100644 --- a/lib/ASM/Event.pm +++ b/lib/ASM/Event.pm @@ -75,6 +75,7 @@ sub new $conn->add_handler('channelurlis', \&on_channelurlis); $conn->add_handler('480', \&on_jointhrottled); $conn->add_handler('invite', \&blah); # This doesn't need to be fancy; I just need it to go through inspect + $conn->add_handler('servicesdown', \&on_servicesdown); bless($self); return $self; } @@ -230,7 +231,9 @@ sub on_connect { $conn->sl("MODE $event->{args}->[0] +Q"); if (lc $event->{args}->[0] ne lc $::settings->{nick}) { ASM::Util->dprint('Attempting to regain my main nick', 'startup'); - $conn->privmsg( 'NickServ@services.', "regain $::settings->{nick} $::settings->{pass}" ); + $conn->sl("NickServ regain $::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 } @@ -861,7 +864,7 @@ sub on_whoxover foreach my $c (@{$::settings->{autojoins}}) { $x{$c} = 1; } foreach my $cx (keys %::sc) { delete $x{$cx}; } if (scalar (keys %x)) { - $conn->privmsg($::settings->{masterchan}, "Syncing appears to have failed for " . ASM::Util->commaAndify(keys %x)); + $conn->privmsg($::settings->{masterchan}, "Syncing appears to have failed for " . ASM::Util->commaAndify(keys %x)) unless $::no_autojoins; } } } @@ -890,4 +893,14 @@ sub on_byechan { #TODO do del event stuff } +sub on_servicesdown +{ + my ($conn, $event) = @_; + if ($event->{args}->[1] eq 'NickServ') { + $::no_autojoins = 1; + $conn->join($::settings->{masterchan}); # always join masterchan, so we can find you + $conn->sl("PING :" . time); + } +} + return 1; diff --git a/lib/ASM/Services.pm b/lib/ASM/Services.pm index 528901d..2d4beb6 100644 --- a/lib/ASM/Services.pm +++ b/lib/ASM/Services.pm @@ -18,9 +18,10 @@ sub doServices { if ($event->{from} eq 'NickServ!NickServ@services.') { ASM::Util->dprint("NickServ: $event->{args}->[0]", 'snotice'); - if ( $event->{args}->[0] =~ /^This nickname is registered/ ) + if ( $::no_autojoins && $event->{args}->[0] =~ /^Please identify/ ) { - $conn->privmsg( 'NickServ@services.', "identify $::settings->{nick} $::settings->{pass}" ); + $::no_autojoins = 0; + $conn->sl("NickServ identify $::settings->{nick} $::settings->{pass}" ); } elsif ( $event->{args}->[0] =~ /^You are now identified/ ) { @@ -52,6 +53,12 @@ sub doServices { { die("NickServ password invalid.") } + elsif ($event->{args}->[0] =~ /frozen/ ) + { + $::no_autojoins = 1; + $conn->join($::settings->{masterchan}); # always join masterchan, so we can find you + $conn->sl("PING :" . time); + } } elsif ($event->{from} eq 'ChanServ!ChanServ@services.') { |
