Mercurial > pidgin
comparison plugins/PERL-HOWTO @ 2345:a49e8f1afbc4
[gaim-migrate @ 2358]
you say potato, i say potato
you say tomato, i say tomato
potato, potato
tomato, tomato
let's call the whole thing off.
*sigh*. it just doesn't work as well when it's typed. but you wouldn't want to hear me sing it.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Sat, 22 Sep 2001 09:14:27 +0000 |
| parents | e243bf60f2d6 |
| children | 571971659533 |
comparison
equal
deleted
inserted
replaced
| 2344:19ea44f74a88 | 2345:a49e8f1afbc4 |
|---|---|
| 17 plugins. | 17 plugins. |
| 18 | 18 |
| 19 There's a really quick simple perl script in this directory, gaim.pl, that | 19 There's a really quick simple perl script in this directory, gaim.pl, that |
| 20 should show most of the functions. Most things should be self-explanatory. | 20 should show most of the functions. Most things should be self-explanatory. |
| 21 | 21 |
| 22 There's one thing you need to be aware of in perl scripts for gaim. Gaim | |
| 23 supports multiple connections, and perl deals with them by using a unique | |
| 24 identifier for each of them (that's a fancy way of saying that perl scripts | |
| 25 use the memory address of the connection). | |
| 26 | |
| 22 Everything available in normal perl scripts should be available in gaim's | 27 Everything available in normal perl scripts should be available in gaim's |
| 23 perl interface, so I'm not going to bother describing that. The important | 28 perl interface, so I'm not going to bother describing that. The important |
| 24 things are the functions provided by gaim's internal GAIM module, which is | 29 things are the functions provided by gaim's internal GAIM module, which is |
| 25 what most of this document is about. So, onto the functions. | 30 what most of this document is about. So, onto the functions. |
| 26 | 31 |
| 32 | 37 |
| 33 GAIM::get_info(integer, ...) | 38 GAIM::get_info(integer, ...) |
| 34 This function returns different information based on the integer passed | 39 This function returns different information based on the integer passed |
| 35 to it. | 40 to it. |
| 36 0 - the version of gaim you're running ("0.10.0" for example). | 41 0 - the version of gaim you're running ("0.10.0" for example). |
| 37 1 - the list of currently online screennames | 42 1 - the list of connection ids |
| 38 2 - given a screenname, the protocol(s) it(/they) use(s) (as ints) | 43 2 - given a connection index, the protocol it uses (as an int) |
| 44 3 - given a connection index, the screenname of the person | |
| 45 4 - given a connection index, the index in the users list | |
| 46 5 - the list of names of users | |
| 47 6 - the list of protocols of the users | |
| 39 | 48 |
| 40 GAIM::print(title, message) | 49 GAIM::print(title, message) |
| 41 This displays a nice little dialog window. | 50 This displays a nice little dialog window. |
| 42 | 51 |
| 43 | 52 |
| 44 GAIM::buddy_list(name) | 53 GAIM::buddy_list(index) |
| 45 This returns the buddy list (no groups, just the names of the buddies) | 54 This returns the buddy list (no groups, just the names of the buddies) |
| 46 for the specified account | 55 for the specified connection. |
| 47 | 56 |
| 48 GAIM::online_list(name) | 57 GAIM::online_list(index) |
| 49 This returns the list of online buddies for the specified account. | 58 This returns the list of online buddies for the specified connection. |
| 50 | 59 |
| 51 | 60 |
| 52 GAIM::command(command, ...) | 61 GAIM::command(command, ...) |
| 53 This sends commands to the server, and each command takes various | 62 This sends commands to the server, and each command takes various |
| 54 arguments. The command should be self-explanatory: | 63 arguments. The command should be self-explanatory: |
| 55 "signon" - the second arg is the screenname to sign on | 64 "signon" - the second arg is the index of the user to sign on |
| 56 "signoff" - the optional second arg is who to sign off. if no args are | 65 "signoff" - the optional second arg is the connection index to sign off. |
| 57 given, all names are signed off. | 66 if no args are given, all connections are signed off. |
| 58 "away" - the second arg is the away message | 67 "away" - the second arg is the away message |
| 59 "back" - no args. | 68 "back" - no args. |
| 60 "idle" - the second arg is how long (in seconds) to set the idle time | 69 "idle" - the second arg is how long (in seconds) to set the idle time |
| 61 (this sets the idle time for all connections) | 70 (this sets the idle time for all connections) |
| 62 "warn" - the second arg is the name of the person to warn. this is | 71 "warn" - the second arg is the name of the person to warn. this is |
| 63 especially evil since it warns the person from every | 72 especially evil since it warns the person from every |
| 64 connection. The third argument is 1 if you want to warn | 73 connection. The third argument is 1 if you want to warn |
| 65 anonymously. If 0 or ommitted, it will warn normally. | 74 anonymously. If 0 or ommitted, it will warn normally. |
| 66 "info" - the second arg is what you want to set your profile to. | 75 "info" - the second arg is the connection index whose info you want to set, |
| 76 and the third arg is what you want to set your profile to. | |
| 67 | 77 |
| 68 GAIM::user_info(nick) | 78 GAIM::user_info(index, nick) |
| 69 Returns 8 data items: | 79 Returns 8 data items: |
| 70 the screenname of the buddy | 80 the screenname of the buddy |
| 71 the alias of the buddy | 81 the alias of the buddy |
| 72 "Online" or "Offline" | 82 "Online" or "Offline" |
| 73 their warning level | 83 their warning level |
| 94 message-style and works like that: | 104 message-style and works like that: |
| 95 wflags==0: display message as if received by <who> | 105 wflags==0: display message as if received by <who> |
| 96 wflags==1: display message as if sent by <who> | 106 wflags==1: display message as if sent by <who> |
| 97 wflags==2: display system message | 107 wflags==2: display system message |
| 98 | 108 |
| 99 GAIM::print_to_conv(who, what, auto) | 109 GAIM::serv_send_im(index, who, what, auto) |
| 100 The question is not what does this do, it's who does this do it as. The | 110 Sends what from the connection index to who. :) |
| 101 answer is "whatever the default is". It uses whichever connection is | |
| 102 selected in the conversation window's menu. If the conversation window | |
| 103 didn't exist beforehand, then it's the default (first) connection. If | |
| 104 auto is one, it will send as an auto (read: away) message. If 0 or | |
| 105 ommitted, it will send normally. | |
| 106 | 111 |
| 107 GAIM::print_to_chat(room, what) | 112 GAIM::print_to_conv(index, who, what, auto) |
| 108 This goes through each connection. If it finds a room matching the name, | 113 Convenience function; combination of write_to_conv and serv_send_im. |
| 109 it'll print the message to that room. | |
| 110 | 114 |
| 111 GAIM::serv_send_im(who, what, auto) | 115 GAIM::print_to_chat(index, room, what) |
| 112 Same as print_to_conv, but it does not display the message. | 116 Room is actually an int. Read SIGNALS to find out why. |
| 113 | 117 |
| 114 GAIM::add_event_handler(event, function) | 118 GAIM::add_event_handler(event, function) |
| 115 This is the most important of them all. This is basically exactly like | 119 This is the most important of them all. This is basically exactly like |
| 116 gaim_signal_connect for plugins. You pass which event you want to connect to | 120 gaim_signal_connect for plugins. You pass which event you want to connect to |
| 117 (a string with the same name as the events for plugins, see SIGNALS), and a | 121 (a string with the same name as the events for plugins, see SIGNALS), and a |
