Changeset 9e02bb7 for perl/modules/IRC


Ignore:
Timestamp:
Jan 11, 2008, 1:38:50 AM (16 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
fe8cad8, 61abb18
Parents:
b0c8011
Message:
Handle `nickinuse' errors and disconnects
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r214b790 r9e02bb7  
    3232    bless($self, $class);
    3333
    34     $self->add_global_handler(376 => sub { goto &on_connect });
    35     $self->add_global_handler(['msg', 'notice', 'public', 'caction'],
     34    $self->add_default_handler(sub { goto &on_event; });
     35    $self->add_handler(376 => sub { goto &on_connect });
     36    $self->add_handler(['msg', 'notice', 'public', 'caction'],
    3637            sub { goto &on_msg });
    37     $self->add_global_handler(['welcome', 'yourhost', 'created',
     38    $self->add_handler(['welcome', 'yourhost', 'created',
    3839            'luserclient', 'luserop', 'luserchannels', 'luserme'],
    3940            sub { goto &on_admin_msg });
    40     $self->add_global_handler(['myinfo', 'map', 'n_local', 'n_global',
     41    $self->add_handler(['myinfo', 'map', 'n_local', 'n_global',
    4142            'luserconns'],
    4243            sub { });
    43     $self->add_handler(375 => sub { goto &on_motdstart });
    44     $self->add_handler(372 => sub { goto &on_motd });
    45     $self->add_handler(376 => sub { goto &on_endofmotd });
    46     $self->add_global_handler(cping => sub { goto &on_ping });
    47     $self->add_global_handler(join  => sub { goto &on_join });
    48     $self->add_global_handler(part  => sub { goto &on_part });
    49     $self->add_default_handler(sub { goto &on_event; });
     44    $self->add_handler(motdstart => sub { goto &on_motdstart });
     45    $self->add_handler(motd      => sub { goto &on_motd });
     46    $self->add_handler(endofmotd => sub { goto &on_endofmotd });
     47    $self->add_handler(join      => sub { goto &on_join });
     48    $self->add_handler(part      => sub { goto &on_part });
     49    $self->add_handler(disconnect => sub { goto &on_disconnect });
     50    $self->add_handler(nicknameinuse => sub { goto &on_nickinuse });
     51    $self->add_handler(cping     => sub { goto &on_ping });
    5052
    5153    return $self;
     
    147149}
    148150
     151sub on_disconnect {
     152    my $self = shift;
     153    delete $BarnOwl::Module::IRC::ircnets{$self->alias};
     154
     155    BarnOwl::admin_message('IRC',
     156                           "[" . $self->alias . "] Disconnected from server");
     157}
     158
     159sub on_nickinuse {
     160    my ($self, $evt) = @_;
     161    BarnOwl::admin_message("IRC",
     162                           "[" . $self->alias . "] " .
     163                           [$evt->args]->[1] . ": Nick already in use");
     164}
     165
    149166sub on_event {
    150167    my ($self, $evt) = @_;
     
    154171        if BarnOwl::getvar('irc:spew') eq 'on';
    155172}
     173
    156174
    157175################################################################################
Note: See TracChangeset for help on using the changeset viewer.