source: perl/modules/AIM/lib/BarnOwl/Module/AIM.pm @ 403198c

barnowl_perlaim
Last change on this file since 403198c was 403198c, checked in by Geoffrey Thomas <geofft@mit.edu>, 13 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
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
18our @oscars;
19
20sub 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
31sub cmd_aimlogin { 
32=comment
33    my ($cmd, $user, $pass) = @_;
34    if (!defined $user) {
35        BarnOwl::start_question('Username: ', sub {
36                cmd_aimlogin($cmd, @_);
37                });
38    } elsif (!defined $pass) {
39        BarnOwl::start_password('Password: ', sub {
40                cmd_aimlogin($cmd, $user, @_);
41                });
42    } else {
43=cut
44    {
45        my $oscar = Net::OSCAR->new();
46        my ($user, $pass) = ('...', '...');
47        $oscar->set_callback_im_in(\&on_im_in);
48        $oscar->signon(
49                screenname => $user,
50                password => $pass
51                );
52        push @oscars, $oscar;
53    }
54}
55BarnOwl::new_command(aimlogin => \&cmd_aimlogin, {});
56
57sub main_loop {
58    for my $oscar (@oscars) {
59        $oscar->do_one_loop();
60    }
61}
62$BarnOwl::Hooks::mainLoop->add(\&main_loop);
63
641;
65
66# vim: set sw=4 et cin:
Note: See TracBrowser for help on using the repository browser.