Changeset 47b6a5f for perl


Ignore:
Timestamp:
Jan 10, 2008, 12:12:52 AM (13 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
2fb58e4
Parents:
6858d2d
Message:
Show PART and JOIN messages
File:
1 edited

Legend:

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

    r0e52069 r47b6a5f  
    3535            sub { goto &on_msg });
    3636    $self->add_global_handler(cping => sub { goto &on_ping });
     37    $self->add_global_handler(join  => sub { goto &on_join });
     38    $self->add_global_handler(part  => sub { goto &on_part });
    3739    $self->add_default_handler(sub { goto &on_event; });
    3840
     
    4951}
    5052
     53sub new_message {
     54    my $self = shift;
     55    my $evt = shift;
     56    return BarnOwl::Message->new(
     57        type        => 'IRC',
     58        server      => $self->server,
     59        network     => $self->alias,
     60        sender      => $evt->nick,
     61        hostname    => $evt->host,
     62        from        => $evt->from,
     63        @_
     64       );
     65}
     66
    5167sub on_msg {
    5268    my ($self, $evt) = @_;
     
    5470    my $body = strip_irc_formatting([$evt->args]->[0]);
    5571    $body = BarnOwl::Style::boldify($evt->nick.' '.$body) if $evt->type eq 'caction';
    56     my $msg = BarnOwl::Message->new(
    57         type        => 'IRC',
     72    my $msg = $self->new_message($evt,
    5873        direction   => 'in',
    59         server      => $self->server,
    60         network     => $self->alias,
    6174        recipient   => $recipient,
    62         body        => $body,
    63         sender      => $evt->nick,
    64         hostname    => $evt->host,
    65         from        => $evt->from,
     75        body => $body,
    6676        $evt->type eq 'notice' ?
    6777          (notice     => 'true') : (),
     
    7080        replycmd    => 'irc-msg ' .
    7181            (is_private($recipient) ? $evt->nick : $recipient),
    72         replysendercmd => 'irc-msg ' . $evt->nick,
     82        replysendercmd => 'irc-msg ' . $evt->nick
    7383       );
     84
    7485    BarnOwl::queue_message($msg);
    7586}
     
    8091}
    8192
     93sub on_join {
     94    my ($self, $evt) = @_;
     95    my $msg = $self->new_message($evt,
     96        loginout   => 'login',
     97        channel    => $evt->to,
     98        );
     99    BarnOwl::queue_message($msg);
     100}
     101
     102sub on_part {
     103    my ($self, $evt) = @_;
     104    my $msg = $self->new_message($evt,
     105        loginout   => 'logout',
     106        channel    => $evt->to,
     107        );
     108    BarnOwl::queue_message($msg);
     109}
     110
    82111sub on_event {
    83112    my ($self, $evt) = @_;
    84113    BarnOwl::admin_message("IRC",
    85             "Unhandled IRC event of type " . $evt->type . ":\n"
     114            "[" . $self->alias . "] Unhandled IRC event of type " . $evt->type . ":\n"
    86115            . strip_irc_formatting(join("\n", $evt->args)))
    87116        if BarnOwl::getvar('irc:spew') eq 'on';
Note: See TracChangeset for help on using the changeset viewer.