barnowl_perlaim
Last change
on this file since 403198c was
403198c,
checked in by Geoffrey Thomas <geofft@mit.edu>, 16 years ago
|
Proof-of-concept AIM client. Maybe less than a proof. Lemma-of-concept.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[7a1c90d] | 1 | use warnings; |
---|
| 2 | use strict; |
---|
| 3 | |
---|
| 4 | =head1 NAME |
---|
| 5 | |
---|
| 6 | BarnOwl::Module::AIM |
---|
| 7 | |
---|
| 8 | =head1 DESCRIPTION |
---|
| 9 | |
---|
| 10 | BarnOwl module implementing AIM support via Net::OSCAR |
---|
| 11 | |
---|
| 12 | =cut |
---|
| 13 | |
---|
| 14 | package BarnOwl::Module::AIM; |
---|
| 15 | |
---|
| 16 | use Net::OSCAR; |
---|
| 17 | |
---|
[403198c] | 18 | our @oscars; |
---|
| 19 | |
---|
| 20 | sub on_im_in { |
---|
| 21 | my ($oscar, $sender, $message, $is_away) = @_; |
---|
| 22 | my $msg = BarnOwl::Message->new( |
---|
| 23 | type => 'AIM', |
---|
| 24 | sender => $sender, |
---|
| 25 | body => $message, |
---|
| 26 | away => $is_away, |
---|
| 27 | ); |
---|
| 28 | BarnOwl::queue_message($msg); |
---|
| 29 | } |
---|
| 30 | |
---|
[7a1c90d] | 31 | sub cmd_aimlogin { |
---|
[403198c] | 32 | =comment |
---|
[7a1c90d] | 33 | my ($cmd, $user, $pass) = @_; |
---|
[403198c] | 34 | if (!defined $user) { |
---|
[7a1c90d] | 35 | BarnOwl::start_question('Username: ', sub { |
---|
| 36 | cmd_aimlogin($cmd, @_); |
---|
| 37 | }); |
---|
[403198c] | 38 | } elsif (!defined $pass) { |
---|
[7a1c90d] | 39 | BarnOwl::start_password('Password: ', sub { |
---|
| 40 | cmd_aimlogin($cmd, $user, @_); |
---|
| 41 | }); |
---|
| 42 | } else { |
---|
[403198c] | 43 | =cut |
---|
| 44 | { |
---|
[5fcf137] | 45 | my $oscar = Net::OSCAR->new(); |
---|
[403198c] | 46 | my ($user, $pass) = ('...', '...'); |
---|
[7a1c90d] | 47 | $oscar->set_callback_im_in(\&on_im_in); |
---|
[403198c] | 48 | $oscar->signon( |
---|
| 49 | screenname => $user, |
---|
| 50 | password => $pass |
---|
| 51 | ); |
---|
| 52 | push @oscars, $oscar; |
---|
[7a1c90d] | 53 | } |
---|
| 54 | } |
---|
[403198c] | 55 | BarnOwl::new_command(aimlogin => \&cmd_aimlogin, {}); |
---|
[7a1c90d] | 56 | |
---|
[403198c] | 57 | sub main_loop { |
---|
| 58 | for my $oscar (@oscars) { |
---|
| 59 | $oscar->do_one_loop(); |
---|
| 60 | } |
---|
[7a1c90d] | 61 | } |
---|
[403198c] | 62 | $BarnOwl::Hooks::mainLoop->add(\&main_loop); |
---|
[5fcf137] | 63 | |
---|
| 64 | 1; |
---|
[403198c] | 65 | |
---|
| 66 | # vim: set sw=4 et cin: |
---|
Note: See
TracBrowser
for help on using the repository browser.