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