Changeset d264c6d for perl/modules/IRC


Ignore:
Timestamp:
Jul 24, 2008, 1:55:35 AM (16 years ago)
Author:
Geoffrey Thomas <geofft@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
4789b17
Parents:
38cfdb5d
Message:
IRC: Support for displaying :irc-whois replies, and various bugfixes.
Location:
perl/modules/IRC/lib/BarnOwl/Module
Files:
2 edited

Legend:

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

    r3ad15ff rd264c6d  
    263263    my $conn = get_connection(\@_);
    264264    my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");
     265    $conn->names_tmp([]);
    265266    $conn->conn->names($chan);
    266267}
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r38cfdb5d rd264c6d  
    4545    $self->motd("");
    4646    $self->connected(0);
    47     $self->names_tmp([]);
     47    $self->names_tmp(0);
    4848    $self->whois_tmp("");
    4949
     
    7171    $self->conn->add_handler(namreply  => sub { shift; $self->on_namreply(@_) });
    7272    $self->conn->add_handler(endofnames=> sub { shift; $self->on_endofnames(@_) });
     73    $self->conn->add_handler(endofwhois=> sub { shift; $self->on_endofwhois(@_) });
    7374
    7475    return $self;
     
    132133            BarnOwl::Style::boldify('IRC ' . $evt->type . ' message from '
    133134                . $self->alias) . "\n"
    134             . strip_irc_formatting(join '\n', $evt->args));
     135            . strip_irc_formatting(join ' ', cdr($evt->args)));
    135136}
    136137
     
    164165        loginout   => 'login',
    165166        channel    => $evt->to,
    166         replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick,
     167        replycmd => 'irc-msg -a ' . $self->alias . ' ' . join(' ', $evt->to),
    167168        replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick
    168169        );
     
    175176        loginout   => 'logout',
    176177        channel    => $evt->to,
    177         replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick,
     178        replycmd => 'irc-msg -a ' . $self->alias . ' ' . join(' ', $evt->to),
    178179        replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick
    179180        );
     
    218219}
    219220
     221# IRC gives us a bunch of namreply messages, followed by an endofnames.
     222# We need to collect them from the namreply and wait for the endofnames message.
     223# After this happens, the names_tmp variable is cleared.
     224
     225sub on_namreply {
     226    my ($self, $evt) = @_;
     227    return unless $self->names_tmp;
     228    $self->names_tmp([@{$self->names_tmp}, split(' ', [$evt->args]->[3])]);
     229}
     230
     231sub on_endofnames {
     232    my ($self, $evt) = @_;
     233    return unless $self->names_tmp;
     234    my $names = BarnOwl::Style::boldify("Members of " . [$evt->args]->[1] . ":\n");
     235    for my $name (@{$self->names_tmp}) {
     236        $names .= "  $name\n";
     237    }
     238    BarnOwl::popless_ztext($names);
     239    $self->names_tmp(0);
     240}
     241
     242sub on_whois {
     243    my ($self, $evt) = @_;
     244    $self->whois_tmp(
     245      $self->whois_tmp . "\n" . $evt->type . ":\n  " .
     246      join("\n  ", cdr(cdr($evt->args))) . "\n"
     247    );
     248}
     249
     250sub on_endofwhois {
     251    my ($self, $evt) = @_;
     252    BarnOwl::popless_ztext(
     253        BarnOwl::Style::boldify("/whois for " . [$evt->args]->[1] . ":\n") .
     254        $self->whois_tmp
     255    );
     256    $self->whois_tmp([]);
     257}
     258
    220259sub on_event {
    221260    my ($self, $evt) = @_;
     261    return on_whois(@_) if ($evt->type =~ /^whois/);
    222262    BarnOwl::admin_message("IRC",
    223263            "[" . $self->alias . "] Unhandled IRC event of type " . $evt->type . ":\n"
    224264            . strip_irc_formatting(join("\n", $evt->args)))
    225265        if BarnOwl::getvar('irc:spew') eq 'on';
    226 }
    227 
    228 # IRC gives us a bunch of namreply messages, followed by an endofnames.
    229 # We need to collect them from the namreply and wait for the endofnames message.
    230 # After this happens, the names_tmp variable is cleared.
    231 
    232 sub on_namreply {
    233     my ($self, $evt) = @_;
    234     $self->names_tmp([@{$self->names_tmp}, split(' ', [$evt->args]->[3])]);
    235 }
    236 
    237 sub on_endofnames {
    238     my ($self, $evt) = @_;
    239     my $names = BarnOwl::Style::boldify("Members of " . [$evt->args]->[1] . ":\n");
    240     for my $name (@{$self->names_tmp}) {
    241         $names .= "  $name\n";
    242     }
    243     BarnOwl::popless_ztext($names);
    244     $self->names_tmp([]);
    245266}
    246267
Note: See TracChangeset for help on using the changeset viewer.