Changeset 38cfdb5d


Ignore:
Timestamp:
Jul 23, 2008, 9:05:18 PM (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:
d264c6d
Parents:
3ad15ff
Message:
IRC: Add proper display for the :irc-names reply.
File:
1 edited

Legend:

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

    r3ad15ff r38cfdb5d  
    1818
    1919use base qw(Class::Accessor Exporter);
    20 __PACKAGE__->mk_accessors(qw(conn alias channels connected motd));
     20__PACKAGE__->mk_accessors(qw(conn alias channels connected motd names_tmp whois_tmp));
    2121our @EXPORT_OK = qw(&is_private);
    2222
     
    4545    $self->motd("");
    4646    $self->connected(0);
     47    $self->names_tmp([]);
     48    $self->whois_tmp("");
    4749
    4850    $self->conn->add_handler(376 => sub { shift; $self->on_connect(@_) });
     
    6769    $self->conn->add_handler(topic     => sub { shift; $self->on_topic(@_) });
    6870    $self->conn->add_handler(topicinfo => sub { shift; $self->on_topicinfo(@_) });
     71    $self->conn->add_handler(namreply  => sub { shift; $self->on_namreply(@_) });
     72    $self->conn->add_handler(endofnames=> sub { shift; $self->on_endofnames(@_) });
    6973
    7074    return $self;
     
    222226}
    223227
     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
     232sub on_namreply {
     233    my ($self, $evt) = @_;
     234    $self->names_tmp([@{$self->names_tmp}, split(' ', [$evt->args]->[3])]);
     235}
     236
     237sub 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([]);
     245}
    224246
    225247################################################################################
Note: See TracChangeset for help on using the changeset viewer.