Ignore:
File:
1 edited

Legend:

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

    r0e52069 rb38b0b2  
    1515=cut
    1616
    17 use base qw(Net::IRC::Connection Class::Accessor Exporter);
     17use base qw(Net::IRC::Connection Class::Accessor);
    1818__PACKAGE__->mk_accessors(qw(alias channels));
    19 our @EXPORT_OK = qw(&is_private);
    2019
    2120use BarnOwl;
     
    3130    bless($self, $class);
    3231
    33     $self->add_global_handler(376 => sub { goto &on_connect });
    34     $self->add_global_handler(['msg', 'notice', 'public', 'caction'],
    35             sub { goto &on_msg });
    36     $self->add_global_handler(cping => sub { goto &on_ping });
     32    $self->add_global_handler(endofmotd => sub { goto &on_connect });
     33    $self->add_global_handler(msg => sub { goto &on_msg });
     34    $self->add_global_handler(notice => sub { goto &on_msg });
    3735    $self->add_default_handler(sub { goto &on_event; });
    3836
     
    5149sub on_msg {
    5250    my ($self, $evt) = @_;
    53     my ($recipient) = $evt->to;
    54     my $body = strip_irc_formatting([$evt->args]->[0]);
    55     $body = BarnOwl::Style::boldify($evt->nick.' '.$body) if $evt->type eq 'caction';
     51    my $replycmd = "irc-msg " . $evt->nick;
    5652    my $msg = BarnOwl::Message->new(
    5753        type        => 'IRC',
     
    5955        server      => $self->server,
    6056        network     => $self->alias,
    61         recipient   => $recipient,
    62         body        => $body,
     57        recipient   => $self->nick,
     58        body        => strip_irc_formatting([$evt->args]->[0]),
    6359        sender      => $evt->nick,
    6460        hostname    => $evt->host,
    6561        from        => $evt->from,
    66         $evt->type eq 'notice' ?
    67           (notice     => 'true') : (),
    68         is_private($recipient) ?
    69           (isprivate  => 'true') : (channel => $recipient),
    70         replycmd    => 'irc-msg ' .
    71             (is_private($recipient) ? $evt->nick : $recipient),
    72         replysendercmd => 'irc-msg ' . $evt->nick,
     62        notice      => $evt->type eq 'notice' ? 'true' : '',
     63        isprivate   => 'true',
     64        replycmd    => $replycmd,
     65        replysendercmd => $replycmd
    7366       );
    7467    BarnOwl::queue_message($msg);
    75 }
    76 
    77 sub on_ping {
    78     my ($self, $evt) = @_;
    79     $self->ctcp_reply($evt->nick, join (' ', ($evt->args)));
    80 }
    81 
    82 sub on_event {
    83     my ($self, $evt) = @_;
    84     BarnOwl::admin_message("IRC",
    85             "Unhandled IRC event of type " . $evt->type . ":\n"
    86             . strip_irc_formatting(join("\n", $evt->args)))
    87         if BarnOwl::getvar('irc:spew') eq 'on';
    8868}
    8969
     
    10383}
    10484
    105 # Determines if the given message recipient is a username, as opposed to
    106 # a channel that starts with # or &.
    107 sub is_private {
    108     return shift !~ /^[\#\&]/;
    109 }
    11085
    111861;
Note: See TracChangeset for help on using the changeset viewer.