Changeset 3ad15ff for perl/modules/IRC


Ignore:
Timestamp:
Jul 23, 2008, 8:18:30 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:
38cfdb5d
Parents:
0398d55
Message:
IRC: Add :irc-topic support and on_topic/on_topicinfo callbacks.
Location:
perl/modules/IRC/lib/BarnOwl/Module
Files:
2 edited

Legend:

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

    rf094fc4 r3ad15ff  
    117117    BarnOwl::new_command('irc-who'        => \&cmd_who);
    118118    BarnOwl::new_command('irc-stats'      => \&cmd_stats);
     119    BarnOwl::new_command('irc-topic'      => \&cmd_topic);
    119120}
    120121
     
    301302}
    302303
     304sub cmd_topic {
     305    my $cmd = shift;
     306    my $conn = get_connection(\@_);
     307    $conn->conn->topic(@_);
     308}
     309
    303310################################################################################
    304311########################### Utilities/Helpers ##################################
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r3835ae8 r3ad15ff  
    6565    $self->conn->add_handler(nicknameinuse => sub { shift; $self->on_nickinuse(@_) });
    6666    $self->conn->add_handler(cping     => sub { shift; $self->on_ping(@_) });
     67    $self->conn->add_handler(topic     => sub { shift; $self->on_topic(@_) });
     68    $self->conn->add_handler(topicinfo => sub { shift; $self->on_topicinfo(@_) });
    6769
    6870    return $self;
     
    193195}
    194196
     197sub on_topic {
     198    my ($self, $evt) = @_;
     199    my @args = $evt->args;
     200    if (scalar @args > 1) {
     201        BarnOwl::admin_message("IRC",
     202                "Topic for $args[1] on " . $self->alias . " is $args[2]");
     203    } else {
     204        BarnOwl::admin_message("IRC",
     205                "Topic changed to $args[0]");
     206    }
     207}
     208
     209sub on_topicinfo {
     210    my ($self, $evt) = @_;
     211    my @args = $evt->args;
     212    BarnOwl::admin_message("IRC",
     213        "Topic for $args[1] set by $args[2] at " . localtime($args[3]));
     214}
     215
    195216sub on_event {
    196217    my ($self, $evt) = @_;
Note: See TracChangeset for help on using the changeset viewer.