Changeset 3baf77f for perl/modules


Ignore:
Timestamp:
Jan 13, 2008, 6:10:44 PM (17 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:
e4db5ae
Parents:
1fd5041b
Message:
'motd' is a method of Net::IRC::Connection, don't clobber it
File:
1 edited

Legend:

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

    r9e02bb7 r3baf77f  
    1616
    1717use base qw(Net::IRC::Connection Class::Accessor Exporter);
    18 __PACKAGE__->mk_accessors(qw(alias channels motd));
     18__PACKAGE__->mk_accessors(qw(alias channels connected _motd));
    1919our @EXPORT_OK = qw(&is_private);
    2020
     
    2929    $self->alias($alias);
    3030    $self->channels([]);
    31     $self->motd("");
     31    $self->_motd("");
     32    $self->connected(0);
    3233    bless($self, $class);
    3334
    3435    $self->add_default_handler(sub { goto &on_event; });
    35     $self->add_handler(376 => sub { goto &on_connect });
    3636    $self->add_handler(['msg', 'notice', 'public', 'caction'],
    3737            sub { goto &on_msg });
     
    5757############################### IRC callbacks ##################################
    5858################################################################################
    59 
    60 sub on_connect {
    61     my ($self, $evt) = @_;
    62     BarnOwl::admin_message("IRC", "Connected to " . $self->server . " (" . $self->alias . ")");
    63 }
    6459
    6560sub new_message {
     
    115110sub on_motdstart {
    116111    my ($self, $evt) = @_;
    117     $self->motd(join "\n", cdr $evt->args);
     112    $self->_motd(join "\n", cdr $evt->args);
    118113}
    119114
    120115sub on_motd {
    121116    my ($self, $evt) = @_;
    122     $self->motd(join "\n", $self->motd, cdr $evt->args);
     117    $self->_motd(join "\n", $self->_motd, cdr $evt->args);
    123118}
    124119
    125120sub on_endofmotd {
    126121    my ($self, $evt) = @_;
    127     $self->motd(join "\n", $self->motd, cdr $evt->args);
    128     BarnOwl::admin_message("IRC",
    129             BarnOwl::Style::boldify('MOTD for ' . $evt->alias) . "\n"
    130             . strip_irc_formatting($self->motd));
     122    $self->_motd(join "\n", $self->_motd, cdr $evt->args);
     123    if(!$self->connected) {
     124        BarnOwl::admin_message("IRC", "Connected to " .
     125                               $self->server . " (" . $self->alias . ")");
     126        $self->connected(1);
     127       
     128    }
     129    BarnOwl::admin_message("IRC",
     130            BarnOwl::Style::boldify('MOTD for ' . $self->alias) . "\n"
     131            . strip_irc_formatting($self->_motd));
    131132}
    132133
Note: See TracChangeset for help on using the changeset viewer.