source: perl/lib/BarnOwl/Complete/AIM.pm @ 5b483a6

release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 5b483a6 was 5b483a6, checked in by Nelson Elhage <nelhage@mit.edu>, 12 years ago
Add minimal completion for 'aimwrite'.
  • Property mode set to 100644
File size: 630 bytes
Line 
1use strict;
2use warnings;
3
4package BarnOwl::Complete::AIM;
5
6our %users;
7
8sub complete_user { keys %users }
9
10sub canonicalize_aim {
11    my $who = shift;
12    $who =~ s{ }{}g;
13    return lc $who;
14}
15
16sub complete_aimwrite {
17    my $ctx = shift;
18    return unless $ctx->word == 1;
19    return complete_user();
20}
21
22sub on_message {
23    my $m = shift;
24    return unless $m->type eq 'AIM';
25    $users{canonicalize_aim($m->sender)} = 1;
26    $users{canonicalize_aim($m->recipient)} = 1;
27}
28
29BarnOwl::Completion::register_completer(aimwrite => \&complete_aimwrite);
30
31$BarnOwl::Hooks::newMessage->add("BarnOwl::Complete::AIM::on_message");
32
33
341;
Note: See TracBrowser for help on using the repository browser.