source: perl/modules/Twitter/lib/BarnOwl/Message/Twitter.pm

release-1.7release-1.8release-1.9
Last change on this file was 8106870, checked in by Anders Kaseorg <andersk@mit.edu>, 10 years ago
Twitter: BarnOwl::quote the replycmd Signed-off-by: Anders Kaseorg <andersk@mit.edu> Reviewed-by: Nelson Elhage <nelhage@mit.edu>
  • Property mode set to 100644
File size: 1.4 KB
Line 
1use warnings;
2use strict;
3
4=head1 NAME
5
6BarnOwl::Message::Twitter
7
8=head1 DESCRIPTION
9
10=cut
11
12package BarnOwl::Message::Twitter;
13use base qw(BarnOwl::Message);
14
15sub context {'twitter'}
16sub subcontext {undef}
17sub service { return (shift->{"service"} || "http://twitter.com"); }
18sub account { return shift->{"account"}; }
19sub retweeted_by { shift->{retweeted_by}; }
20sub long_sender {
21    my $self = shift;
22    $self->service =~ m#^\s*(.*?://.*?)/.*$#;
23    my $service = $1 || $self->service;
24    my $long = $service . '/' . $self->sender;
25    if ($self->retweeted_by) {
26        $long = "(retweeted by " . $self->retweeted_by . ") $long";
27    }
28    return $long;
29}
30
31sub replycmd {
32    my $self = shift;
33    if($self->is_private) {
34        return $self->replysendercmd;
35    } elsif(exists($self->{status_id})) {
36        return BarnOwl::quote('twitter-atreply', $self->sender, $self->{status_id}, $self->account);
37    } else {
38        return BarnOwl::quote('twitter-atreply', $self->sender, $self->account);
39    }
40}
41
42sub replysendercmd {
43    my $self = shift;
44    return BarnOwl::quote('twitter-direct', $self->sender, $self->account);
45}
46
47sub smartfilter {
48    my $self = shift;
49    my $inst = shift;
50    my $filter;
51
52    if($inst) {
53        $filter = "twitter-" . $self->sender;
54        BarnOwl::command("filter", $filter,
55                         qw{type ^twitter$ and sender}, '^'.$self->sender.'$');
56    } else {
57        $filter = "twitter";
58    }
59    return $filter;
60}
61
621;
Note: See TracBrowser for help on using the repository browser.