annotate plugins/PERL-HOWTO @ 781:95ebfdb31a9b

[gaim-migrate @ 791] arg committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 29 Aug 2000 04:02:10 +0000
parents c4c4a18bb2f9
children dc9ad68fc30e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
750
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 This is really the wrong place for a HOWTO on writing perl scripts for gaim,
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 but there didn't seem to be a much better place.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 If you've ever written a perl script for X-Chat then you've basically written
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 one for gaim as well. perl.c in gaim's source is basically an exact copy of
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 X-Chat's perl.c file, with small modifications to suit AIM rather than IRC.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 Basically the reason for including perl is based on the experience with the
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 plugins. X-Chat's docs on Perl Scripting sums it up nicely:
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 it's not quite as simple to stick a module together in C and make it
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 stable compared to the development time of perl code
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 Plugins are more powerful as they can directly access gaim's functions and
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 variables; as such they should be used for things like modifying the UI or
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 when something takes quite a bit of trickery not offered by perl. But for
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 the most part things should be written in Perl. It's more stable than
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 plugins.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 Right now, the only way to test that your script is working correctly is to
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 load the perl plugin and load the script through that. Though, right now
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 there really isn't much point in writing a script, since the two major
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 functions in the AIM module (message_handler and command_handler) haven't
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 been implemented yet.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 Everything available in normal perl scripts should be available in gaim's
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 perl interface, so I'm not going to bother describing that. The important
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 things are the functions provided by gaim's internal AIM module, which is
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 what most of this document is about. So, onto the functions.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 AIM::register(name, version, shutdownroutine, unused)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 Just like X-Chat. This is the first function your script should call.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 shutdownroutine is a function that will be called when the script
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 gets unloaded (like when gaim gets closed). This function returns
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 gaim's version number.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 AIM::get_info(integer)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 This function returns different information based on the integer passed
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 to it.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 0 - the version of gaim you're running ("0.10.0" for example).
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 1 - the screenname to last attempt to sign on
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 2 - either "Offline", "TOC", or "Oscar"
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 AIM::print(title, message)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 This displays a nice little dialog window.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 AIM::buddy_list()
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 This returns the buddy list (no groups, just the names of the buddies)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 AIM::online_list()
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 This returns the list of online buddies.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 AIM::deny_list()
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 This returns the deny list. This is probably going to be modified before
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 0.10.0 is released to return either the deny or the permit list and the
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 current mode.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 AIM::command(command, ...)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 This sends commands to the server, and each command takes various
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 arguments. The command should be self-explanatory:
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 "signon" - no args.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 "signoff" - no args.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 "away" - the second arg is the away message
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 "back" - no args.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 "idle" - the second arg is how long (in seconds) to set the idle time
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 "warn" - the second arg is the name of the person to warn
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 AIM::user_info(nick)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 Returns 7 data items:
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 the screenname of the buddy
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 "Online" or "Offline"
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 their warning level
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 signon time, in seconds since the epoch
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 idle time, in seconds (?)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 user class, an integer with bit values
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 AOL 1
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 ADMIN 2
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 UNCONFIRMED 4
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 NORMAL 8
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 AWAY 16
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 their capabilites, an integer with bit values
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 BUDDYICON 1
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 VOICE 2
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 IMIMAGE 4
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 CHAT 8
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 GETFILE 16
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 SENDFILE 32
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 This is probably going to change before 0.10.0 is released to
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 also return the alias of the buddy.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 AIM::print_to_conv(who, what)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 This should be obvious. If you can't figure this out on your own, you
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 shouldn't be using a computer.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 AIM::print_to_chat(room, what)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 This should be just as obvious as the last command.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 AIM::add_message_handler
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 This actually hasn't been implemented yet, so don't worry about it
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 AIM::add_command_handler
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 This hasn't been implemented yet either. Pay no attention.
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 AIM::add_timeout_handler(integer, function)
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 This calls function after integer number of seconds. It only calls function
c4c4a18bb2f9 [gaim-migrate @ 760]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 once, so if you want to keep calling function, keep reading the handler.