source: perl/modules/AIM/lib/BarnOwl/Module/AIM.pm @ 5fcf137

barnowl_perlaim
Last change on this file since 5fcf137 was 5fcf137, checked in by Geoffrey Thomas <geofft@mit.edu>, 13 years ago
Potential fix to Net::OSCAR to make it deal with coderefs in @INC
  • Property mode set to 100644
File size: 1007 bytes
Line 
1use warnings;
2use strict;
3
4=head1 NAME
5
6BarnOwl::Module::AIM
7
8=head1 DESCRIPTION
9
10BarnOwl module implementing AIM support via Net::OSCAR
11
12=cut
13
14package BarnOwl::Module::AIM; 
15
16use Net::OSCAR;
17
18sub cmd_aimlogin { 
19    my ($cmd, $user, $pass) = @_;
20    if (undef $user) {
21        BarnOwl::start_question('Username: ', sub {
22                cmd_aimlogin($cmd, @_);
23                });
24    } elsif (undef $pass) {
25        BarnOwl::start_password('Password: ', sub {
26                cmd_aimlogin($cmd, $user, @_);
27                });
28    } else {
29        my $oscar = Net::OSCAR->new();
30        $oscar->set_callback_im_in(\&on_im_in);
31        $oscar->signon($user, $pass);
32    }
33}
34
35sub on_im_in {
36    my ($oscar, $sender, $message, $is_away) = @_;
37    my $msg = BarnOwl::Message->new(
38            type => 'AIM',
39            sender => $sender,
40            body => $message,
41            away => $is_away,
42            );
43    BarnOwl::queue_message($msg);
44}
45
46BarnOwl::new_command(aimlogin => \&cmd_aimlogin, {});
47
481;
Note: See TracBrowser for help on using the repository browser.