Ignore:
Timestamp:
Apr 3, 2011, 3:06:01 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
59425a3
Parents:
249bbbe
git-author:
Nelson Elhage <nelhage@mit.edu> (02/26/11 20:32:10)
git-committer:
Nelson Elhage <nelhage@mit.edu> (04/03/11 15:06:01)
Message:
Implement sending and receiving CTCP ACTIONs
File:
1 edited

Legend:

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

    r249bbbe r09bd74c  
    1717
    1818use AnyEvent::IRC::Client;
    19 use AnyEvent::IRC::Util qw(split_prefix prefix_nick);
     19use AnyEvent::IRC::Util qw(split_prefix prefix_nick encode_ctcp);
    2020
    2121use base qw(Class::Accessor);
     
    9292                        irc_403       => on("nosuch"),
    9393                        nick_change   => on("nick"),
     94                        ctcp_action   => on("ctcp_action"),
    9495                        'irc_*' => sub { BarnOwl::debug("IRC: " . $_[1]->{command}) });
    9596
     
    106107    my $self = shift;
    107108    return $self->conn->socket;
     109}
     110
     111sub me {
     112    my ($self, $to, $msg) = @_;
     113    $self->conn->send_msg('privmsg', $to,
     114                          encode_ctcp(['ACTION', $msg]))
    108115}
    109116
     
    130137    my ($self, $recipient, $evt) = @_;
    131138    my $body = strip_irc_formatting($evt->{params}->[1]);
    132 
     139    $self->handle_message($recipient, $evt, $body);
     140}
     141
     142sub on_ctcp_action {
     143    my ($self, $src, $target, $msg) = @_;
     144    my $body = strip_irc_formatting($msg);
     145    my $evt = {
     146        params => [$src],
     147        type   => 'privmsg',
     148        prefix => $src
     149       };
     150    $self->handle_message($target, $evt, "* $body");
     151}
     152
     153sub handle_message {
     154    my ($self, $recipient, $evt, $body) = @_;
    133155    my $msg = $self->new_message($evt,
    134156        direction   => 'in',
     
    147169}
    148170
     171
    149172sub on_admin_msg {
    150173    my ($self, $evt) = @_;
Note: See TracChangeset for help on using the changeset viewer.