source: perl/modules/IRC/lib/BarnOwl/Message/IRC.pm @ 744769e

release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 744769e was e04b7a1, checked in by Alex Dehnert <adehnert@mit.edu>, 16 years ago
Add short_personal_context to IRC This is thoroughly untested --- it doesn't crash my BarnOwl, but I don't think my BarnOwl loads this code... Somebody who actually uses IRC should confirm this doesn't break anything. Also supports Jabber and AIM, insofaras the "right" thing to do for them is probably nothing.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1use warnings;
2use strict;
3
4=head1 NAME
5
6BarnOwl::Message::IRC
7
8=head1 DESCRIPTION
9
10A subclass of BarnOwl::Message for IRC messages
11
12=cut
13
14package BarnOwl::Message::IRC;
15
16use base qw( BarnOwl::Message );
17
18sub smartfilter {
19    my $self = shift;
20    my $inst = shift;
21
22    my $filter;
23    my @filter;
24
25    if($self->is_private) {
26        my $who;
27        if($self->direction eq 'out') {
28            $who = $self->recipient;
29        } else {
30            $who = $self->sender;
31        }
32        $filter = "irc-user-$who";
33        @filter  =
34             (qw{( type ^irc$ and filter personal and },
35              qw{( ( direction ^in$ and sender}, "^\Q$who\E\$",
36              qw{ ) or ( direction ^out$ and recipient}, "^\Q$who\E\$",
37              qw{) ) ) });
38        BarnOwl::command("filter", "$filter", @filter);
39        return $filter;
40    } else {
41        # To a Channel
42        my $network = $self->network;
43        my $channel = $self->channel;
44        my $sender = $self->sender;
45        my ($filter, $ftext);
46        if ($inst && $self->body =~ /^(\S+):/) {
47            $filter = "irc-$network-channel-$channel-$sender-$1";
48            @filter =
49                 (qw{type ^irc$ and network}, "^\Q$network\E\$",
50                  qw{and channel}, "^\Q$channel\E\$",
51                  qw{and ( sender}, "^\Q$sender\E\$",
52                  qw{or sender}, "^\Q$1\E\$",qq{)});
53        } else {
54            $filter = "irc-$network-channel-$channel";
55            @filter = (qw{type ^irc$ and network}, "^\Q$network\E\$",
56                       qw{and channel}, "^\Q$channel\E\$");
57        }
58        BarnOwl::command("filter", "$filter", @filter);
59        return $filter;
60    }
61}
62
63sub server {shift->{server}}
64sub network {shift->{network}}
65sub channel {shift->{channel}}
66sub action {shift->{action}}
67sub reason {shift->{reason}}
68
69# display
70sub context {shift->{network};}
71sub subcontext {shift->{recipient};}
72sub personal_context {"on " . shift->{network};}
73sub short_personal_context { shift->{network};}
74
75sub long_sender {shift->{from} || ""};
76
77sub login_type {
78    my $self = shift;
79    return " (" . uc $self->action . ")";
80}
81
82sub login_extra { 
83    my $self = shift;
84    if ($self->action eq "quit") {
85        return $self->reason;
86    } else {
87        return $self->channel;
88    }
89}
90
911;
Note: See TracBrowser for help on using the repository browser.