source: lib/BarnOwl/Message/Twitter.pm @ 159aaad

release-1.7release-1.8release-1.9
Last change on this file since 159aaad was 159aaad, checked in by Nelson Elhage <nelhage@mit.edu>, 12 years ago
Multiple account support Accounts are specified as a list of hashes in the ~/.owl/twitter file. Adds 'poll_for_tweets', 'poll_for_dms', 'publish_tweets', 'default_sender', and 'account_nickname' options to the twitter account hashes. They do about what they say on the tin. Add arguments to :twitter, :twitter-direct, and :twitter-atreply to specify the service to use (by nickname), with sane defaults, plus documentation.
  • Property mode set to 100644
File size: 1.3 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 long_sender {
20    my $self = shift;
21    $self->service =~ m#^\s*(.*?://.*?)/.*$#;
22    my $service = $1 || $self->service;
23    return $service . '/' . $self->sender
24}
25
26sub replycmd {
27    my $self = shift;
28    if($self->is_private) {
29        return $self->replysendercmd;
30    } elsif(exists($self->{status_id})) {
31        return 'twitter-atreply ' . $self->sender . " " . $self->{status_id} . " " . $self->account;
32    } else {
33        return 'twitter-atreply ' . $self->sender . " " . $self->account;
34    }
35}
36
37sub replysendercmd {
38    my $self = shift;
39    return 'twitter-direct ' . $self->sender . " " . $self->account;
40}
41
42sub smartfilter {
43    my $self = shift;
44    my $inst = shift;
45    my $filter;
46
47    if($inst) {
48        $filter = "twitter-" . $self->sender;
49        BarnOwl::command("filter", $filter,
50                         qw{type ^twitter$ and sender}, '^'.$self->sender.'$');
51    } else {
52        $filter = "twitter";
53    }
54    return $filter;
55}
56
57=head1 SEE ALSO
58
59Foo, Bar, Baz
60
61=cut
62
631;
Note: See TracBrowser for help on using the repository browser.