diff options
-rw-r--r-- | doc/weechat_doc_en.texi | 837 | ||||
-rw-r--r-- | doc/weechat_doc_es.texi | 877 | ||||
-rw-r--r-- | doc/weechat_doc_fr.texi | 854 | ||||
-rw-r--r-- | doc/weechat_doc_pt.texi | 838 | ||||
-rw-r--r-- | weechat/doc/weechat_doc_en.texi | 837 | ||||
-rw-r--r-- | weechat/doc/weechat_doc_es.texi | 877 | ||||
-rw-r--r-- | weechat/doc/weechat_doc_fr.texi | 854 | ||||
-rw-r--r-- | weechat/doc/weechat_doc_pt.texi | 838 |
8 files changed, 6328 insertions, 484 deletions
diff --git a/doc/weechat_doc_en.texi b/doc/weechat_doc_en.texi index d93e8397d..f9a43e874 100644 --- a/doc/weechat_doc_en.texi +++ b/doc/weechat_doc_en.texi @@ -35,7 +35,7 @@ @title WeeChat - User guide @subtitle Fast, light and extensible IRC client -@subtitle Documentation for WeeChat v0.1.6-cvs - October, 02 2005 +@subtitle Documentation for WeeChat v0.1.6-cvs - October, 17 2005 @author FlashCode <@email{flashcode@@flashtux.org, flashcode AT flashtux.org}> @@ -64,7 +64,7 @@ version 2 or higher. * Introduction:: What is WeeChat ? * Installation:: WeeChat installation * Usage:: WeeChat usage -* Extensions:: WeeChat extensions +* Plugins:: WeeChat plugins * Authors / Support:: Contact authors and get support @end menu @@ -199,7 +199,7 @@ Then follow instructions for source package - @xref{Source package}. @c ********************************** Usage *********************************** -@node Usage, Extensions, Installation, Top +@node Usage, Plugins, Installation, Top @chapter Usage @menu @@ -429,7 +429,7 @@ Color for input text (nick name)@* Type: color (Curses or Gtk color), default value: 'lightcyan'@* @item col_input_delimiters Color for input text (delimiters)@* -Type: color (Curses or Gtk color), default value: 'cyan'@* +Type: color (Curses or Gtk color), default value: 'lightgreen'@* @item col_input_bg Background for input window@* Type: color (Curses or Gtk color), default value: 'default'@* @@ -628,6 +628,15 @@ Type: string (any string), default value: ''@* @item proxy_password Password for proxy server@* Type: string (any string), default value: ''@* +@item plugins_path +Path for searching plugins@* +Type: string (any string), default value: '~/.weechat/plugins'@* +@item plugins_autoload +Comma separated list of plugins to load automatically at startup, "*" means all plugins found (names may be partial, for example "perl" is ok for "libperl.so")@* +Type: string (any string), default value: '*'@* +@item plugins_extension +Standard plugins extension in filename, used for autoload (if empty, then all files are loaded when autoload is "*")@* +Type: string (any string), default value: '.so'@* @item server_name Name associated to IRC server (for display only)@* Type: string (any string), default value: ''@* @@ -906,29 +915,13 @@ unbind: unbind a key (if "all", default bindings are restored)@* functions: list internal functions for key bindings@* reset: restore bindings to the default values and delete ALL personal binding (use carefully!)@* @* -@item perl [load filename] | [autoload] | [reload] | [unload] -@* -list/load/unload Perl scripts@* -@* -filename: Perl script (file) to load@* -@* -Without argument, /perl command lists all loaded Perl scripts.@* -@* -@item python [load filename] | [autoload] | [reload] | [unload] +@item plugin [load filename] | [autoload] | [reload] | [unload] @* -list/load/unload Python scripts@* +list/load/unload plugins@* @* -filename: Python script (file) to load@* +filename: WeeChat plugin (file) to load@* @* -Without argument, /python command lists all loaded Python scripts.@* -@* -@item ruby [load filename] | [autoload] | [reload] | [unload] -@* -list/load/unload Ruby scripts@* -@* -filename: Ruby script (file) to load@* -@* -Without argument, /ruby command lists all loaded Ruby scripts.@* +Without argument, /plugin command lists all loaded plugins.@* @* @item server [servername] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [del servername] @* @@ -1152,6 +1145,7 @@ channel modes:@* m: moderated channel@* l: set the user limit to channel@* b: set a ban mask to keep users out@* + e: set exception mask@* v: give/take the ability to speak on a moderated channel@* k: set a channel key (password)@* user modes:@* @@ -1499,21 +1493,613 @@ If the script is called "auto_weechat_command", you can run it with:@* @command{./auto_weechat_command "freenode,#weechat *hello"} -@c ******************************* Extensions ********************************* +@c ******************************** Plugins *********************************** -@node Extensions, Authors / Support, Usage, Top -@chapter Extensions +@node Plugins, Authors / Support, Usage, Top +@chapter Plugins @menu -* Perl scripts:: -* Python scripts:: -* Ruby scripts:: +* Plugins in WeeChat:: +* Write a plugin:: +* Plugin example:: +* Scripts plugins:: @end menu -@node Perl scripts, Python scripts, Extensions, Extensions -@section Perl scripts +@node Plugins in WeeChat, Write a plugin, Plugins, Plugins +@section Plugins in WeeChat + +A plugin is a C program which can call WeeChat functions defined in an +interface.@* +@* +This C program does not need WeeChat sources to compile and can be +dynamically loaded into WeeChat with command @command{/plugin}.@* +@* +The plugin has to be a dynamic library, for dynamic loading by +operating system. +Under GNU/Linux, the file has ``.so'' extension. + +@node Write a plugin, Plugin example, Plugins in WeeChat, Plugins +@section Write a plugin + +@subsection Base rules + +The plugin should include ``weechat-plugin.h'' file (available in +WeeChat source code).@* +This file defines structures and types used to communicate with WeeChat.@* +@* +The plugin must have some variables and functions (mandatory, without +them the plugin can't load):@* +@itemize @bullet +@item variables for plugin description: +@itemize @minus +@item plugin_name[]: plugin name +@item plugin_version[]: plugin version +@item plugin_description[]: short description of plugin +@end itemize +@item functions for init and end of plugin: +@itemize @minus +@item weechat_plugin_init: function called when plugin is loaded +@item weechat_plugin_end: function called when plugin is unloaded +@end itemize +@end itemize + +@subsection API functions + +The plugin can call some functions defined in t_weechat_plugin structure.@* +These functions are detailed below: + +@itemize @bullet +@item +@command{int ascii_strcasecmp (t_weechat_plugin *plugin, +char *string1, char *string2)}@* +@* +locale and case independent string comparison.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string1}: first string for comparison +@item @option{string2}: second string for comparison +@end itemize +@* +@emph{Return value:}@* +@* +Difference between two strings: negative if chaine1 < chaine2, +nul if chaine1 == chaine 2, positive if chaine1 > chaine2@* +@* +@emph{Example:}@* +@* +@code{if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...}@* + +@* + +@item +@command{char **explode_string (t_weechat_plugin *plugin, +char *string, char *separators, int num_items_max, int *num_items)}@* +@* +Explode a string according to one or more delimiter(s).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string to explode +@item @option{separators}: delimiters used for explosion +@item @option{num_items_max}: maximum number of items created (0 means +no limit) +@item @option{num_items}: pointer to int which will contain number of +items created +@end itemize +@* +@emph{Return value:}@* +@* +Array of strings, NULL if problem.@* +Note: the result has to be free by a call to ``free_exploded_string'' +function after use.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{char **free_exploded_string (t_weechat_plugin *plugin, +char **string)}@* +@* +Free memory used by a string explosion.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string exploded by ``explode_string'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{void exec_on_files (t_weechat_plugin *plugin, char *directory, +int (*callback)(t_weechat_plugin *, char *))}@* +@* +Execute a function on all files of a directory.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{directory}: directory for searching files +@item @option{callback}: function called for each file found +@end itemize +@* +@emph{Return value:}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{int callback (t_weechat_plugin *plugin, char *file)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "file: %s", file);}@* +@code{@ @ @ @ return 1;}@* +@code{@}}@* +@code{}@* +@code{...}@* +@code{plugin->exec_on_files (plugin, "/tmp", &callback);}@* +@* + +@item +@command{void printf (t_weechat_plugin *plugin, +char *server, char *channel, char *message, ...)}@* +@* +Display a message on a WeeChat buffer, identified by server and +channel (both may be NULL).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server to find buffer for message +display (may be NULL) +@item @option{channel}: name of channel to find buffer for message +display (may be NULL) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->printf (NULL, NULL, "hello");}@* +@code{plugin->printf (NULL, "#weechat", "hello");}@* +@code{plugin->printf ("freenode", "#weechat", "hello");}@* +@* + +@item +@command{void printf_server (t_weechat_plugin *plugin, +char *message, ...)}@* +@* +Display a message on server buffer.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_server ("hello");}@* +@* + +@item +@command{void printf_infobar (t_weechat_plugin *plugin, +int time, char *message, ...)}@* +@* +Display a message in infobar for a specified time.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{time}: time in seconds for displaying message (0 means +never erased) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_infobar (5, "hello");}@* +@* + +@item +@command{t_plugin_msg_handler *msg_handler_add (t_weechat_plugin +*plugin, char *message, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add an IRC message handler, called when an IRC message is received.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: IRC message (for example: ``PRIVMSG'') +@item @option{handler_func}: function called when message is received +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new message handler.@* +@* +@emph{Example:}@* +@* +@code{int msg_kick (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "KICK received");}@* +@code{@}}@* +@code{...}@* +@code{plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);}@* +@* + +@item +@command{void msg_handler_remove (t_weechat_plugin *plugin, +t_plugin_msg_handler *msg_handler)}@* +@* +Remove an IRC message handler.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{msg_handler}: handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove (plugin, my_msg_handler);}@* +@* + +@item +@command{void msg_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all IRC message handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove_all (plugin);}@* +@* + +@item +@command{t_plugin_cmd_handler *cmd_handler_add (t_weechat_plugin +*plugin, char *command, char *description, char *arguments, +char *arguments_description, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add a WeeChat command handler, called when user uses command +(for example /command).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{commande}: the new command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) +@item @option{handler_func}: function called when comand is executed +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new command handler.@* +@* +@emph{Example:}@* +@* +@code{int cmd_test (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "test command, +file: %s", (arguments) ? arguments : "none");}@* +@code{@}}@* +@code{...}@* +@code{plugin->cmd_handler_add (plugin, "test", "Test command", +"[file]", "file: a file name", &cmd_test, NULL, NULL);}@* +@* + +@item +@command{void cmd_handler_remove (t_weechat_plugin *plugin, +t_plugin_cmd_handler *cmd_handler)}@* +@* +Remove a command handler.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{cmd_handler}: command handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->cmd_handler_remove (plugin, my_cmd_handler);}@* +@* + +@item +@command{void cmd_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all command handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example :}@* +@* +@code{plugin->cmd_handler_remove_all (plugin);}@* +@* + +@item +@command{void exec_command (t_weechat_plugin +*plugin, char *server, char *channel, char *command)}@* +@* +Execute a WeeChat command (or send a message to a channel).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server for executing command (may be +NULL) +@item @option{channel}: name of channel for executing command (may be +NULL) +@item @option{command}: command +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->exec_command (plugin, NULL, NULL, "/help nick");}@* +@code{plugin->exec_command (plugin, "freenode", "#weechat", "hello");}@* +@* + +@item +@command{char *get_info (t_weechat_plugin +*plugin, char *info, char *server, char *channel)}@* +@* +Return an info about WeeChat or a channel.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{info}: name of info to read: +@itemize @minus +@item @option{version}: get WeeChat's version +@item @option{nick}: get nick +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir +@end itemize +@item @option{server}: name of server for reading info (if needed) +@item @option{channel}: name of channel for reading info (if needed) +@end itemize +@* +@emph{Return value:}@* +@* +Information asked, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *version = plugin->get_info (plugin, "version", NULL, NULL);}@* +@code{char *nick = plugin->get_info (plugin, "nick", "freenode", NULL);}@* +@* + +@item +@command{t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin)}@* +@* +Returns list of DCC currently active or finished.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +Chained list of DCC.@* +Note: result has to be free by a call to ``free_dcc_info'' function +after use.@* +@* +@emph{Example:}@* +@* +@code{t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin);}@* +@code{for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = +ptr_dcc->next_dcc)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "DCC type=%d, with: %s", +ptr_dcc->type, ptr_dcc->nick);}@* +@code{@}}@* +@* -@subsection Load/unload Perl scripts +@item +@command{void free_dcc_info (t_weechat_plugin *plugin, +t_plugin_dcc_info *dcc_info)}@* +@* +Free memory used by a DCC list.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{dcc_info}: pointer to DCC list returned by +``get_dcc_info'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->free_dcc_info (plugin, dcc_info);}@* +@* + +@item +@command{char *get_config (t_weechat_plugin +*plugin, char *option)}@* +@* +Return value of a WeeChat config option.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{option}: name of option to read +@end itemize +@* +@emph{Return value:}@* +@* +Value of option, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *value1 = plugin->get_config (plugin, "look_set_title");}@* +@code{char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Compile plugin + +Compile does not need WeeChat sources, only file +``weechat-plugin.h''.@* + +To compile a plugin which has one file ``toto.c'' (sous GNU/Linux):@* +@* +gcc -fPIC -Wall -c toto.c@* +gcc -shared -fPIC -o libtoto.so toto.o + +@subsection Load plugin under WeeChat + +Copy ``libtoto.so'' file into general plugins dir (for example +/usr/local/lib/weechat/plugins) or into user's plugins dir (for +example /home/xxxxx/.weechat/plugins).@* +@* +Under WeeChat:@* +@command{/plugin load toto} + +@node Plugin example, Scripts plugins, Write a plugin, Plugins +@section Plugin example + +Full example of plugin, which adds a /double command, which displays +two times arguments on current channel (ok that's not very useful, but +that's just an example!): + +@verbatim +#include <stdlib.h> + +#include "weechat-plugin.h" + +char plugin_name[] = "Toto"; +char plugin_version[] = "0.1"; +char plugin_description[] = "Test plugin for WeeChat"; + +/* gestionnaire de commande "/hello" */ + +int toto_cmd_double (t_weechat_plugin *plugin, char *server, + char *command, char *arguments, + char *handler_args, void *handler_pointer) +{ + if (arguments && arguments[0] && (arguments[0] != '/')) + { + plugin->exec_command (plugin, NULL, NULL, arguments); + plugin->exec_command (plugin, NULL, NULL, arguments); + } + return 1; +} + +int weechat_plugin_init (t_weechat_plugin *plugin) +{ + plugin->cmd_handler_add (plugin, "double", + "Display two times a message", + "msg", + "msg: message", + &toto_cmd_double, + NULL, NULL); + return 1; +} + +int weechat_plugin_end (t_weechat_plugin *plugin) +{ + /* on ne fait rien ici */ + return 1; +} +@end verbatim + +@node Scripts plugins, , Plugin example, Plugins +@section Scripts plugins + +Three plugins are provided with WeeChat to use script languages: Perl, +Python and Ruby. + +@subsection Perl scripts + +@subsubsection Load/unload Perl scripts Perl scripts are loaded and unloaded with @command{/perl} command. (type @kbd{/help perl} within WeeChat to get help about command).@* @@ -1528,7 +2114,7 @@ Unload all Perl scripts: @kbd{/perl unload}@* List all Perl scripts: @kbd{/perl}@* @end itemize -@subsection WeeChat / Perl API +@subsubsection WeeChat / Perl API @itemize @bullet @item @@ -1548,6 +2134,7 @@ unloaded (optional parameter, empty string means nothing is called at the end) @end itemize @* @emph{Example:}@* +@* @code{weechat::register ("sample", "1.0", "sample_end", "Sample script!");}@* @* @@ -1564,6 +2151,7 @@ Print message in a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat::print ("message");}@* @code{weechat::print ("message", "#weechat");}@* @code{weechat::print ("message", "#weechat", "freenode");}@* @@ -1582,6 +2170,7 @@ Print message in infobar.@* @end itemize @* @emph{Example:}@* +@* @code{weechat::print_infobar (5, "message");}@* @* @@ -1601,6 +2190,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Example:}@* +@* @code{weechat::add_message_handler ("privmsg", my_function);}@* @code{sub my_function}@* @code{@{ }@* @@ -1624,9 +2214,16 @@ This name may be existing command, so that the command is overrided by Perl function. Be careful when overriding WeeChat commands, they'll not be available until your Perl script will be unloaded. @item @option{function}: Perl function linked with command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Example:}@* +@* @code{weechat::add_command_handler ("command", my_command);}@* @code{sub my_command}@* @code{@{ }@* @@ -1648,6 +2245,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat::command ("hello world!");}@* @code{weechat::command ("/kick toto please leave this chan", "#weechat");}@* @code{weechat::command ("/nick newnick", "", "freenode");}@* @@ -1661,28 +2259,86 @@ Get various info about WeeChat, server or user.@* @emph{Arguments:} @itemize @minus @item @option{name}: name of info to retrieve: +@itemize @minus +@item @option{version}: get WeeChat version +@item @option{nick}: get nickname +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir + +@end itemize @item @option{server}: internal name of server +@end itemize +@* +@emph{Examples:}@* +@* +@code{$version = weechat::get_info("version");}@* +@code{$nick = weechat::get_info("nick", "freenode");}@* +@* + +@item +@command{weechat::get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: @itemize @minus -@item @option{0 or version}: get WeeChat version -@item @option{1 or nick}: get nickname -@item @option{2 or channel}: get channel name -@item @option{3 or server}: get server name -@item @option{4 or weechatdir}: get WeeChat home directory -@item @option{5 or away}: get away flag for server +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) @end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat::get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option @end itemize @* @emph{Examples:}@* -@code{$version = get_info("version");}@* -@code{$nick = get_info("nick", "freenode");}@* +@* +@code{$value1 = weechat::get_config ("look_set_title");}@* +@code{$value2 = weechat::get_config ("freenode.server_autojoin");}@* @* @end itemize -@node Python scripts, Ruby scripts, Perl scripts, Extensions -@section Python scripts +@subsection Python scripts -@subsection Load/unload Python scripts +@subsubsection Load/unload Python scripts Python scripts are loaded and unloaded with @command{/python} command. (type @kbd{/help python} within WeeChat to get help about command).@* @@ -1697,7 +2353,7 @@ Unload all Python scripts: @kbd{/python unload}@* List all Python scripts: @kbd{/python}@* @end itemize -@subsection WeeChat / Python API +@subsubsection WeeChat / Python API @itemize @bullet @item @@ -1717,6 +2373,7 @@ unloaded (optional parameter, empty string means nothing is called at the end) @end itemize @* @emph{Example:}@* +@* @code{weechat.register ("sample", "1.0", "sample_end", "Sample script!")}@* @* @@ -1733,6 +2390,7 @@ Print message in a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat.prnt ("message")}@* @code{weechat.prnt ("message", "#weechat")}@* @code{weechat.prnt ("message", "#weechat", "freenode")}@* @@ -1751,6 +2409,7 @@ Print message in infobar.@* @end itemize @* @emph{Example:}@* +@* @code{weechat.print_infobar (5, "message")}@* @* @@ -1770,6 +2429,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Example:}@* +@* @code{weechat.add_message_handler ("privmsg", my_function)}@* @code{def my_function(server, args):}@* @code{@ @ @ @ weechat.prnt("server="+server)}@* @@ -1791,9 +2451,16 @@ This name may be existing command, so that the command is overrided by Python function. Be careful when overriding WeeChat commands, they'll not be available until your Python script will be unloaded. @item @option{function}: Python function linked with command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Example:}@* +@* @code{weechat.add_command_handler ("command", my_command)}@* @code{def my_command(server, args):}@* @code{@ @ @ @ weechat.prnt("server:"+server+" arguments:"+args)}@* @@ -1812,6 +2479,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat.command ("hello world!")}@* @code{weechat.command ("/kick toto please leave this chan", "#weechat")}@* @code{weechat.command ("/nick newnick", "", "freenode")}@* @@ -1826,33 +2494,90 @@ Get various info about WeeChat, server or user.@* @emph{Arguments:} @itemize @minus @item @option{name}: name of info to retrieve: -@item @option{server}: internal name of server @itemize @minus -@item @option{0 or version}: get WeeChat version -@item @option{1 or nick}: get nickname -@item @option{2 or channel}: get channel name -@item @option{3 or server}: get server name -@item @option{4 or weechatdir}: get WeeChat home directory -@item @option{5 or away}: get away flag for server +@item @option{version}: get WeeChat version +@item @option{nick}: get nickname +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{server}: internal name of server @end itemize @* @emph{Examples:}@* +@* @code{$version = weechat.get_info("version")}@* @code{$nick = weechat.get_info("nick", "freenode")}@* @* +@item +@command{weechat.get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) +@end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat.get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat.get_config ("look_set_title");}@* +@code{$value2 = weechat.get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Ruby scripts, , Python scripts, Extensions -@section Ruby scripts +@subsection Ruby scripts Not developed! @c **************************** Authors / Support ***************************** -@node Authors / Support, , Extensions, Top +@node Authors / Support, , Plugins, Top @chapter Authors / Support @ifhtml diff --git a/doc/weechat_doc_es.texi b/doc/weechat_doc_es.texi index df574373c..de0cd21fe 100644 --- a/doc/weechat_doc_es.texi +++ b/doc/weechat_doc_es.texi @@ -36,7 +36,7 @@ @title WeeChat - Gui@'on de usuario. @subtitle Cliente IRC r@'apido, peque@~no y extensible -@subtitle Documentaci@'on para WeeChat v0.1.6-cvs - 2 de octubre de 2005 +@subtitle Documentaci@'on para WeeChat v0.1.6-cvs - 17 de octubre de 2005 @author FlashCode <@email{flashcode@@flashtux.org, flashcode AT flashtux.org}> @@ -66,7 +66,7 @@ License versi@'on 2 o posterior. * Introduccion:: Presentaci@'on de WeeChat * Instalacion:: Instalaci@'on de WeeChat * Uso:: Utilizaci@'on de WeeChat -* Extensiones:: Extensiones de WeeChat +* Plugins:: WeeChat plugins * Autores / Soporte:: Contactar los autores y obtener soporte @end menu @@ -201,7 +201,7 @@ Luego, lee las instructiones para Paquetes de fuentes - @xref{Paquetes de fuente @c ******************************* Utilisaci@'on ******************************** -@node Uso, Extensiones, Instalacion, Top +@node Uso, Plugins, Instalacion, Top @chapter Uso @menu @@ -429,7 +429,7 @@ Color para el texto de entrada (alias)@* Typo: color (color Curses @'o Gtk), valor por defecto: 'lightcyan'@* @item col_input_delimiters Color for input text (delimiters)@* -Typo: color (color Curses @'o Gtk), valor por defecto: 'cyan'@* +Typo: color (color Curses @'o Gtk), valor por defecto: 'lightgreen'@* @item col_input_bg Color de fondo para la ventana de entrada@* Typo: color (color Curses @'o Gtk), valor por defecto: 'default'@* @@ -628,6 +628,15 @@ Typo: cadena (cualquier cadena), valor por defecto: ''@* @item proxy_password Contrase@~na para el servidor proxy@* Typo: cadena (cualquier cadena), valor por defecto: ''@* +@item plugins_path +Path for searching plugins@* +Typo: cadena (cualquier cadena), valor por defecto: '~/.weechat/plugins'@* +@item plugins_autoload +Comma separated list of plugins to load automatically at startup, "*" means all plugins found (names may be partial, for example "perl" is ok for "libperl.so")@* +Typo: cadena (cualquier cadena), valor por defecto: '*'@* +@item plugins_extension +Standard plugins extension in filename, used for autoload (if empty, then all files are loaded when autoload is "*")@* +Typo: cadena (cualquier cadena), valor por defecto: '.so'@* @item server_name Nombre asociado al servidor IRC (para mostrar solamente)@* Typo: cadena (cualquier cadena), valor por defecto: ''@* @@ -906,29 +915,13 @@ desatar: desata una clave(si "all", se restauran los anclajes por defecto)@* funciones: lista funciones internas para el anclaje de claves@* reset: restaura anclajes a los valores por defecto y elimina todos los anclajes personales (usar cuidadosamente)@* @* -@item perl [load fichero] | [autoload] | [reload] | [unload] -@* -lista/carga/descarga de los Perl scripts@* -@* -fichero: Perl script (archivo) a cargar@* -@* -Sin argumentos, el comando /perl lista todos los Perl scripts cargados.@* -@* -@item python [load fichero] | [autoload] | [reload] | [unload] +@item plugin [load fichero] | [autoload] | [reload] | [unload] @* -lista/carga/descarga de los Python scripts@* +list/load/unload plugins@* @* -fichero: Python script (archivo) a cargar@* +filename: WeeChat plugin (file) to load@* @* -Sin argumentos, el comando /python lista todos los Python scripts cargados.@* -@* -@item ruby [load fichero] | [autoload] | [reload] | [unload] -@* -lista/carga/descarga de los Ruby scripts@* -@* -fichero: Ruby script (archivo) a cargar@* -@* -Sin argumentos, el comando /ruby lista todos los Ruby scripts cargados.@* +Without argument, /plugin command lists all loaded plugins.@* @* @item server [nombre_de_servidor] | [nombre_de_servidor nombre/IP puerto [-auto | -noauto] [-ipv6] [-ssl] [-pwd contrase@~na] [-nicks alias1 alias2 alias3] [-username nombre de usuario] [-realname nombre_real] [-command comando] [-autojoin canal[,canal]] ] | [del nombre_de_servidor] @* @@ -1141,25 +1134,26 @@ mensaje: mensaje a enviar@* @* cambiar modo del canal o del usuario@* @* -modos del canal:@* - canal: nombre del canal a modificar@* - o: dar/coger privilegios de operador de canal@* - p: indicador de canal privado@* - s: indicador de canal secreto@* - i: indicador de canal s@'olo con invitaci@'on@* - t: indicador de tema s@'olo modificable por operador de canal@* - n: ningún mensaje al canal desde el exterior@* - m: canal moderado@* - l: fijar el l@'imite de usuarios para el canal@* - b: establecer una m@'ascara de baneo para mantener fuera a usuarios@* - v: dar/quitar la capacidad de hablar en un canal moderado@* - k: definir una clave (contrase@~na) de canal@* -modos de usuario:@* - usuario: usuario a modificar@* - i: marcar a un usuario como invisible@* - s: marcar a un usuario para recibir noticias del servidor@* - w: el usuario recibe golpes@* - o: indicador de operador@* +channel modes:@* + channel: channel name to modify@* + o: give/take channel operator privileges@* + p: private channel flag@* + s: secret channel flag@* + i: invite-only channel flag@* + t: topic settable by channel operator only flag@* + n: no messages to channel from clients on the outside@* + m: moderated channel@* + l: set the user limit to channel@* + b: set a ban mask to keep users out@* + e: set exception mask@* + v: give/take the ability to speak on a moderated channel@* + k: set a channel key (password)@* +user modes:@* + nickname: nickname to modify@* + i: mark a user as invisible@* + s: mark a user for receive server notices@* + w: user receives wallops@* + o: operator flag@* @* @item motd [target] @* @@ -1502,21 +1496,613 @@ Si el script se llama "auto_weechat_command", puedes ejecutarlo hac@'i:@* @command{./auto_weechat_command "freenode,#weechat *Hola"} -@c ******************************* Extensions ********************************* +@c ******************************** Plugins *********************************** -@node Extensiones, Autores / Soporte, Uso, Top -@chapter Extensiones +@node Plugins, Autores / Soporte, Uso, Top +@chapter Plugins @menu -* Programas Perl:: -* Programas Python:: -* Programas Ruby:: +* Plugins in WeeChat:: +* Write a plugin:: +* Plugin example:: +* Scripts plugins:: @end menu -@node Programas Perl, Programas Python, Extensiones, Extensiones -@section Programas Perl +@node Plugins in WeeChat, Write a plugin, Plugins, Plugins +@section Plugins in WeeChat + +A plugin is a C program which can call WeeChat functions defined in an +interface.@* +@* +This C program does not need WeeChat sources to compile and can be +dynamically loaded into WeeChat with command @command{/plugin}.@* +@* +The plugin has to be a dynamic library, for dynamic loading by +operating system. +Under GNU/Linux, the file has ``.so'' extension. + +@node Write a plugin, Plugin example, Plugins in WeeChat, Plugins +@section Write a plugin + +@subsection Base rules + +The plugin should include ``weechat-plugin.h'' file (available in +WeeChat source code).@* +This file defines structures and types used to communicate with WeeChat.@* +@* +The plugin must have some variables and functions (mandatory, without +them the plugin can't load):@* +@itemize @bullet +@item variables for plugin description: +@itemize @minus +@item plugin_name[]: plugin name +@item plugin_version[]: plugin version +@item plugin_description[]: short description of plugin +@end itemize +@item functions for init and end of plugin: +@itemize @minus +@item weechat_plugin_init: function called when plugin is loaded +@item weechat_plugin_end: function called when plugin is unloaded +@end itemize +@end itemize + +@subsection API functions + +The plugin can call some functions defined in t_weechat_plugin structure.@* +These functions are detailed below: + +@itemize @bullet +@item +@command{int ascii_strcasecmp (t_weechat_plugin *plugin, +char *string1, char *string2)}@* +@* +locale and case independent string comparison.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string1}: first string for comparison +@item @option{string2}: second string for comparison +@end itemize +@* +@emph{Return value:}@* +@* +Difference between two strings: negative if chaine1 < chaine2, +nul if chaine1 == chaine 2, positive if chaine1 > chaine2@* +@* +@emph{Example:}@* +@* +@code{if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...}@* + +@* + +@item +@command{char **explode_string (t_weechat_plugin *plugin, +char *string, char *separators, int num_items_max, int *num_items)}@* +@* +Explode a string according to one or more delimiter(s).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string to explode +@item @option{separators}: delimiters used for explosion +@item @option{num_items_max}: maximum number of items created (0 means +no limit) +@item @option{num_items}: pointer to int which will contain number of +items created +@end itemize +@* +@emph{Return value:}@* +@* +Array of strings, NULL if problem.@* +Note: the result has to be free by a call to ``free_exploded_string'' +function after use.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{char **free_exploded_string (t_weechat_plugin *plugin, +char **string)}@* +@* +Free memory used by a string explosion.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string exploded by ``explode_string'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{void exec_on_files (t_weechat_plugin *plugin, char *directory, +int (*callback)(t_weechat_plugin *, char *))}@* +@* +Execute a function on all files of a directory.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{directory}: directory for searching files +@item @option{callback}: function called for each file found +@end itemize +@* +@emph{Return value:}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{int callback (t_weechat_plugin *plugin, char *file)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "file: %s", file);}@* +@code{@ @ @ @ return 1;}@* +@code{@}}@* +@code{}@* +@code{...}@* +@code{plugin->exec_on_files (plugin, "/tmp", &callback);}@* +@* + +@item +@command{void printf (t_weechat_plugin *plugin, +char *server, char *channel, char *message, ...)}@* +@* +Display a message on a WeeChat buffer, identified by server and +channel (both may be NULL).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server to find buffer for message +display (may be NULL) +@item @option{channel}: name of channel to find buffer for message +display (may be NULL) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->printf (NULL, NULL, "hello");}@* +@code{plugin->printf (NULL, "#weechat", "hello");}@* +@code{plugin->printf ("freenode", "#weechat", "hello");}@* +@* + +@item +@command{void printf_server (t_weechat_plugin *plugin, +char *message, ...)}@* +@* +Display a message on server buffer.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_server ("hello");}@* +@* + +@item +@command{void printf_infobar (t_weechat_plugin *plugin, +int time, char *message, ...)}@* +@* +Display a message in infobar for a specified time.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{time}: time in seconds for displaying message (0 means +never erased) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_infobar (5, "hello");}@* +@* + +@item +@command{t_plugin_msg_handler *msg_handler_add (t_weechat_plugin +*plugin, char *message, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add an IRC message handler, called when an IRC message is received.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: IRC message (for example: ``PRIVMSG'') +@item @option{handler_func}: function called when message is received +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new message handler.@* +@* +@emph{Example:}@* +@* +@code{int msg_kick (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "KICK received");}@* +@code{@}}@* +@code{...}@* +@code{plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);}@* +@* + +@item +@command{void msg_handler_remove (t_weechat_plugin *plugin, +t_plugin_msg_handler *msg_handler)}@* +@* +Remove an IRC message handler.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{msg_handler}: handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove (plugin, my_msg_handler);}@* +@* + +@item +@command{void msg_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all IRC message handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove_all (plugin);}@* +@* + +@item +@command{t_plugin_cmd_handler *cmd_handler_add (t_weechat_plugin +*plugin, char *command, char *description, char *arguments, +char *arguments_description, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add a WeeChat command handler, called when user uses command +(for example /command).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{commande}: the new command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) +@item @option{handler_func}: function called when comand is executed +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new command handler.@* +@* +@emph{Example:}@* +@* +@code{int cmd_test (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "test command, +file: %s", (arguments) ? arguments : "none");}@* +@code{@}}@* +@code{...}@* +@code{plugin->cmd_handler_add (plugin, "test", "Test command", +"[file]", "file: a file name", &cmd_test, NULL, NULL);}@* +@* + +@item +@command{void cmd_handler_remove (t_weechat_plugin *plugin, +t_plugin_cmd_handler *cmd_handler)}@* +@* +Remove a command handler.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{cmd_handler}: command handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->cmd_handler_remove (plugin, my_cmd_handler);}@* +@* + +@item +@command{void cmd_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all command handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example :}@* +@* +@code{plugin->cmd_handler_remove_all (plugin);}@* +@* + +@item +@command{void exec_command (t_weechat_plugin +*plugin, char *server, char *channel, char *command)}@* +@* +Execute a WeeChat command (or send a message to a channel).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server for executing command (may be +NULL) +@item @option{channel}: name of channel for executing command (may be +NULL) +@item @option{command}: command +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->exec_command (plugin, NULL, NULL, "/help nick");}@* +@code{plugin->exec_command (plugin, "freenode", "#weechat", "hello");}@* +@* + +@item +@command{char *get_info (t_weechat_plugin +*plugin, char *info, char *server, char *channel)}@* +@* +Return an info about WeeChat or a channel.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{info}: name of info to read: +@itemize @minus +@item @option{version}: get WeeChat's version +@item @option{nick}: get nick +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir +@end itemize +@item @option{server}: name of server for reading info (if needed) +@item @option{channel}: name of channel for reading info (if needed) +@end itemize +@* +@emph{Return value:}@* +@* +Information asked, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *version = plugin->get_info (plugin, "version", NULL, NULL);}@* +@code{char *nick = plugin->get_info (plugin, "nick", "freenode", NULL);}@* +@* + +@item +@command{t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin)}@* +@* +Returns list of DCC currently active or finished.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +Chained list of DCC.@* +Note: result has to be free by a call to ``free_dcc_info'' function +after use.@* +@* +@emph{Example:}@* +@* +@code{t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin);}@* +@code{for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = +ptr_dcc->next_dcc)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "DCC type=%d, with: %s", +ptr_dcc->type, ptr_dcc->nick);}@* +@code{@}}@* +@* + +@item +@command{void free_dcc_info (t_weechat_plugin *plugin, +t_plugin_dcc_info *dcc_info)}@* +@* +Free memory used by a DCC list.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{dcc_info}: pointer to DCC list returned by +``get_dcc_info'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->free_dcc_info (plugin, dcc_info);}@* +@* + +@item +@command{char *get_config (t_weechat_plugin +*plugin, char *option)}@* +@* +Return value of a WeeChat config option.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{option}: name of option to read +@end itemize +@* +@emph{Return value:}@* +@* +Value of option, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *value1 = plugin->get_config (plugin, "look_set_title");}@* +@code{char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Compile plugin + +Compile does not need WeeChat sources, only file +``weechat-plugin.h''.@* + +To compile a plugin which has one file ``toto.c'' (sous GNU/Linux):@* +@* +gcc -fPIC -Wall -c toto.c@* +gcc -shared -fPIC -o libtoto.so toto.o + +@subsection Load plugin under WeeChat -@subsection Cargar/descargar programas Perl +Copy ``libtoto.so'' file into general plugins dir (for example +/usr/local/lib/weechat/plugins) or into user's plugins dir (for +example /home/xxxxx/.weechat/plugins).@* +@* +Under WeeChat:@* +@command{/plugin load toto} + +@node Plugin example, Scripts plugins, Write a plugin, Plugins +@section Plugin example + +Full example of plugin, which adds a /double command, which displays +two times arguments on current channel (ok that's not very useful, but +that's just an example!): + +@verbatim +#include <stdlib.h> + +#include "weechat-plugin.h" + +char plugin_name[] = "Toto"; +char plugin_version[] = "0.1"; +char plugin_description[] = "Test plugin for WeeChat"; + +/* gestionnaire de commande "/hello" */ + +int toto_cmd_double (t_weechat_plugin *plugin, char *server, + char *command, char *arguments, + char *handler_args, void *handler_pointer) +{ + if (arguments && arguments[0] && (arguments[0] != '/')) + { + plugin->exec_command (plugin, NULL, NULL, arguments); + plugin->exec_command (plugin, NULL, NULL, arguments); + } + return 1; +} + +int weechat_plugin_init (t_weechat_plugin *plugin) +{ + plugin->cmd_handler_add (plugin, "double", + "Display two times a message", + "msg", + "msg: message", + &toto_cmd_double, + NULL, NULL); + return 1; +} + +int weechat_plugin_end (t_weechat_plugin *plugin) +{ + /* on ne fait rien ici */ + return 1; +} +@end verbatim + +@node Scripts plugins, , Plugin example, Plugins +@section Scripts plugins + +Three plugins are provided with WeeChat to load scripts: Perl, +Python and Ruby. + +@subsection Perl scripts + +@subsubsection Cargar/descargar programas Perl Los programas Perl se cargan y descargan con el comando @command{/perl} (escribiendo @kbd{/help perl} en WeeChat para obtener la ayuda acerca del comando).@* @@ -1530,7 +2116,7 @@ Cargar un programa Perl: @kbd{/perl load /tmp/ejemplo.pl}@* Listar los programas Perl cargados: @kbd{/perl}@* @end itemize -@subsection Interfaz WeeChat / Perl +@subsubsection Interfaz WeeChat / Perl @itemize @bullet @item @@ -1550,6 +2136,7 @@ tener un nombre distinto) @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat::register ("ejemplo", "1.0", "fin_ejemplo", "programa de ejemplo...");}@* @* @@ -1565,7 +2152,8 @@ Escribe un mensaje en un canal.@* @item @option{servidor}: (opcional) nombre interno del servidor @end itemize @* -@emph{Ejemplo:}@* +@emph{Ejemplos:}@* +@* @code{weechat::print ("mensaje");}@* @code{weechat::print ("mensaje", "#weechat");}@* @code{weechat::print ("mensaje", "#weechat", "freenode");}@* @@ -1584,6 +2172,7 @@ Escribir un mensaje en la barra de informaciones.@* @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat::print_infobar (5, "mensaje");}@* @* @@ -1604,6 +2193,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat::add_message_handler ("privmsg", mi_funcion);}@* @code{sub mi_funcion}@* @code{@{ }@* @@ -1627,9 +2217,16 @@ Puede ser un comando que ya existe, y en este caso el nuevo comando sustituir@'a el antiguo. Ten cuidado cuando sustituyas a un comando de WeeChat, no podr@'a acceder al antiguo comando si el script Perl est@'a cargado. @item @option{funcion}: funci@'on Perl assiciada al comando. +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat::add_command_handler ("comando", mi_comando);}@* @code{sub mi_comando}@* @code{@{ }@* @@ -1651,6 +2248,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat::command ("hello world!");}@* @code{weechat::command ("/kick toto please leave this chan", "#weechat");}@* @code{weechat::command ("/nick newnick", "", "freenode");}@* @@ -1664,28 +2262,85 @@ Obtener informaciones distintas sobre WeeChat, el servidor o el usuario.@* @emph{Par@'ametros:} @itemize @minus @item @option{nombre}: nombre de la informaci@'on que se quiere obtener: -@item @option{servidor}: nombre interno del servidor @itemize @minus -@item @option{0 o version}: obtener la versi@'on de WeeChat -@item @option{1 o nick}: obtener el seud@'onimo -@item @option{2 o channel}: obtener el nombre del canal -@item @option{3 o server}: obtener el nombre del servidor -@item @option{4 o weechatdir}: obtener el directorio home de WeeChat -@item @option{5 o away}: obtener la informaci@'on "away" del servidor +@item @option{version}: obtener la versi@'on de WeeChat +@item @option{nick}: obtener el seud@'onimo +@item @option{channel}: obtener el nombre del canal +@item @option{server}: obtener el nombre del servidor +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{servidor}: nombre interno del servidor @end itemize @* @emph{Ejemplos:}@* +@* @code{$version = weechat::get_info("version");}@* @code{$nick = weechat::get_info("nick", "freenode");}@* @* +@item +@command{weechat::get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) +@end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat::get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat::get_config ("look_set_title");}@* +@code{$value2 = weechat::get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Programas Python, Programas Ruby, Programas Perl, Extensiones -@section Programas Python +@subsection Python scripts -@subsection Cargar/descargar programas Python +@subsubsection Cargar/descargar programas Python Los programas Python se cargan y descargan con el comando @command{/python} (escribiendo @kbd{/help python} en WeeChat para obtener la ayuda acerca del comando).@* @@ -1699,7 +2354,7 @@ Cargar un programa Python: @kbd{/python load /tmp/ejemplo.py}@* Listar los programas Python cargados: @kbd{/python}@* @end itemize -@subsection Interfaz WeeChat / Python +@subsubsection Interfaz WeeChat / Python @itemize @bullet @item @@ -1719,6 +2374,7 @@ tener un nombre distinto) @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat.register ("ejemplo", "1.0", "fin_ejemplo", "programa de ejemplo...")}@* @* @@ -1734,7 +2390,8 @@ Escribe un mensaje en un canal.@* @item @option{servidor}: (opcional) nombre interno del servidor @end itemize @* -@emph{Ejemplo:}@* +@emph{Ejemplos:}@* +@* @code{weechat.prnt ("mensaje")}@* @code{weechat.prnt ("mensaje", "#weechat")}@* @code{weechat.prnt ("mensaje", "#weechat", "freenode")}@* @@ -1753,6 +2410,7 @@ Escribir un mensaje en la barra de informaciones.@* @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat.print_infobar (5, "mensaje")}@* @* @@ -1773,6 +2431,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat.add_message_handler ("privmsg", mi_funcion)}@* @code{def mi_funcion(servidor, args):}@* @code{@ @ @ @ weechat.prnt("servidor="+servidor)}@* @@ -1794,9 +2453,16 @@ Puede ser un comando que ya existe, y en este caso el nuevo comando sustituir@'a el antiguo. Ten cuidado cuando sustituyas a un comando de WeeChat, no podr@'a acceder al antiguo comando si el script Python est@'a cargado. @item @option{funcion}: funci@'on Python assiciada al comando. +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat.add_command_handler ("comando", mi_comando)}@* @code{def mi_comando(servidor, args):}@* @code{@ @ @ @ weechat.prnt("Servidor:"+servidor+" Par@'ametros:"+args)}@* @@ -1815,6 +2481,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat.command ("hello world!")}@* @code{weechat.command ("/kick toto please leave this chan", "#weechat")}@* @code{weechat.command ("/nick newnick", "", "freenode")}@* @@ -1828,32 +2495,90 @@ Obtener informaciones distintas sobre WeeChat, el servidor o el usuario.@* @emph{Par@'ametros:} @itemize @minus @item @option{nombre}: nombre de la informaci@'on que se quiere obtener: -@item @option{servidor}: nombre interno del servidor @itemize @minus -@item @option{0 o version}: obtener la versi@'on de WeeChat -@item @option{1 o nick}: obtener el seud@'onimo -@item @option{2 o channel}: obtener el nombre del canal -@item @option{3 o server}: obtener el nombre del servidor -@item @option{4 o weechatdir}: obtener el directorio home de WeeChat -@item @option{5 o away}: obtener la informaci@'on "away" del servidor +@item @option{version}: obtener la versi@'on de WeeChat +@item @option{nick}: obtener el seud@'onimo +@item @option{channel}: obtener el nombre del canal +@item @option{server}: obtener el nombre del servidor +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{servidor}: nombre interno del servidor @end itemize @* @emph{Ejemplos:}@* +@* @code{$version = weechat.get_info("version")}@* @code{$nick = weechat.get_info("nick", "freenode")}@* @* +@item +@command{weechat.get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) +@end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat.get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat.get_config ("look_set_title");}@* +@code{$value2 = weechat.get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Programas Ruby, , Programas Python, Extensiones -@section Programas Ruby +@subsection Ruby scripts @exclamdown{}No desarrollado! + @c **************************** Autores / Soporte ***************************** -@node Autores / Soporte, , Extensiones, Top +@node Autores / Soporte, , Plugins, Top @chapter Autores / Soporte @ifhtml diff --git a/doc/weechat_doc_fr.texi b/doc/weechat_doc_fr.texi index a3afdea6b..4c40f648c 100644 --- a/doc/weechat_doc_fr.texi +++ b/doc/weechat_doc_fr.texi @@ -36,7 +36,7 @@ @title WeeChat - Guide utilisateur @subtitle Client IRC rapide, l@'eger et extensible -@subtitle Documentation pour WeeChat v0.1.6-cvs - 2 octobre 2005 +@subtitle Documentation pour WeeChat v0.1.6-cvs - 17 octobre 2005 @author FlashCode <@email{flashcode@@flashtux.org, flashcode AT flashtux.org}> @@ -430,7 +430,7 @@ Couleur pour le texte saisi (pseudo)@* Type: couleur (couleur Curses ou Gtk), valeur par d@'efaut: 'lightcyan'@* @item col_input_delimiters Couleur pour le texte saisi (d@'elimiteurs)@* -Type: couleur (couleur Curses ou Gtk), valeur par d@'efaut: 'cyan'@* +Type: couleur (couleur Curses ou Gtk), valeur par d@'efaut: 'lightgreen'@* @item col_input_bg Couleur de fond pour la fen@^etre de saisie@* Type: couleur (couleur Curses ou Gtk), valeur par d@'efaut: 'default'@* @@ -629,6 +629,15 @@ Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: ''@* @item proxy_password Mot de passe pour le serveur proxy@* Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: ''@* +@item plugins_path +Chemin de recherche des extensions@* +Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: '~/.weechat/plugins'@* +@item plugins_autoload +Liste des extensions @`a charger automatiquement au d@'emarrage, "*" signifie toutes (s@'epar@'ees par des virgules, les noms peuvent @^etre partiels, par exemple "perl" est ok pour "libperl.so")@* +Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: '*'@* +@item plugins_extension +Extension standard des extensions dans le nom de fichier, pour le chargement automatique (si vide, alors tous les fichiers sont charg@'es si autoload vaut "*")@* +Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: '.so'@* @item server_name Nom associ@'e au serveur IRC (pour affichage seulement)@* Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: ''@* @@ -907,29 +916,13 @@ unbind: supprimer l'association @`a une touche (si "all", toutes les association functions: lister la liste des fonctions internes pour les associations de touches@* reset: restaur les touches aux valeurs par d@'efaut et supprime TOUTES les touches personnelles (utiliser avec pr@'ecaution !)@* @* -@item perl [load fichier] | [autoload] | [reload] | [unload] -@* -liste/charge/d@'echarge des scripts Perl@* -@* -fichier: script Perl (fichier) @`a charger@* -@* -Sans param@`etre, la commande /perl liste tous les scripts Perl charg@'es.@* -@* -@item python [load fichier] | [autoload] | [reload] | [unload] +@item plugin [load fichier] | [autoload] | [reload] | [unload] @* -liste/charge/d@'echarge des scripts Python@* +liste/charge/d@'echarge des extensions@* @* -fichier: script Python (fichier) @`a charger@* +fichier: extension WeeChat (fichier) @`a charger@* @* -Sans param@`etre, la commande /python liste tous les scripts Python charg@'es.@* -@* -@item ruby [load fichier] | [autoload] | [reload] | [unload] -@* -liste/charge/d@'echarge des scripts Ruby@* -@* -fichier: script Ruby (fichier) @`a charger@* -@* -Sans param@`etre, la commande /ruby liste tous les scripts Ruby charg@'es.@* +Sans param@`etre, la commande /plugin liste toutes les extensions charg@'ees.@* @* @item server [nom_serveur] | [nom_serveur nom/IP port [-auto | -noauto] [-ipv6] [-ssl] [-pwd mot_de_passe] [-nicks pseudo1 pseudo2 pseudo3] [-username nom_utilisateur] [-realname nom_r@'eel] [-command commande] [-autojoin canal[,canal]] ] | [del nom_serveur] @* @@ -1153,6 +1146,7 @@ modes de canaux :@* m: canal mod@'er@'e@* l: fixer la limite d'utilisateurs pour le canal@* b: param@'etrer un masque de banissement pour garder des utilisateurs dehors@* + e: param@'etrer un masque d'exception@* v: donner/reprendre la possibilit@'e de parler sur un canal mod@'er@'e@* k: d@'efinir une cl@'e (mot de passe) pour acc@'eder au canal@* modes utilisateur :@* @@ -1510,15 +1504,625 @@ Si le script s'appelle "auto_weechat_command", vous pouvez le lancer ainsi :@* @chapter Extensions @menu -* Scripts Perl:: -* Scripts Python:: -* Scripts Ruby:: +* Les extensions dans WeeChat:: +* Ecrire une extension:: +* Exemple d'extension:: +* Extensions pour scripts:: @end menu -@node Scripts Perl, Scripts Python, Extensions, Extensions -@section Scripts Perl +@node Les extensions dans WeeChat, Ecrire une extension, Extensions, Extensions +@section Les extensions dans WeeChat + +Une extension (``plugin'' en anglais) est un programme @'ecrit en C +qui peut appeler des fonctions de WeeChat d@'efinies dans une +interface.@* +Ce programme C n'a pas besoin des sources WeeChat pour @^etre +compil@'e et peut @^etre charg@'e/d@'echarg@'e dynamiquement dans +WeeChat via la commande @command{/plugin}.@* +@* +L'extension doit @^etre au format biblioth@`eque, chargeable +dynamiquement par le syst@^eme d'exploitation.@* +Sous GNU/Linux, il s'agit d'un fichier ayant pour extension ``.so''. + +@node Ecrire une extension, Exemple d'extension, Les extensions dans WeeChat, Extensions +@section Ecrire une extension + +@subsection R@`egles de base + +L'extension doit appeler le fichier ``weechat-plugin.h'' (disponible +dans les sources de WeeChat).@* +Ce fichier d@'efinit les structures et types dont l'extension aura +besoin pour communiquer avec WeeChat.@* +@* +L'extension doit comporter certaines variables et fonctions +obligatoires (sans quoi l'extension ne peut être chargée) :@* +@itemize @bullet +@item variables de description de l'extension : +@itemize @minus +@item plugin_name[]: le nom de l'extension +@item plugin_version[]: la version de l'extension +@item plugin_description[]: une courte description de l'extension +@end itemize +@item fonctions d'initialisation et fin de l'extension : +@itemize @minus +@item weechat_plugin_init: fonction appel@'e au chargement de l'extension +@item weechat_plugin_end: fonction appel@'e au d@'echargement de l'extension +@end itemize +@end itemize + +@subsection Fonctions de l'interface (API) + +L'extension peut appeler un certain nombre de fonctions d@'efinies +dans la structure t_weechat_plugin.@* +Ces fonctions sont d@'etaill@'ees ci-dessous : + +@itemize @bullet +@item +@command{int ascii_strcasecmp (t_weechat_plugin *plugin, +char *string1, char *string2)}@* +@* +Effectue une comparaison entre deux cha@^ines, sans tenir compte des +majuscules/minuscules ni de la locale.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{string1}: la premi@`ere cha@^ine @`a comparer +@item @option{string2}: la deuxi@`eme cha@^ine @`a comparer +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +La diff@'erence entre les deux cha@^ines: n@'egatif si chaine1 < +chaine2, nul si chaine1 == chaine 2, positif si chaine1 > chaine2@* +@* +@emph{Exemple :}@* +@* +@code{if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...}@* +@* + +@item +@command{char **explode_string (t_weechat_plugin *plugin, +char *string, char *separators, int num_items_max, int *num_items)}@* +@* +Explose une cha@^ine en plusieurs selon un/des d@'elimiteur(s).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{string}: la cha@^ine @`a exploser +@item @option{separators}: les d@'elimiteurs utilis@'s pour exploser +la cha@^ine +@item @option{num_items_max}: nombre maximum de sous-cha@^ines +cr@'é@'ees (si 0, alors le nombre est infini) +@item @option{num_items}: pointeur vers un entier qui contiendra le +nombre de sous-cha@^ines cr@'e@'ees en retour +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Un tableau de cha@^ines, ou NULL si un probl@^eme a @'et@'e rencontr@'e.@* +NB: le r@'esultat doit @^etre lib@'er@'e par un appel @`a la fonction +``free_exploded_string'' apr@`es utilisation.@* +@* +@emph{Exemple :}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{char **free_exploded_string (t_weechat_plugin *plugin, +char **string)}@* +@* +Lib@`ere la m@'emoire utilis@'ee pour une explosion de cha@^ine.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{string}: la cha@^ine explos@'ee par la fonction +``explode_string'' +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{void exec_on_files (t_weechat_plugin *plugin, char *directory, +int (*callback)(t_weechat_plugin *, char *))}@* +@* +Ex@'ecute une fonction sur tous les fichiers d'un r@'epertoire.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{directory}: le r@'epertoire o@`u les fichiers sont +recherch@'es +@item @option{callback}: une fonction appel@'ee pour chaque fichier trouv@'e +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{int callback (t_weechat_plugin *plugin, char *file)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "fichier: %s", file);}@* +@code{@ @ @ @ return 1;}@* +@code{@}}@* +@code{}@* +@code{...}@* +@code{plugin->exec_on_files (plugin, "/tmp", &callback);}@* +@* + +@item +@command{void printf (t_weechat_plugin *plugin, +char *server, char *channel, char *message, ...)}@* +@* +Affiche un message sur un tampon WeeChat, identifi@'e par le serveur et +le canal (tous deux pouvant @^etre NULL).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{server}: nom du serveur pour trouver le tampon dans +lequel afficher (peut @^etre NULL) +@item @option{channel}: nom du canal pour trouver le tampon dans +lequel afficher (peut @^etre NULL) +@item @option{message}: message @`a afficher +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemples :}@* +@* +@code{plugin->printf (NULL, NULL, "hello");}@* +@code{plugin->printf (NULL, "#weechat", "hello");}@* +@code{plugin->printf ("freenode", "#weechat", "hello");}@* +@* + +@item +@command{void printf_server (t_weechat_plugin *plugin, +char *message, ...)}@* +@* +Affiche un message sur la fen@^etre du serveur courant.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{message}: message @`a afficher +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->printf_server ("hello");}@* +@* + +@item +@command{void printf_infobar (t_weechat_plugin *plugin, +int time, char *message, ...)}@* +@* +Affiche un message sur la barre d'infos pour un temps d@'etermin@'e.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{time}: temps pendant lequel le message est affich@'e, en +secondes (0 = jamais effac@'e) +@item @option{message}: message @`a afficher +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->printf_infobar (5, "hello");}@* +@* + +@item +@command{t_plugin_msg_handler *msg_handler_add (t_weechat_plugin +*plugin, char *message, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Ajoute un gestionnaire de messages IRC, appel@'e d@`s qu'un message +IRC est re@,cu.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{message}: message IRC (par exemple ``PRIVMSG'') +@item @option{handler_func}: fonction appel@'ee lorsque le message est +re@,cu +@item @option{handler_args}: param@`etres pass@'es @`a la fonction +appel@'ee +@item @option{handler_pointer}: pointeur pass@'e @`a la fonction +appel@'ee +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Le pointeur vers le nouveau gestionnaire de messages.@* +@* +@emph{Exemple :}@* +@* +@code{int msg_kick (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "KICK re@,cu");}@* +@code{@}}@* +@code{...}@* +@code{plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);}@* +@* + +@item +@command{void msg_handler_remove (t_weechat_plugin *plugin, +t_plugin_msg_handler *msg_handler)}@* +@* +Supprime un gestionnaire de messages IRC.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{msg_handler}: le gestionnaire de messages @`a supprimer +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->msg_handler_remove (plugin, my_msg_handler);}@* +@* + +@item +@command{void msg_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Supprime tous les gestionnaires de messages IRC d'une extension.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->msg_handler_remove_all (plugin);}@* +@* + +@item +@command{t_plugin_cmd_handler *cmd_handler_add (t_weechat_plugin +*plugin, char *command, char *description, char *arguments, +char *arguments_description, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Ajoute un gestionnaire de commande WeeChat, appel@'e d@`s que +l'utilisateur utilise la commande (par exemple /commande).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{commande}: la nouvelle commande +@item @option{description}: description de la commande (affich@'ee par +/help commande) +@item @option{arguments}: br@`eve description des param@`etres de la +commande (affich@'ee par /help commande) +@item @option{arguments_description}: longue description des +param@`etres de la commande (affich@'ee par /help commande) +@item @option{handler_func}: fonction appel@'ee lorsque la commande est +ex@'ecut@'ee +@item @option{handler_args}: param@`etres pass@'es @`a la fonction +appel@'ee +@item @option{handler_pointer}: pointeur pass@'e @`a la fonction +appel@'ee +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Le pointeur vers le nouveau gestionnaire de commande.@* +@* +@emph{Exemple :}@* +@* +@code{int cmd_test (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "commande test, +fichier: %s", (arguments) ? arguments : "aucun");}@* +@code{@}}@* +@code{...}@* +@code{plugin->cmd_handler_add (plugin, "test", "Commande test", +"[fichier]", "fichier: un nom de fichier", &cmd_test, NULL, NULL);}@* +@* + +@item +@command{void cmd_handler_remove (t_weechat_plugin *plugin, +t_plugin_cmd_handler *cmd_handler)}@* +@* +Supprime un gestionnaire de commande.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{cmd_handler}: le gestionnaire de commande @`a supprimer +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->cmd_handler_remove (plugin, my_cmd_handler);}@* +@* + +@item +@command{void cmd_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Supprime tous les gestionnaires de commande d'une extension.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->cmd_handler_remove_all (plugin);}@* +@* + +@item +@command{void exec_command (t_weechat_plugin +*plugin, char *server, char *channel, char *command)}@* +@* +Execute une commande WeeChat (ou envoie un message @`a un canal).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{server}: nom du serveur o@`u ex@'ecuter la commande +(peut @^etre NULL) +@item @option{channel}: nom du canal o@`u ex@'ecuter la commande (peut +@^etre NULL) +@item @option{command}: la commande @`a ex@'ecuter +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemples :}@* +@* +@code{plugin->exec_command (plugin, NULL, NULL, "/help nick");}@* +@code{plugin->exec_command (plugin, "freenode", "#weechat", "hello");}@* +@* -@subsection Charger/d@'echarger des scripts Perl +@item +@command{char *get_info (t_weechat_plugin +*plugin, char *info, char *server, char *channel)}@* +@* +Renvoie une information sur WeeChat ou un canal.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{info}: nom de l'info @`a obtenir : +@itemize @minus +@item @option{version}: obtenir la version de WeeChat +@item @option{nick}: obtenir le pseudo +@item @option{channel}: obtenir le nom du canal +@item @option{server}: obtenir le nom du serveur +@item @option{away}: obtenir le drapeau ``away'' +@item @option{weechat_dir}: obtenir le r@'epertoire maison de WeeChat +@item @option{weechat_libdir}: obtenir le r@'epertoire ``lib'' +syst@`eme de WeeChat +@item @option{weechat_sharedir}: obtenir le r@'epertoire ``share'' +syst@`eme de partage WeeChat +@end itemize +@item @option{server}: nom du serveur o@`u r@'ecup@'erer l'information +(ni n@'ecessaire) +@item @option{channel}: nom du canal o@`u r@'ecup@'erer l'information +(si n@'ecessaire) +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +L'information recherch@'ee, NULL si non trouv@'ee.@* +NB: le r@'esultat doit @^etre lib@'er@'e par un appel @`a la fonction +``free'' apr@`es utilisation.@* +@* +@emph{Exemples :}@* +@* +@code{char *version = plugin->get_info (plugin, "version", NULL, NULL);}@* +@code{char *nick = plugin->get_info (plugin, "nick", "freenode", NULL);}@* +@* + +@item +@command{t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin)}@* +@* +Renvoie la liste des DCC en cours ou termin@'es.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +La liste cha@^in@'ee des DCC.@* +NB: le r@'esultat doit @^etre lib@'er@'e par un appel @`a la fonction +``free_dcc_info'' apr@`es utilisation.@* +@* +@emph{Exemple :}@* +@* +@code{t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin);}@* +@code{for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = +ptr_dcc->next_dcc)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "DCC type=%d, avec: %s", +ptr_dcc->type, ptr_dcc->nick);}@* +@code{@}}@* +@* + +@item +@command{void free_dcc_info (t_weechat_plugin *plugin, +t_plugin_dcc_info *dcc_info)}@* +@* +Lib@`ere la m@'emoire utilis@'ee par une liste de DCC.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{dcc_info}: pointeur vers une structure renvoy@'ee par la +fonction ``get_dcc_info'' +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->free_dcc_info (plugin, dcc_info);}@* +@* + +@item +@command{char *get_config (t_weechat_plugin +*plugin, char *option)}@* +@* +Renvoie la valeur d'une option de configuration WeeChat.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{option}: nom de l'option @`a lire +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +La valeur de l'option, NULL si non trouv@'ee.@* +NB: le r@'esultat doit @^etre lib@'er@'e par un appel @`a la fonction +``free'' apr@`es utilisation.@* +@* +@emph{Exemples :}@* +@* +@code{char *value1 = plugin->get_config (plugin, "look_set_title");}@* +@code{char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Compiler l'extension + +La compilation ne n@'ecessite pas les sources WeeChat, mais seulement +le fichier ``weechat-plugin.h''.@* + +Pour compiler une extension compos@'ee d'un fichier ``toto.c'' (sous +GNU/Linux) :@* +@* +gcc -fPIC -Wall -c toto.c@* +gcc -shared -fPIC -o libtoto.so toto.o + +@subsection Charger l'extension dans WeeChat + +Copier le fichier ``libtoto.so'' dans le r@'epertoire des extensions +g@'en@'eral (par exemple /usr/local/lib/weechat/plugins) ou bien dans +celui de l'utilisateur (par exemple /home/xxxxx/.weechat/plugins).@* +@* +Sous WeeChat :@* +@command{/plugin load toto} + +@node Exemple d'extension, Extensions pour scripts, Ecrire une extension, Extensions +@section Exemple d'extension + +Un exemple complet d'extension, qui ajoute une commande /double +affichant deux fois les param@`etres pass@'es sur le canal courant +(d'accord ce n'est pas tr@`es utile mais ceci est un exemple !) : + +@verbatim +#include <stdlib.h> + +#include "weechat-plugin.h" + +char plugin_name[] = "Toto"; +char plugin_version[] = "0.1"; +char plugin_description[] = "Plugin de test pour WeeChat"; + +/* gestionnaire de commande "/hello" */ + +int toto_cmd_double (t_weechat_plugin *plugin, char *server, + char *command, char *arguments, + char *handler_args, void *handler_pointer) +{ + if (arguments && arguments[0] && (arguments[0] != '/')) + { + plugin->exec_command (plugin, NULL, NULL, arguments); + plugin->exec_command (plugin, NULL, NULL, arguments); + } + return 1; +} + +int weechat_plugin_init (t_weechat_plugin *plugin) +{ + plugin->cmd_handler_add (plugin, "double", + "Affiche deux fois un message", + "msg", + "msg: message @`a afficher deux fois", + &toto_cmd_double, + NULL, NULL); + return 1; +} + +int weechat_plugin_end (t_weechat_plugin *plugin) +{ + /* on ne fait rien ici */ + return 1; +} +@end verbatim + +@node Extensions pour scripts, , Exemple d'extension, Extensions +@section Extensions pour scripts + +Trois extensions sont fournies en standard avec WeeChat pour utiliser +des langages de script: Perl, Python et Ruby. + +@subsection Scripts Perl + +@subsubsection Charger/d@'echarger des scripts Perl Les scripts Perl sont charg@'es et d@'echarg@'es avec la commande @command{/perl} (tapez @kbd{/help perl} dans WeeChat pour obtenir de l'aide sur la commande).@* @@ -1532,7 +2136,7 @@ Charger un script Perl : @kbd{/perl load /tmp/essai.pl}@* Lister les scripts Perl charg@'es : @kbd{/perl}@* @end itemize -@subsection Interface WeeChat / Perl +@subsubsection Interface WeeChat / Perl @itemize @bullet @item @@ -1553,6 +2157,7 @@ de fonction @`a appeler) @end itemize @* @emph{Exemple :}@* +@* @code{weechat::register ("essai", "1.0", "fin_essai", "Script d'essai !");}@* @* @@ -1568,7 +2173,8 @@ Affiche un message dans un canal.@* @item @option{serveur}: nom interne du serveur @end itemize @* -@emph{Exemple :}@* +@emph{Exemples :}@* +@* @code{weechat::print ("message");}@* @code{weechat::print ("message", "#weechat");}@* @code{weechat::print ("message", "#weechat", "freenode");}@* @@ -1587,6 +2193,7 @@ Affiche un message dans la barre d'infos.@* @end itemize @* @emph{Exemple :}@* +@* @code{weechat::print_infobar (5, "message");}@* @* @@ -1607,6 +2214,7 @@ RFC 2812 : @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Exemple :}@* +@* @code{weechat::add_message_handler ("privmsg", ma_fonction);}@* @code{sub ma_fonction}@* @code{@{ }@* @@ -1618,7 +2226,8 @@ RFC 2812 : @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @* @item -@command{weechat::add_command_handler ( nom, fonction );}@* +@command{weechat::add_command_handler ( nom, fonction, [description, +arguments, arguments_description] );}@* @* Cr@'e@'e une nouvelle commande WeeChat, associ@'ee @`a une fonction Perl.@* La fonction sera appel@'ee lorsque l'utilisateur lancera la commande par @kbd{/nom}.@* @@ -1630,9 +2239,16 @@ Il peut s'agir d'une commande existante, auquel cas celle-ci est @'ecras@'ee par la fonction Perl. Soyez prudent en @'ecrasant les commandes WeeChat, car elles ne seront plus accessibles tant que le script Perl sera charg@'e. @item @option{fonction}: fonction Perl associ@'ee @`a la commande +@item @option{description}: description de la commande (affich@'ee par +/help commande) +@item @option{arguments}: br@`eve description des param@`etres de la +commande (affich@'ee par /help commande) +@item @option{arguments_description}: longue description des +param@`etres de la commande (affich@'ee par /help commande) @end itemize @* @emph{Exemple :}@* +@* @code{weechat::add_command_handler ("commande", ma_commande);}@* @code{sub ma_commande}@* @code{@{ }@* @@ -1654,6 +2270,7 @@ Ex@'ecute une commande ou envoie un message @'a un canal.@* @end itemize @* @emph{Exemples :}@* +@* @code{weechat::command ("bonjour tout le monde !");}@* @code{weechat::command ("/kick toto merci de quitter ce canal", "#weechat");}@* @code{weechat::command ("/nick newnick", "", "freenode");}@* @@ -1667,28 +2284,87 @@ Obtenir des informations vari@'ees sur WeeChat, le serveur ou l'utilisateur.@* @emph{Param@`etres :} @itemize @minus @item @option{nom}: nom de l'info @`a obtenir : -@item @option{serveur}: nom interne du serveur @itemize @minus -@item @option{0 ou version}: obtenir la version de WeeChat -@item @option{1 ou nick}: obtenir le pseudo -@item @option{2 ou channel}: obtenir le nom du canal -@item @option{3 ou server}: obtenir le nom du serveur -@item @option{4 ou weechatdir}: obtenir le r@'epertoire maison de WeeChat -@item @option{5 ou away}: obtenir le drapeau "away" du serveur +@item @option{version}: obtenir la version de WeeChat +@item @option{nick}: obtenir le pseudo +@item @option{channel}: obtenir le nom du canal +@item @option{server}: obtenir le nom du serveur +@item @option{away}: obtenir le drapeau ``away'' +@item @option{weechat_dir}: obtenir le r@'epertoire maison de WeeChat +@item @option{weechat_libdir}: obtenir le r@'epertoire ``lib'' +syst@`eme de WeeChat +@item @option{weechat_sharedir}: obtenir le r@'epertoire ``share'' +syst@`eme de partage WeeChat @end itemize +@item @option{serveur}: nom interne du serveur @end itemize @* @emph{Exemples :}@* +@* @code{$version = get_info("version");}@* @code{$nick = get_info("nick", "freenode");}@* @* +@item +@command{weechat::get_dcc_info ( );}@* +@* +Obtenir la liste des DCC.@* + +Le tableau renvoy@'e contient les champs suivants : +@itemize @minus +@item server: le serveur IRC +@item channel: le canal IRC +@item type: le type de DCC : +@itemize @minus +@item 0: discussion (re@,cue) +@item 1: discussion (envoy@'ee) +@item 2: fichier en r@'eception +@item 3: fichier en @'emission +@end itemize +@item status: statut du DCC : +@itemize @minus +@item 0: en attente +@item 1: en cours de connexion +@item 2: actif +@item 3: termin@'e +@item 4: @'echou@'e +@item 5: interrompu par l'utilisateur +@end itemize +@item start_time: la date et heure de cr@'eation du DCC +@item start_transfer: la date et heure de d@'emarrage du transfert +@item addr: adresse de l'utilisateur distant +@item port: port utilis@'e pour le DCC +@item nick: pseudo de l'utilisateur distant +@item filename: nom de fichier +@item local_filename: nom de fichier local +@item size: taille du fichier +@item pos: position actuelle dans le fichier +@item start_resume: position de d@'emarrage apr@`es une interruption +@item bytes_per_sec: nombre d'octets transmis par seconde depuis le d@'ebut +@end itemize +@* + +@item +@command{weechat::get_config ( nom );}@* +@* +Obtenir la valeur d'une option de configuration WeeChat.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{nom}: nom de l'option +@end itemize +@* +@emph{Exemples :}@* +@* +@code{$value1 = weechat::get_config ("look_set_title");}@* +@code{$value2 = weechat::get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Scripts Python, Scripts Ruby, Scripts Perl, Extensions -@section Scripts Python +@subsection Scripts Python -@subsection Charger/d@'echarger des scripts Python +@subsubsection Charger/d@'echarger des scripts Python Les scripts Python sont charg@'es et d@'echarg@'es avec la commande @command{/python} (tapez @kbd{/help python} dans WeeChat pour obtenir de l'aide sur la commande).@* @@ -1702,7 +2378,7 @@ Charger un script Python : @kbd{/python load /tmp/essai.py}@* Lister les scripts Python charg@'es : @kbd{/python}@* @end itemize -@subsection Interface WeeChat / Python +@subsubsection Interface WeeChat / Python @itemize @bullet @item @@ -1723,6 +2399,7 @@ de fonction @`a appeler) @end itemize @* @emph{Exemple :}@* +@* @code{weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !")}@* @* @@ -1738,7 +2415,8 @@ Affiche un message dans un canal.@* @item @option{serveur}: nom interne du serveur @end itemize @* -@emph{Exemple :}@* +@emph{Exemples :}@* +@* @code{weechat.prnt ("message")}@* @code{weechat.prnt ("message", "#weechat")}@* @code{weechat.prnt ("message", "#weechat", "freenode")}@* @@ -1757,6 +2435,7 @@ Affiche un message dans la barre d'infos.@* @end itemize @* @emph{Exemple :}@* +@* @code{weechat.print_infobar (5, "message")}@* @* @@ -1777,6 +2456,7 @@ RFC 2812 : @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Exemple :}@* +@* @code{weechat.add_message_handler ("privmsg", ma_fonction)}@* @code{def ma_fonction(serveur, args):}@* @code{@ @ @ @ weechat.prnt("serveur="+serveur)}@* @@ -1798,9 +2478,16 @@ Il peut s'agir d'une commande existante, auquel cas celle-ci est @'ecras@'ee par la fonction Python. Soyez prudent en @'ecrasant les commandes WeeChat, car elles ne seront plus accessibles tant que le script Python sera charg@'e. @item @option{fonction}: fonction Python associ@'ee @`a la commande +@item @option{description}: description de la commande (affich@'ee par +/help commande) +@item @option{arguments}: br@`eve description des param@`etres de la +commande (affich@'ee par /help commande) +@item @option{arguments_description}: longue description des +param@`etres de la commande (affich@'ee par /help commande) @end itemize @* @emph{Exemple :}@* +@* @code{weechat.add_command_handler ("commande", ma_commande)}@* @code{def ma_commande(serveur, args):}@* @code{@ @ @ @ weechat.prnt("serveur:"+serveur+" param@`etres:"+args)}@* @@ -1819,6 +2506,7 @@ Ex@'ecute une commande ou envoie un message @'a un canal.@* @end itemize @* @emph{Exemples :}@* +@* @code{weechat.command ("bonjour tout le monde !")}@* @code{weechat.command ("/kick toto merci de quitter ce canal", "#weechat")}@* @code{weechat.command ("/nick newnick", "", "freenode")}@* @@ -1832,29 +2520,89 @@ Obtenir des informations vari@'ees sur WeeChat, le serveur ou l'utilisateur.@* @emph{Param@`etres :} @itemize @minus @item @option{nom}: nom de l'info @`a obtenir : +@itemize @minus +@item @option{version}: obtenir la version de WeeChat +@item @option{nick}: obtenir le pseudo +@item @option{channel}: obtenir le nom du canal +@item @option{server}: obtenir le nom du serveur +@item @option{away}: obtenir le drapeau ``away'' +@item @option{weechat_dir}: obtenir le r@'epertoire maison de WeeChat +@item @option{weechat_libdir}: obtenir le r@'epertoire ``lib'' +syst@`eme de WeeChat +@item @option{weechat_sharedir}: obtenir le r@'epertoire ``share'' +syst@`eme de partage WeeChat +@end itemize @item @option{serveur}: nom interne du serveur +@end itemize +@* +@emph{Exemples :}@* +@* +@code{$version = weechat.get_info ("version")}@* +@code{$nick = weechat.get_info ("nick", "freenode")}@* +@* + +@item +@command{weechat.get_dcc_info ( );}@* +@* +Obtenir la liste des DCC.@* + +Le tableau renvoy@'e contient les champs suivants : +@itemize @minus +@item server: le serveur IRC +@item channel: le canal IRC +@item type: le type de DCC : +@itemize @minus +@item 0: discussion (re@,cue) +@item 1: discussion (envoy@'ee) +@item 2: fichier en r@'eception +@item 3: fichier en @'emission +@end itemize +@item status: statut du DCC : @itemize @minus -@item @option{0 ou version}: obtenir la version de WeeChat -@item @option{1 ou nick}: obtenir le pseudo -@item @option{2 ou channel}: obtenir le nom du canal -@item @option{3 ou server}: obtenir le nom du serveur -@item @option{4 ou weechatdir}: obtenir le r@'epertoire maison de WeeChat -@item @option{5 ou away}: obtenir le drapeau "away" du serveur +@item 0: en attente +@item 1: en cours de connexion +@item 2: actif +@item 3: termin@'e +@item 4: @'echou@'e +@item 5: interrompu par l'utilisateur @end itemize +@item start_time: la date et heure de cr@'eation du DCC +@item start_transfer: la date et heure de d@'emarrage du transfert +@item addr: adresse de l'utilisateur distant +@item port: port utilis@'e pour le DCC +@item nick: pseudo de l'utilisateur distant +@item filename: nom de fichier +@item local_filename: nom de fichier local +@item size: taille du fichier +@item pos: position actuelle dans le fichier +@item start_resume: position de d@'emarrage apr@`es une interruption +@item bytes_per_sec: nombre d'octets transmis par seconde depuis le d@'ebut +@end itemize +@* + +@item +@command{weechat.get_config ( nom );}@* +@* +Obtenir la valeur d'une option de configuration WeeChat.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{nom}: nom de l'option @end itemize @* @emph{Exemples :}@* -@code{$version = weechat.get_info("version")}@* -@code{$nick = weechat.get_info("nick", "freenode")}@* +@* +@code{$value1 = weechat.get_config ("look_set_title");}@* +@code{$value2 = weechat.get_config ("freenode.server_autojoin");}@* @* @end itemize -@node Scripts Ruby, , Scripts Python, Extensions -@section Scripts Ruby +@subsection Scripts Ruby Non d@'evelopp@'e ! + @c **************************** Auteurs / Support ***************************** @node Auteurs / Support, , Extensions, Top diff --git a/doc/weechat_doc_pt.texi b/doc/weechat_doc_pt.texi index 5cb6a17c7..816d7e8c4 100644 --- a/doc/weechat_doc_pt.texi +++ b/doc/weechat_doc_pt.texi @@ -36,7 +36,7 @@ @title WeeChat - Guia do Utilizador @subtitle Cliente de IRC rapido, leve e extencivel -@subtitle Documenta@,{c}@~ao do WeeChat v0.1.6-cvs - 2 de outubro de 2005 +@subtitle Documenta@,{c}@~ao do WeeChat v0.1.6-cvs - 17 de outubro de 2005 @author FlashCode <@email{flashcode@@flashtux.org, flashcode AT flashtux.org}> @@ -65,7 +65,7 @@ License) vers@~ao 2 ou superior. * Introducao:: Descri@,{c}@~ao do WeeChat * Instalacao:: Instala@,{c}@~ao do WeeChat * Utilizacao:: Utiliza@,{c}@~ao do WeeChat -* Extencoes:: Exten@,{c}@~oes do Weechat +* Plugins:: WeeChat plugins * Autores/Suporte:: Contactar os autores e obter suporte @end menu @@ -198,7 +198,7 @@ Segue agora as instru@,{c}@~oes para compilar o c@'odigo fonte - @xref{Codigo Fo @c ******************************* Utilizacao ******************************** -@node Utilizacao, Extencoes, Instalacao, Top +@node Utilizacao, Plugins, Instalacao, Top @chapter Utiliza@,{c}@~ao @menu @@ -427,7 +427,7 @@ Color for input text (nick name)@* Type: color (Curses or Gtk color), default value: 'lightcyan'@* @item col_input_delimiters Color for input text (delimiters)@* -Type: color (Curses or Gtk color), default value: 'cyan'@* +Type: color (Curses or Gtk color), default value: 'lightgreen'@* @item col_input_bg Background for input window@* Type: color (Curses or Gtk color), default value: 'default'@* @@ -626,6 +626,15 @@ Type: string (any string), default value: ''@* @item proxy_password Password for proxy server@* Type: string (any string), default value: ''@* +@item plugins_path +Path for searching plugins@* +Type: string (any string), default value: '~/.weechat/plugins'@* +@item plugins_autoload +Comma separated list of plugins to load automatically at startup, "*" means all plugins found (names may be partial, for example "perl" is ok for "libperl.so")@* +Type: string (any string), default value: '*'@* +@item plugins_extension +Standard plugins extension in filename, used for autoload (if empty, then all files are loaded when autoload is "*")@* +Type: string (any string), default value: '.so'@* @item server_name Name associated to IRC server (for display only)@* Type: string (any string), default value: ''@* @@ -904,29 +913,13 @@ unbind: unbind a key (if "all", default bindings are restored)@* functions: list internal functions for key bindings@* reset: restore bindings to the default values and delete ALL personal binding (use carefully!)@* @* -@item perl [load filename] | [autoload] | [reload] | [unload] -@* -list/load/unload Perl scripts@* -@* -filename: Perl script (file) to load@* -@* -Without argument, /perl command lists all loaded Perl scripts.@* -@* -@item python [load filename] | [autoload] | [reload] | [unload] +@item plugin [load filename] | [autoload] | [reload] | [unload] @* -list/load/unload Python scripts@* +list/load/unload plugins@* @* -filename: Python script (file) to load@* +filename: WeeChat plugin (file) to load@* @* -Without argument, /python command lists all loaded Python scripts.@* -@* -@item ruby [load filename] | [autoload] | [reload] | [unload] -@* -list/load/unload Ruby scripts@* -@* -filename: Ruby script (file) to load@* -@* -Without argument, /ruby command lists all loaded Ruby scripts.@* +Without argument, /plugin command lists all loaded plugins.@* @* @item server [servername] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [del servername] @* @@ -1150,6 +1143,7 @@ channel modes:@* m: moderated channel@* l: set the user limit to channel@* b: set a ban mask to keep users out@* + e: set exception mask@* v: give/take the ability to speak on a moderated channel@* k: set a channel key (password)@* user modes:@* @@ -1497,21 +1491,613 @@ If the script is called "auto_weechat_command", you can run it with:@* @command{./auto_weechat_command "freenode,#weechat *hello"} -@c ******************************* Extencoes ********************************* +@c ********************************* Plugins ********************************** -@node Extencoes, Autores/Suporte, Utilizacao, Top -@chapter Exten@,{c}@~oes +@node Plugins, Autores/Suporte, Utilizacao, Top +@chapter Plugins @menu -* Scripts Perl:: -* Scripts Python:: -* Scripts Ruby:: +* Plugins in WeeChat:: +* Write a plugin:: +* Plugin example:: +* Scripts plugins:: @end menu -@node Scripts Perl, Scripts Python, Extencoes, Extencoes -@section Scripts Perl +@node Plugins in WeeChat, Write a plugin, Plugins, Plugins +@section Plugins in WeeChat + +A plugin is a C program which can call WeeChat functions defined in an +interface.@* +@* +This C program does not need WeeChat sources to compile and can be +dynamically loaded into WeeChat with command @command{/plugin}.@* +@* +The plugin has to be a dynamic library, for dynamic loading by +operating system. +Under GNU/Linux, the file has ``.so'' extension. + +@node Write a plugin, Plugin example, Plugins in WeeChat, Plugins +@section Write a plugin + +@subsection Base rules + +The plugin should include ``weechat-plugin.h'' file (available in +WeeChat source code).@* +This file defines structures and types used to communicate with WeeChat.@* +@* +The plugin must have some variables and functions (mandatory, without +them the plugin can't load):@* +@itemize @bullet +@item variables for plugin description: +@itemize @minus +@item plugin_name[]: plugin name +@item plugin_version[]: plugin version +@item plugin_description[]: short description of plugin +@end itemize +@item functions for init and end of plugin: +@itemize @minus +@item weechat_plugin_init: function called when plugin is loaded +@item weechat_plugin_end: function called when plugin is unloaded +@end itemize +@end itemize + +@subsection API functions + +The plugin can call some functions defined in t_weechat_plugin structure.@* +These functions are detailed below: + +@itemize @bullet +@item +@command{int ascii_strcasecmp (t_weechat_plugin *plugin, +char *string1, char *string2)}@* +@* +locale and case independent string comparison.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string1}: first string for comparison +@item @option{string2}: second string for comparison +@end itemize +@* +@emph{Return value:}@* +@* +Difference between two strings: negative if chaine1 < chaine2, +nul if chaine1 == chaine 2, positive if chaine1 > chaine2@* +@* +@emph{Example:}@* +@* +@code{if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...}@* + +@* + +@item +@command{char **explode_string (t_weechat_plugin *plugin, +char *string, char *separators, int num_items_max, int *num_items)}@* +@* +Explode a string according to one or more delimiter(s).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string to explode +@item @option{separators}: delimiters used for explosion +@item @option{num_items_max}: maximum number of items created (0 means +no limit) +@item @option{num_items}: pointer to int which will contain number of +items created +@end itemize +@* +@emph{Return value:}@* +@* +Array of strings, NULL if problem.@* +Note: the result has to be free by a call to ``free_exploded_string'' +function after use.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{char **free_exploded_string (t_weechat_plugin *plugin, +char **string)}@* +@* +Free memory used by a string explosion.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string exploded by ``explode_string'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{void exec_on_files (t_weechat_plugin *plugin, char *directory, +int (*callback)(t_weechat_plugin *, char *))}@* +@* +Execute a function on all files of a directory.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{directory}: directory for searching files +@item @option{callback}: function called for each file found +@end itemize +@* +@emph{Return value:}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{int callback (t_weechat_plugin *plugin, char *file)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "file: %s", file);}@* +@code{@ @ @ @ return 1;}@* +@code{@}}@* +@code{}@* +@code{...}@* +@code{plugin->exec_on_files (plugin, "/tmp", &callback);}@* +@* + +@item +@command{void printf (t_weechat_plugin *plugin, +char *server, char *channel, char *message, ...)}@* +@* +Display a message on a WeeChat buffer, identified by server and +channel (both may be NULL).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server to find buffer for message +display (may be NULL) +@item @option{channel}: name of channel to find buffer for message +display (may be NULL) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->printf (NULL, NULL, "hello");}@* +@code{plugin->printf (NULL, "#weechat", "hello");}@* +@code{plugin->printf ("freenode", "#weechat", "hello");}@* +@* + +@item +@command{void printf_server (t_weechat_plugin *plugin, +char *message, ...)}@* +@* +Display a message on server buffer.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_server ("hello");}@* +@* + +@item +@command{void printf_infobar (t_weechat_plugin *plugin, +int time, char *message, ...)}@* +@* +Display a message in infobar for a specified time.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{time}: time in seconds for displaying message (0 means +never erased) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_infobar (5, "hello");}@* +@* + +@item +@command{t_plugin_msg_handler *msg_handler_add (t_weechat_plugin +*plugin, char *message, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add an IRC message handler, called when an IRC message is received.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: IRC message (for example: ``PRIVMSG'') +@item @option{handler_func}: function called when message is received +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new message handler.@* +@* +@emph{Example:}@* +@* +@code{int msg_kick (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "KICK received");}@* +@code{@}}@* +@code{...}@* +@code{plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);}@* +@* + +@item +@command{void msg_handler_remove (t_weechat_plugin *plugin, +t_plugin_msg_handler *msg_handler)}@* +@* +Remove an IRC message handler.@* -@subsection Carregar/Descarregar Scripts Perl +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{msg_handler}: handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove (plugin, my_msg_handler);}@* +@* + +@item +@command{void msg_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all IRC message handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove_all (plugin);}@* +@* + +@item +@command{t_plugin_cmd_handler *cmd_handler_add (t_weechat_plugin +*plugin, char *command, char *description, char *arguments, +char *arguments_description, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add a WeeChat command handler, called when user uses command +(for example /command).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{commande}: the new command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) +@item @option{handler_func}: function called when comand is executed +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new command handler.@* +@* +@emph{Example:}@* +@* +@code{int cmd_test (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "test command, +file: %s", (arguments) ? arguments : "none");}@* +@code{@}}@* +@code{...}@* +@code{plugin->cmd_handler_add (plugin, "test", "Test command", +"[file]", "file: a file name", &cmd_test, NULL, NULL);}@* +@* + +@item +@command{void cmd_handler_remove (t_weechat_plugin *plugin, +t_plugin_cmd_handler *cmd_handler)}@* +@* +Remove a command handler.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{cmd_handler}: command handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->cmd_handler_remove (plugin, my_cmd_handler);}@* +@* + +@item +@command{void cmd_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all command handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example :}@* +@* +@code{plugin->cmd_handler_remove_all (plugin);}@* +@* + +@item +@command{void exec_command (t_weechat_plugin +*plugin, char *server, char *channel, char *command)}@* +@* +Execute a WeeChat command (or send a message to a channel).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server for executing command (may be +NULL) +@item @option{channel}: name of channel for executing command (may be +NULL) +@item @option{command}: command +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->exec_command (plugin, NULL, NULL, "/help nick");}@* +@code{plugin->exec_command (plugin, "freenode", "#weechat", "hello");}@* +@* + +@item +@command{char *get_info (t_weechat_plugin +*plugin, char *info, char *server, char *channel)}@* +@* +Return an info about WeeChat or a channel.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{info}: name of info to read: +@itemize @minus +@item @option{version}: get WeeChat's version +@item @option{nick}: get nick +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir +@end itemize +@item @option{server}: name of server for reading info (if needed) +@item @option{channel}: name of channel for reading info (if needed) +@end itemize +@* +@emph{Return value:}@* +@* +Information asked, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *version = plugin->get_info (plugin, "version", NULL, NULL);}@* +@code{char *nick = plugin->get_info (plugin, "nick", "freenode", NULL);}@* +@* + +@item +@command{t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin)}@* +@* +Returns list of DCC currently active or finished.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +Chained list of DCC.@* +Note: result has to be free by a call to ``free_dcc_info'' function +after use.@* +@* +@emph{Example:}@* +@* +@code{t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin);}@* +@code{for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = +ptr_dcc->next_dcc)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "DCC type=%d, with: %s", +ptr_dcc->type, ptr_dcc->nick);}@* +@code{@}}@* +@* + +@item +@command{void free_dcc_info (t_weechat_plugin *plugin, +t_plugin_dcc_info *dcc_info)}@* +@* +Free memory used by a DCC list.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{dcc_info}: pointer to DCC list returned by +``get_dcc_info'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->free_dcc_info (plugin, dcc_info);}@* +@* + +@item +@command{char *get_config (t_weechat_plugin +*plugin, char *option)}@* +@* +Return value of a WeeChat config option.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{option}: name of option to read +@end itemize +@* +@emph{Return value:}@* +@* +Value of option, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *value1 = plugin->get_config (plugin, "look_set_title");}@* +@code{char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Compile plugin + +Compile does not need WeeChat sources, only file +``weechat-plugin.h''.@* + +To compile a plugin which has one file ``toto.c'' (sous GNU/Linux):@* +@* +gcc -fPIC -Wall -c toto.c@* +gcc -shared -fPIC -o libtoto.so toto.o + +@subsection Load plugin under WeeChat + +Copy ``libtoto.so'' file into general plugins dir (for example +/usr/local/lib/weechat/plugins) or into user's plugins dir (for +example /home/xxxxx/.weechat/plugins).@* +@* +Under WeeChat:@* +@command{/plugin load toto} + +@node Plugin example, Scripts plugins, Write a plugin, Plugins +@section Plugin example + +Full example of plugin, which adds a /double command, which displays +two times arguments on current channel (ok that's not very useful, but +that's just an example!): + +@verbatim +#include <stdlib.h> + +#include "weechat-plugin.h" + +char plugin_name[] = "Toto"; +char plugin_version[] = "0.1"; +char plugin_description[] = "Test plugin for WeeChat"; + +/* gestionnaire de commande "/hello" */ + +int toto_cmd_double (t_weechat_plugin *plugin, char *server, + char *command, char *arguments, + char *handler_args, void *handler_pointer) +{ + if (arguments && arguments[0] && (arguments[0] != '/')) + { + plugin->exec_command (plugin, NULL, NULL, arguments); + plugin->exec_command (plugin, NULL, NULL, arguments); + } + return 1; +} + +int weechat_plugin_init (t_weechat_plugin *plugin) +{ + plugin->cmd_handler_add (plugin, "double", + "Display two times a message", + "msg", + "msg: message", + &toto_cmd_double, + NULL, NULL); + return 1; +} + +int weechat_plugin_end (t_weechat_plugin *plugin) +{ + /* on ne fait rien ici */ + return 1; +} +@end verbatim + +@node Scripts plugins, , Plugin example, Plugins +@section Scripts plugins + +Three plugins are provided with WeeChat to load scripts: Perl, +Python and Ruby. + +@subsection Perl scripts + +@subsubsection Carregar/Descarregar Scripts Perl Os Scripts Perl s@~ao carregados e descarregados com o comando @command{/perl}. (escreve @kbd{/help perl} dentro do WeeChat para obteres ajuda acerca do comando).@* @@ -1526,7 +2112,7 @@ Descarregar todos os Scripts Perl: @kbd{/perl unload}@* Listar todos os Scripts Perl: @kbd{/perl}@* @end itemize -@subsection Interface WeeChat / Perl +@subsubsection Interface WeeChat / Perl @itemize @bullet @item @@ -1544,6 +2130,7 @@ Todos os Scripts Perl para o Weechat devem invocar esta fun@,{c}@~ao.@* @end itemize @* @emph{Exemplo:}@* +@* @code{weechat::register ("sample", "1.0", "sample_end", "Sample script!");}@* @* @@ -1559,7 +2146,8 @@ Imprimne uma mensagem na canal.@* @item @option{servidor}: nome interno da servidor @end itemize @* -@emph{Exemplo:}@* +@emph{Exemplos:}@* +@* @code{weechat::print ("mensagem");}@* @code{weechat::print ("mensagem", "#weechat");}@* @code{weechat::print ("mensagem", "#weechat", "freenode");}@* @@ -1578,6 +2166,7 @@ Imprimne uma mensagem na barra do info.@* @end itemize @* @emph{Exemplo:}@* +@* @code{weechat::print_infobar (5, "mensagem");}@* @* @@ -1597,6 +2186,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Exemplo:}@* +@* @code{weechat::add_message_handler ("privmsg", my_function);}@* @code{sub my_function}@* @code{@{ }@* @@ -1617,9 +2207,16 @@ A fun@,{c}@~ao ser@'a chamada quando o utilizador a invocar utilizando @command{ @item @option{nome}: nome do novo comando@* Este nome pode pertencer a um comando já existente, o qual ser@'a sobreposto pela fun@,{c}@~ao Perl. Tem cuidado quando fizeres isto: os comandos originais não estar@~ao acessiveis antes de teres descarregado o Script Perl. @item @option{fun@,{c}@~ao}: fun@,{c}@~ao Perl ligada ao comando +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Exemplo:}@* +@* @code{weechat::add_command_handler ("command", my_command);}@* @code{sub my_command}@* @code{@{ }@* @@ -1641,6 +2238,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat::command ("hello world!");}@* @code{weechat::command ("/kick toto please leave this chan", "#weechat");}@* @code{weechat::command ("/nick newnick", "", "freenode");}@* @@ -1654,28 +2252,85 @@ Comece o v@'ario info sobre WeeChat, servidor ou usu@'ario.@* @emph{Argumentos:} @itemize @minus @item @option{nome}: nome do info a recuperar: -@item @option{servidor}: nome interno da servidor @itemize @minus -@item @option{0 ou version}: comece a vers@~ao de WeeChat -@item @option{1 ou nick}: comece o nickname -@item @option{2 ou channel}: comece o nome da canal -@item @option{3 ou server}: comece o nome do servidor -@item @option{4 ou weechatdir}: comece a WeeChat o diret@'orio home -@item @option{5 ou away}: comece a bandeira ausente para o servidor +@item @option{version}: comece a vers@~ao de WeeChat +@item @option{nick}: comece o nickname +@item @option{channel}: comece o nome da canal +@item @option{server}: comece o nome do servidor +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{servidor}: nome interno da servidor @end itemize @* @emph{Exemplos:}@* +@* @code{$version = get_info("version");}@* @code{$nick = get_info("nick", "freenode");}@* @* +@item +@command{weechat::get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) @end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* -@node Scripts Python, Scripts Ruby, Scripts Perl, Extencoes -@section Scripts Python +@item +@command{weechat::get_config ( name );}@* +@* +Get WeeChat config option value.@* -@subsection Carregar/Descarregar Scripts Python +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat::get_config ("look_set_title");}@* +@code{$value2 = weechat::get_config ("freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Python scripts + +@subsubsection Carregar/Descarregar Scripts Python Os Scripts Python s@~ao carregados e descarregados com o comando @command{/python}. (escreve @kbd{/help python} dentro do WeeChat para obteres ajuda acerca do comando).@* @@ -1690,7 +2345,7 @@ Descarregar todos os Scripts Python: @kbd{/python unload}@* Listar todos os Scripts Python: @kbd{/python}@* @end itemize -@subsection Interface WeeChat / Python +@subsubsection Interface WeeChat / Python @itemize @bullet @item @@ -1708,6 +2363,7 @@ Todos os Scripts Python para o Weechat devem invocar esta fun@,{c}@~ao.@* @end itemize @* @emph{Exemplo:}@* +@* @code{weechat.register ("sample", "1.0", "sample_end", "Sample script!")}@* @* @@ -1723,7 +2379,8 @@ Imprimne uma mensagem na canal.@* @item @option{servidor}: nome interno da servidor @end itemize @* -@emph{Exemplo:}@* +@emph{Exemplos:}@* +@* @code{weechat.prnt ("mensagem")}@* @code{weechat.prnt ("mensagem", "#weechat")}@* @code{weechat.prnt ("mensagem", "#weechat", "freenode")}@* @@ -1742,6 +2399,7 @@ Imprimne uma mensagem na barra do info.@* @end itemize @* @emph{Exemplo:}@* +@* @code{weechat.print_infobar (5, "mensagem")}@* @* @@ -1761,6 +2419,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Exemplo:}@* +@* @code{weechat.add_message_handler ("privmsg", my_function)}@* @code{def my_function(server, args):}@* @code{@ @ @ @ weechat.prnt("server="+server)}@* @@ -1780,9 +2439,16 @@ A fun@,{c}@~ao ser@'a chamada quando o utilizador a invocar utilizando @command{ @item @option{nome}: nome do novo comando@* Este nome pode pertencer a um comando já existente, o qual ser@'a sobreposto pela fun@,{c}@~ao Python. Tem cuidado quando fizeres isto: os comandos originais não estar@~ao acessiveis antes de teres descarregado o Script Python. @item @option{fun@,{c}@~ao}: fun@,{c}@~ao Python ligada ao comando +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Exemplo:}@* +@* @code{weechat.add_command_handler ("command", my_command)}@* @code{def my_command(server, args):}@* @code{@ @ @ @ weechat.prnt("Servidor:"+server+" Argumentos:"+args)}@* @@ -1801,6 +2467,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat.command ("hello world!")}@* @code{weechat.command ("/kick toto please leave this chan", "#weechat")}@* @code{weechat.command ("/nick newnick", "", "freenode")}@* @@ -1814,33 +2481,90 @@ Comece o v@'ario info sobre WeeChat, servidor ou usu@'ario.@* @emph{Argumentos:} @itemize @minus @item @option{nome}: nome do info a recuperar: -@item @option{servidor}: nome interno da servidor @itemize @minus -@item @option{0 ou version}: comece a vers@~ao de WeeChat -@item @option{1 ou nick}: comece o nickname -@item @option{2 ou channel}: comece o nome da canal -@item @option{3 ou server}: comece o nome do servidor -@item @option{4 ou weechatdir}: comece a WeeChat o diret@'orio home -@item @option{5 ou away}: comece a bandeira ausente para o servidor +@item @option{version}: comece a vers@~ao de WeeChat +@item @option{nick}: comece o nickname +@item @option{channel}: comece o nome da canal +@item @option{server}: comece o nome do servidor +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{servidor}: nome interno da servidor @end itemize @* @emph{Exemplos:}@* +@* @code{$version = weechat.get_info("version")}@* @code{$nick = weechat.get_info("nick", "freenode")}@* @* +@item +@command{weechat::get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) +@end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat.get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat.get_config ("look_set_title");}@* +@code{$value2 = weechat.get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Scripts Ruby, , Scripts Python, Extencoes -@section Scripts Ruby +@subsection Ruby scripts N@~AO DESENVOLVIDO! @c **************************** Autores/Suporte ***************************** -@node Autores/Suporte, , Extencoes, Top +@node Autores/Suporte, , Plugins, Top @chapter Autores / Suporte @ifhtml diff --git a/weechat/doc/weechat_doc_en.texi b/weechat/doc/weechat_doc_en.texi index d93e8397d..f9a43e874 100644 --- a/weechat/doc/weechat_doc_en.texi +++ b/weechat/doc/weechat_doc_en.texi @@ -35,7 +35,7 @@ @title WeeChat - User guide @subtitle Fast, light and extensible IRC client -@subtitle Documentation for WeeChat v0.1.6-cvs - October, 02 2005 +@subtitle Documentation for WeeChat v0.1.6-cvs - October, 17 2005 @author FlashCode <@email{flashcode@@flashtux.org, flashcode AT flashtux.org}> @@ -64,7 +64,7 @@ version 2 or higher. * Introduction:: What is WeeChat ? * Installation:: WeeChat installation * Usage:: WeeChat usage -* Extensions:: WeeChat extensions +* Plugins:: WeeChat plugins * Authors / Support:: Contact authors and get support @end menu @@ -199,7 +199,7 @@ Then follow instructions for source package - @xref{Source package}. @c ********************************** Usage *********************************** -@node Usage, Extensions, Installation, Top +@node Usage, Plugins, Installation, Top @chapter Usage @menu @@ -429,7 +429,7 @@ Color for input text (nick name)@* Type: color (Curses or Gtk color), default value: 'lightcyan'@* @item col_input_delimiters Color for input text (delimiters)@* -Type: color (Curses or Gtk color), default value: 'cyan'@* +Type: color (Curses or Gtk color), default value: 'lightgreen'@* @item col_input_bg Background for input window@* Type: color (Curses or Gtk color), default value: 'default'@* @@ -628,6 +628,15 @@ Type: string (any string), default value: ''@* @item proxy_password Password for proxy server@* Type: string (any string), default value: ''@* +@item plugins_path +Path for searching plugins@* +Type: string (any string), default value: '~/.weechat/plugins'@* +@item plugins_autoload +Comma separated list of plugins to load automatically at startup, "*" means all plugins found (names may be partial, for example "perl" is ok for "libperl.so")@* +Type: string (any string), default value: '*'@* +@item plugins_extension +Standard plugins extension in filename, used for autoload (if empty, then all files are loaded when autoload is "*")@* +Type: string (any string), default value: '.so'@* @item server_name Name associated to IRC server (for display only)@* Type: string (any string), default value: ''@* @@ -906,29 +915,13 @@ unbind: unbind a key (if "all", default bindings are restored)@* functions: list internal functions for key bindings@* reset: restore bindings to the default values and delete ALL personal binding (use carefully!)@* @* -@item perl [load filename] | [autoload] | [reload] | [unload] -@* -list/load/unload Perl scripts@* -@* -filename: Perl script (file) to load@* -@* -Without argument, /perl command lists all loaded Perl scripts.@* -@* -@item python [load filename] | [autoload] | [reload] | [unload] +@item plugin [load filename] | [autoload] | [reload] | [unload] @* -list/load/unload Python scripts@* +list/load/unload plugins@* @* -filename: Python script (file) to load@* +filename: WeeChat plugin (file) to load@* @* -Without argument, /python command lists all loaded Python scripts.@* -@* -@item ruby [load filename] | [autoload] | [reload] | [unload] -@* -list/load/unload Ruby scripts@* -@* -filename: Ruby script (file) to load@* -@* -Without argument, /ruby command lists all loaded Ruby scripts.@* +Without argument, /plugin command lists all loaded plugins.@* @* @item server [servername] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [del servername] @* @@ -1152,6 +1145,7 @@ channel modes:@* m: moderated channel@* l: set the user limit to channel@* b: set a ban mask to keep users out@* + e: set exception mask@* v: give/take the ability to speak on a moderated channel@* k: set a channel key (password)@* user modes:@* @@ -1499,21 +1493,613 @@ If the script is called "auto_weechat_command", you can run it with:@* @command{./auto_weechat_command "freenode,#weechat *hello"} -@c ******************************* Extensions ********************************* +@c ******************************** Plugins *********************************** -@node Extensions, Authors / Support, Usage, Top -@chapter Extensions +@node Plugins, Authors / Support, Usage, Top +@chapter Plugins @menu -* Perl scripts:: -* Python scripts:: -* Ruby scripts:: +* Plugins in WeeChat:: +* Write a plugin:: +* Plugin example:: +* Scripts plugins:: @end menu -@node Perl scripts, Python scripts, Extensions, Extensions -@section Perl scripts +@node Plugins in WeeChat, Write a plugin, Plugins, Plugins +@section Plugins in WeeChat + +A plugin is a C program which can call WeeChat functions defined in an +interface.@* +@* +This C program does not need WeeChat sources to compile and can be +dynamically loaded into WeeChat with command @command{/plugin}.@* +@* +The plugin has to be a dynamic library, for dynamic loading by +operating system. +Under GNU/Linux, the file has ``.so'' extension. + +@node Write a plugin, Plugin example, Plugins in WeeChat, Plugins +@section Write a plugin + +@subsection Base rules + +The plugin should include ``weechat-plugin.h'' file (available in +WeeChat source code).@* +This file defines structures and types used to communicate with WeeChat.@* +@* +The plugin must have some variables and functions (mandatory, without +them the plugin can't load):@* +@itemize @bullet +@item variables for plugin description: +@itemize @minus +@item plugin_name[]: plugin name +@item plugin_version[]: plugin version +@item plugin_description[]: short description of plugin +@end itemize +@item functions for init and end of plugin: +@itemize @minus +@item weechat_plugin_init: function called when plugin is loaded +@item weechat_plugin_end: function called when plugin is unloaded +@end itemize +@end itemize + +@subsection API functions + +The plugin can call some functions defined in t_weechat_plugin structure.@* +These functions are detailed below: + +@itemize @bullet +@item +@command{int ascii_strcasecmp (t_weechat_plugin *plugin, +char *string1, char *string2)}@* +@* +locale and case independent string comparison.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string1}: first string for comparison +@item @option{string2}: second string for comparison +@end itemize +@* +@emph{Return value:}@* +@* +Difference between two strings: negative if chaine1 < chaine2, +nul if chaine1 == chaine 2, positive if chaine1 > chaine2@* +@* +@emph{Example:}@* +@* +@code{if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...}@* + +@* + +@item +@command{char **explode_string (t_weechat_plugin *plugin, +char *string, char *separators, int num_items_max, int *num_items)}@* +@* +Explode a string according to one or more delimiter(s).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string to explode +@item @option{separators}: delimiters used for explosion +@item @option{num_items_max}: maximum number of items created (0 means +no limit) +@item @option{num_items}: pointer to int which will contain number of +items created +@end itemize +@* +@emph{Return value:}@* +@* +Array of strings, NULL if problem.@* +Note: the result has to be free by a call to ``free_exploded_string'' +function after use.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{char **free_exploded_string (t_weechat_plugin *plugin, +char **string)}@* +@* +Free memory used by a string explosion.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string exploded by ``explode_string'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{void exec_on_files (t_weechat_plugin *plugin, char *directory, +int (*callback)(t_weechat_plugin *, char *))}@* +@* +Execute a function on all files of a directory.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{directory}: directory for searching files +@item @option{callback}: function called for each file found +@end itemize +@* +@emph{Return value:}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{int callback (t_weechat_plugin *plugin, char *file)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "file: %s", file);}@* +@code{@ @ @ @ return 1;}@* +@code{@}}@* +@code{}@* +@code{...}@* +@code{plugin->exec_on_files (plugin, "/tmp", &callback);}@* +@* + +@item +@command{void printf (t_weechat_plugin *plugin, +char *server, char *channel, char *message, ...)}@* +@* +Display a message on a WeeChat buffer, identified by server and +channel (both may be NULL).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server to find buffer for message +display (may be NULL) +@item @option{channel}: name of channel to find buffer for message +display (may be NULL) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->printf (NULL, NULL, "hello");}@* +@code{plugin->printf (NULL, "#weechat", "hello");}@* +@code{plugin->printf ("freenode", "#weechat", "hello");}@* +@* + +@item +@command{void printf_server (t_weechat_plugin *plugin, +char *message, ...)}@* +@* +Display a message on server buffer.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_server ("hello");}@* +@* + +@item +@command{void printf_infobar (t_weechat_plugin *plugin, +int time, char *message, ...)}@* +@* +Display a message in infobar for a specified time.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{time}: time in seconds for displaying message (0 means +never erased) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_infobar (5, "hello");}@* +@* + +@item +@command{t_plugin_msg_handler *msg_handler_add (t_weechat_plugin +*plugin, char *message, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add an IRC message handler, called when an IRC message is received.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: IRC message (for example: ``PRIVMSG'') +@item @option{handler_func}: function called when message is received +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new message handler.@* +@* +@emph{Example:}@* +@* +@code{int msg_kick (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "KICK received");}@* +@code{@}}@* +@code{...}@* +@code{plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);}@* +@* + +@item +@command{void msg_handler_remove (t_weechat_plugin *plugin, +t_plugin_msg_handler *msg_handler)}@* +@* +Remove an IRC message handler.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{msg_handler}: handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove (plugin, my_msg_handler);}@* +@* + +@item +@command{void msg_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all IRC message handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove_all (plugin);}@* +@* + +@item +@command{t_plugin_cmd_handler *cmd_handler_add (t_weechat_plugin +*plugin, char *command, char *description, char *arguments, +char *arguments_description, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add a WeeChat command handler, called when user uses command +(for example /command).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{commande}: the new command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) +@item @option{handler_func}: function called when comand is executed +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new command handler.@* +@* +@emph{Example:}@* +@* +@code{int cmd_test (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "test command, +file: %s", (arguments) ? arguments : "none");}@* +@code{@}}@* +@code{...}@* +@code{plugin->cmd_handler_add (plugin, "test", "Test command", +"[file]", "file: a file name", &cmd_test, NULL, NULL);}@* +@* + +@item +@command{void cmd_handler_remove (t_weechat_plugin *plugin, +t_plugin_cmd_handler *cmd_handler)}@* +@* +Remove a command handler.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{cmd_handler}: command handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->cmd_handler_remove (plugin, my_cmd_handler);}@* +@* + +@item +@command{void cmd_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all command handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example :}@* +@* +@code{plugin->cmd_handler_remove_all (plugin);}@* +@* + +@item +@command{void exec_command (t_weechat_plugin +*plugin, char *server, char *channel, char *command)}@* +@* +Execute a WeeChat command (or send a message to a channel).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server for executing command (may be +NULL) +@item @option{channel}: name of channel for executing command (may be +NULL) +@item @option{command}: command +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->exec_command (plugin, NULL, NULL, "/help nick");}@* +@code{plugin->exec_command (plugin, "freenode", "#weechat", "hello");}@* +@* + +@item +@command{char *get_info (t_weechat_plugin +*plugin, char *info, char *server, char *channel)}@* +@* +Return an info about WeeChat or a channel.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{info}: name of info to read: +@itemize @minus +@item @option{version}: get WeeChat's version +@item @option{nick}: get nick +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir +@end itemize +@item @option{server}: name of server for reading info (if needed) +@item @option{channel}: name of channel for reading info (if needed) +@end itemize +@* +@emph{Return value:}@* +@* +Information asked, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *version = plugin->get_info (plugin, "version", NULL, NULL);}@* +@code{char *nick = plugin->get_info (plugin, "nick", "freenode", NULL);}@* +@* + +@item +@command{t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin)}@* +@* +Returns list of DCC currently active or finished.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +Chained list of DCC.@* +Note: result has to be free by a call to ``free_dcc_info'' function +after use.@* +@* +@emph{Example:}@* +@* +@code{t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin);}@* +@code{for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = +ptr_dcc->next_dcc)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "DCC type=%d, with: %s", +ptr_dcc->type, ptr_dcc->nick);}@* +@code{@}}@* +@* -@subsection Load/unload Perl scripts +@item +@command{void free_dcc_info (t_weechat_plugin *plugin, +t_plugin_dcc_info *dcc_info)}@* +@* +Free memory used by a DCC list.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{dcc_info}: pointer to DCC list returned by +``get_dcc_info'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->free_dcc_info (plugin, dcc_info);}@* +@* + +@item +@command{char *get_config (t_weechat_plugin +*plugin, char *option)}@* +@* +Return value of a WeeChat config option.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{option}: name of option to read +@end itemize +@* +@emph{Return value:}@* +@* +Value of option, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *value1 = plugin->get_config (plugin, "look_set_title");}@* +@code{char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Compile plugin + +Compile does not need WeeChat sources, only file +``weechat-plugin.h''.@* + +To compile a plugin which has one file ``toto.c'' (sous GNU/Linux):@* +@* +gcc -fPIC -Wall -c toto.c@* +gcc -shared -fPIC -o libtoto.so toto.o + +@subsection Load plugin under WeeChat + +Copy ``libtoto.so'' file into general plugins dir (for example +/usr/local/lib/weechat/plugins) or into user's plugins dir (for +example /home/xxxxx/.weechat/plugins).@* +@* +Under WeeChat:@* +@command{/plugin load toto} + +@node Plugin example, Scripts plugins, Write a plugin, Plugins +@section Plugin example + +Full example of plugin, which adds a /double command, which displays +two times arguments on current channel (ok that's not very useful, but +that's just an example!): + +@verbatim +#include <stdlib.h> + +#include "weechat-plugin.h" + +char plugin_name[] = "Toto"; +char plugin_version[] = "0.1"; +char plugin_description[] = "Test plugin for WeeChat"; + +/* gestionnaire de commande "/hello" */ + +int toto_cmd_double (t_weechat_plugin *plugin, char *server, + char *command, char *arguments, + char *handler_args, void *handler_pointer) +{ + if (arguments && arguments[0] && (arguments[0] != '/')) + { + plugin->exec_command (plugin, NULL, NULL, arguments); + plugin->exec_command (plugin, NULL, NULL, arguments); + } + return 1; +} + +int weechat_plugin_init (t_weechat_plugin *plugin) +{ + plugin->cmd_handler_add (plugin, "double", + "Display two times a message", + "msg", + "msg: message", + &toto_cmd_double, + NULL, NULL); + return 1; +} + +int weechat_plugin_end (t_weechat_plugin *plugin) +{ + /* on ne fait rien ici */ + return 1; +} +@end verbatim + +@node Scripts plugins, , Plugin example, Plugins +@section Scripts plugins + +Three plugins are provided with WeeChat to use script languages: Perl, +Python and Ruby. + +@subsection Perl scripts + +@subsubsection Load/unload Perl scripts Perl scripts are loaded and unloaded with @command{/perl} command. (type @kbd{/help perl} within WeeChat to get help about command).@* @@ -1528,7 +2114,7 @@ Unload all Perl scripts: @kbd{/perl unload}@* List all Perl scripts: @kbd{/perl}@* @end itemize -@subsection WeeChat / Perl API +@subsubsection WeeChat / Perl API @itemize @bullet @item @@ -1548,6 +2134,7 @@ unloaded (optional parameter, empty string means nothing is called at the end) @end itemize @* @emph{Example:}@* +@* @code{weechat::register ("sample", "1.0", "sample_end", "Sample script!");}@* @* @@ -1564,6 +2151,7 @@ Print message in a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat::print ("message");}@* @code{weechat::print ("message", "#weechat");}@* @code{weechat::print ("message", "#weechat", "freenode");}@* @@ -1582,6 +2170,7 @@ Print message in infobar.@* @end itemize @* @emph{Example:}@* +@* @code{weechat::print_infobar (5, "message");}@* @* @@ -1601,6 +2190,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Example:}@* +@* @code{weechat::add_message_handler ("privmsg", my_function);}@* @code{sub my_function}@* @code{@{ }@* @@ -1624,9 +2214,16 @@ This name may be existing command, so that the command is overrided by Perl function. Be careful when overriding WeeChat commands, they'll not be available until your Perl script will be unloaded. @item @option{function}: Perl function linked with command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Example:}@* +@* @code{weechat::add_command_handler ("command", my_command);}@* @code{sub my_command}@* @code{@{ }@* @@ -1648,6 +2245,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat::command ("hello world!");}@* @code{weechat::command ("/kick toto please leave this chan", "#weechat");}@* @code{weechat::command ("/nick newnick", "", "freenode");}@* @@ -1661,28 +2259,86 @@ Get various info about WeeChat, server or user.@* @emph{Arguments:} @itemize @minus @item @option{name}: name of info to retrieve: +@itemize @minus +@item @option{version}: get WeeChat version +@item @option{nick}: get nickname +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir + +@end itemize @item @option{server}: internal name of server +@end itemize +@* +@emph{Examples:}@* +@* +@code{$version = weechat::get_info("version");}@* +@code{$nick = weechat::get_info("nick", "freenode");}@* +@* + +@item +@command{weechat::get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: @itemize @minus -@item @option{0 or version}: get WeeChat version -@item @option{1 or nick}: get nickname -@item @option{2 or channel}: get channel name -@item @option{3 or server}: get server name -@item @option{4 or weechatdir}: get WeeChat home directory -@item @option{5 or away}: get away flag for server +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) @end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat::get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option @end itemize @* @emph{Examples:}@* -@code{$version = get_info("version");}@* -@code{$nick = get_info("nick", "freenode");}@* +@* +@code{$value1 = weechat::get_config ("look_set_title");}@* +@code{$value2 = weechat::get_config ("freenode.server_autojoin");}@* @* @end itemize -@node Python scripts, Ruby scripts, Perl scripts, Extensions -@section Python scripts +@subsection Python scripts -@subsection Load/unload Python scripts +@subsubsection Load/unload Python scripts Python scripts are loaded and unloaded with @command{/python} command. (type @kbd{/help python} within WeeChat to get help about command).@* @@ -1697,7 +2353,7 @@ Unload all Python scripts: @kbd{/python unload}@* List all Python scripts: @kbd{/python}@* @end itemize -@subsection WeeChat / Python API +@subsubsection WeeChat / Python API @itemize @bullet @item @@ -1717,6 +2373,7 @@ unloaded (optional parameter, empty string means nothing is called at the end) @end itemize @* @emph{Example:}@* +@* @code{weechat.register ("sample", "1.0", "sample_end", "Sample script!")}@* @* @@ -1733,6 +2390,7 @@ Print message in a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat.prnt ("message")}@* @code{weechat.prnt ("message", "#weechat")}@* @code{weechat.prnt ("message", "#weechat", "freenode")}@* @@ -1751,6 +2409,7 @@ Print message in infobar.@* @end itemize @* @emph{Example:}@* +@* @code{weechat.print_infobar (5, "message")}@* @* @@ -1770,6 +2429,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Example:}@* +@* @code{weechat.add_message_handler ("privmsg", my_function)}@* @code{def my_function(server, args):}@* @code{@ @ @ @ weechat.prnt("server="+server)}@* @@ -1791,9 +2451,16 @@ This name may be existing command, so that the command is overrided by Python function. Be careful when overriding WeeChat commands, they'll not be available until your Python script will be unloaded. @item @option{function}: Python function linked with command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Example:}@* +@* @code{weechat.add_command_handler ("command", my_command)}@* @code{def my_command(server, args):}@* @code{@ @ @ @ weechat.prnt("server:"+server+" arguments:"+args)}@* @@ -1812,6 +2479,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat.command ("hello world!")}@* @code{weechat.command ("/kick toto please leave this chan", "#weechat")}@* @code{weechat.command ("/nick newnick", "", "freenode")}@* @@ -1826,33 +2494,90 @@ Get various info about WeeChat, server or user.@* @emph{Arguments:} @itemize @minus @item @option{name}: name of info to retrieve: -@item @option{server}: internal name of server @itemize @minus -@item @option{0 or version}: get WeeChat version -@item @option{1 or nick}: get nickname -@item @option{2 or channel}: get channel name -@item @option{3 or server}: get server name -@item @option{4 or weechatdir}: get WeeChat home directory -@item @option{5 or away}: get away flag for server +@item @option{version}: get WeeChat version +@item @option{nick}: get nickname +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{server}: internal name of server @end itemize @* @emph{Examples:}@* +@* @code{$version = weechat.get_info("version")}@* @code{$nick = weechat.get_info("nick", "freenode")}@* @* +@item +@command{weechat.get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) +@end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat.get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat.get_config ("look_set_title");}@* +@code{$value2 = weechat.get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Ruby scripts, , Python scripts, Extensions -@section Ruby scripts +@subsection Ruby scripts Not developed! @c **************************** Authors / Support ***************************** -@node Authors / Support, , Extensions, Top +@node Authors / Support, , Plugins, Top @chapter Authors / Support @ifhtml diff --git a/weechat/doc/weechat_doc_es.texi b/weechat/doc/weechat_doc_es.texi index df574373c..de0cd21fe 100644 --- a/weechat/doc/weechat_doc_es.texi +++ b/weechat/doc/weechat_doc_es.texi @@ -36,7 +36,7 @@ @title WeeChat - Gui@'on de usuario. @subtitle Cliente IRC r@'apido, peque@~no y extensible -@subtitle Documentaci@'on para WeeChat v0.1.6-cvs - 2 de octubre de 2005 +@subtitle Documentaci@'on para WeeChat v0.1.6-cvs - 17 de octubre de 2005 @author FlashCode <@email{flashcode@@flashtux.org, flashcode AT flashtux.org}> @@ -66,7 +66,7 @@ License versi@'on 2 o posterior. * Introduccion:: Presentaci@'on de WeeChat * Instalacion:: Instalaci@'on de WeeChat * Uso:: Utilizaci@'on de WeeChat -* Extensiones:: Extensiones de WeeChat +* Plugins:: WeeChat plugins * Autores / Soporte:: Contactar los autores y obtener soporte @end menu @@ -201,7 +201,7 @@ Luego, lee las instructiones para Paquetes de fuentes - @xref{Paquetes de fuente @c ******************************* Utilisaci@'on ******************************** -@node Uso, Extensiones, Instalacion, Top +@node Uso, Plugins, Instalacion, Top @chapter Uso @menu @@ -429,7 +429,7 @@ Color para el texto de entrada (alias)@* Typo: color (color Curses @'o Gtk), valor por defecto: 'lightcyan'@* @item col_input_delimiters Color for input text (delimiters)@* -Typo: color (color Curses @'o Gtk), valor por defecto: 'cyan'@* +Typo: color (color Curses @'o Gtk), valor por defecto: 'lightgreen'@* @item col_input_bg Color de fondo para la ventana de entrada@* Typo: color (color Curses @'o Gtk), valor por defecto: 'default'@* @@ -628,6 +628,15 @@ Typo: cadena (cualquier cadena), valor por defecto: ''@* @item proxy_password Contrase@~na para el servidor proxy@* Typo: cadena (cualquier cadena), valor por defecto: ''@* +@item plugins_path +Path for searching plugins@* +Typo: cadena (cualquier cadena), valor por defecto: '~/.weechat/plugins'@* +@item plugins_autoload +Comma separated list of plugins to load automatically at startup, "*" means all plugins found (names may be partial, for example "perl" is ok for "libperl.so")@* +Typo: cadena (cualquier cadena), valor por defecto: '*'@* +@item plugins_extension +Standard plugins extension in filename, used for autoload (if empty, then all files are loaded when autoload is "*")@* +Typo: cadena (cualquier cadena), valor por defecto: '.so'@* @item server_name Nombre asociado al servidor IRC (para mostrar solamente)@* Typo: cadena (cualquier cadena), valor por defecto: ''@* @@ -906,29 +915,13 @@ desatar: desata una clave(si "all", se restauran los anclajes por defecto)@* funciones: lista funciones internas para el anclaje de claves@* reset: restaura anclajes a los valores por defecto y elimina todos los anclajes personales (usar cuidadosamente)@* @* -@item perl [load fichero] | [autoload] | [reload] | [unload] -@* -lista/carga/descarga de los Perl scripts@* -@* -fichero: Perl script (archivo) a cargar@* -@* -Sin argumentos, el comando /perl lista todos los Perl scripts cargados.@* -@* -@item python [load fichero] | [autoload] | [reload] | [unload] +@item plugin [load fichero] | [autoload] | [reload] | [unload] @* -lista/carga/descarga de los Python scripts@* +list/load/unload plugins@* @* -fichero: Python script (archivo) a cargar@* +filename: WeeChat plugin (file) to load@* @* -Sin argumentos, el comando /python lista todos los Python scripts cargados.@* -@* -@item ruby [load fichero] | [autoload] | [reload] | [unload] -@* -lista/carga/descarga de los Ruby scripts@* -@* -fichero: Ruby script (archivo) a cargar@* -@* -Sin argumentos, el comando /ruby lista todos los Ruby scripts cargados.@* +Without argument, /plugin command lists all loaded plugins.@* @* @item server [nombre_de_servidor] | [nombre_de_servidor nombre/IP puerto [-auto | -noauto] [-ipv6] [-ssl] [-pwd contrase@~na] [-nicks alias1 alias2 alias3] [-username nombre de usuario] [-realname nombre_real] [-command comando] [-autojoin canal[,canal]] ] | [del nombre_de_servidor] @* @@ -1141,25 +1134,26 @@ mensaje: mensaje a enviar@* @* cambiar modo del canal o del usuario@* @* -modos del canal:@* - canal: nombre del canal a modificar@* - o: dar/coger privilegios de operador de canal@* - p: indicador de canal privado@* - s: indicador de canal secreto@* - i: indicador de canal s@'olo con invitaci@'on@* - t: indicador de tema s@'olo modificable por operador de canal@* - n: ningún mensaje al canal desde el exterior@* - m: canal moderado@* - l: fijar el l@'imite de usuarios para el canal@* - b: establecer una m@'ascara de baneo para mantener fuera a usuarios@* - v: dar/quitar la capacidad de hablar en un canal moderado@* - k: definir una clave (contrase@~na) de canal@* -modos de usuario:@* - usuario: usuario a modificar@* - i: marcar a un usuario como invisible@* - s: marcar a un usuario para recibir noticias del servidor@* - w: el usuario recibe golpes@* - o: indicador de operador@* +channel modes:@* + channel: channel name to modify@* + o: give/take channel operator privileges@* + p: private channel flag@* + s: secret channel flag@* + i: invite-only channel flag@* + t: topic settable by channel operator only flag@* + n: no messages to channel from clients on the outside@* + m: moderated channel@* + l: set the user limit to channel@* + b: set a ban mask to keep users out@* + e: set exception mask@* + v: give/take the ability to speak on a moderated channel@* + k: set a channel key (password)@* +user modes:@* + nickname: nickname to modify@* + i: mark a user as invisible@* + s: mark a user for receive server notices@* + w: user receives wallops@* + o: operator flag@* @* @item motd [target] @* @@ -1502,21 +1496,613 @@ Si el script se llama "auto_weechat_command", puedes ejecutarlo hac@'i:@* @command{./auto_weechat_command "freenode,#weechat *Hola"} -@c ******************************* Extensions ********************************* +@c ******************************** Plugins *********************************** -@node Extensiones, Autores / Soporte, Uso, Top -@chapter Extensiones +@node Plugins, Autores / Soporte, Uso, Top +@chapter Plugins @menu -* Programas Perl:: -* Programas Python:: -* Programas Ruby:: +* Plugins in WeeChat:: +* Write a plugin:: +* Plugin example:: +* Scripts plugins:: @end menu -@node Programas Perl, Programas Python, Extensiones, Extensiones -@section Programas Perl +@node Plugins in WeeChat, Write a plugin, Plugins, Plugins +@section Plugins in WeeChat + +A plugin is a C program which can call WeeChat functions defined in an +interface.@* +@* +This C program does not need WeeChat sources to compile and can be +dynamically loaded into WeeChat with command @command{/plugin}.@* +@* +The plugin has to be a dynamic library, for dynamic loading by +operating system. +Under GNU/Linux, the file has ``.so'' extension. + +@node Write a plugin, Plugin example, Plugins in WeeChat, Plugins +@section Write a plugin + +@subsection Base rules + +The plugin should include ``weechat-plugin.h'' file (available in +WeeChat source code).@* +This file defines structures and types used to communicate with WeeChat.@* +@* +The plugin must have some variables and functions (mandatory, without +them the plugin can't load):@* +@itemize @bullet +@item variables for plugin description: +@itemize @minus +@item plugin_name[]: plugin name +@item plugin_version[]: plugin version +@item plugin_description[]: short description of plugin +@end itemize +@item functions for init and end of plugin: +@itemize @minus +@item weechat_plugin_init: function called when plugin is loaded +@item weechat_plugin_end: function called when plugin is unloaded +@end itemize +@end itemize + +@subsection API functions + +The plugin can call some functions defined in t_weechat_plugin structure.@* +These functions are detailed below: + +@itemize @bullet +@item +@command{int ascii_strcasecmp (t_weechat_plugin *plugin, +char *string1, char *string2)}@* +@* +locale and case independent string comparison.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string1}: first string for comparison +@item @option{string2}: second string for comparison +@end itemize +@* +@emph{Return value:}@* +@* +Difference between two strings: negative if chaine1 < chaine2, +nul if chaine1 == chaine 2, positive if chaine1 > chaine2@* +@* +@emph{Example:}@* +@* +@code{if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...}@* + +@* + +@item +@command{char **explode_string (t_weechat_plugin *plugin, +char *string, char *separators, int num_items_max, int *num_items)}@* +@* +Explode a string according to one or more delimiter(s).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string to explode +@item @option{separators}: delimiters used for explosion +@item @option{num_items_max}: maximum number of items created (0 means +no limit) +@item @option{num_items}: pointer to int which will contain number of +items created +@end itemize +@* +@emph{Return value:}@* +@* +Array of strings, NULL if problem.@* +Note: the result has to be free by a call to ``free_exploded_string'' +function after use.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{char **free_exploded_string (t_weechat_plugin *plugin, +char **string)}@* +@* +Free memory used by a string explosion.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string exploded by ``explode_string'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{void exec_on_files (t_weechat_plugin *plugin, char *directory, +int (*callback)(t_weechat_plugin *, char *))}@* +@* +Execute a function on all files of a directory.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{directory}: directory for searching files +@item @option{callback}: function called for each file found +@end itemize +@* +@emph{Return value:}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{int callback (t_weechat_plugin *plugin, char *file)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "file: %s", file);}@* +@code{@ @ @ @ return 1;}@* +@code{@}}@* +@code{}@* +@code{...}@* +@code{plugin->exec_on_files (plugin, "/tmp", &callback);}@* +@* + +@item +@command{void printf (t_weechat_plugin *plugin, +char *server, char *channel, char *message, ...)}@* +@* +Display a message on a WeeChat buffer, identified by server and +channel (both may be NULL).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server to find buffer for message +display (may be NULL) +@item @option{channel}: name of channel to find buffer for message +display (may be NULL) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->printf (NULL, NULL, "hello");}@* +@code{plugin->printf (NULL, "#weechat", "hello");}@* +@code{plugin->printf ("freenode", "#weechat", "hello");}@* +@* + +@item +@command{void printf_server (t_weechat_plugin *plugin, +char *message, ...)}@* +@* +Display a message on server buffer.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_server ("hello");}@* +@* + +@item +@command{void printf_infobar (t_weechat_plugin *plugin, +int time, char *message, ...)}@* +@* +Display a message in infobar for a specified time.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{time}: time in seconds for displaying message (0 means +never erased) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_infobar (5, "hello");}@* +@* + +@item +@command{t_plugin_msg_handler *msg_handler_add (t_weechat_plugin +*plugin, char *message, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add an IRC message handler, called when an IRC message is received.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: IRC message (for example: ``PRIVMSG'') +@item @option{handler_func}: function called when message is received +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new message handler.@* +@* +@emph{Example:}@* +@* +@code{int msg_kick (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "KICK received");}@* +@code{@}}@* +@code{...}@* +@code{plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);}@* +@* + +@item +@command{void msg_handler_remove (t_weechat_plugin *plugin, +t_plugin_msg_handler *msg_handler)}@* +@* +Remove an IRC message handler.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{msg_handler}: handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove (plugin, my_msg_handler);}@* +@* + +@item +@command{void msg_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all IRC message handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove_all (plugin);}@* +@* + +@item +@command{t_plugin_cmd_handler *cmd_handler_add (t_weechat_plugin +*plugin, char *command, char *description, char *arguments, +char *arguments_description, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add a WeeChat command handler, called when user uses command +(for example /command).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{commande}: the new command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) +@item @option{handler_func}: function called when comand is executed +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new command handler.@* +@* +@emph{Example:}@* +@* +@code{int cmd_test (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "test command, +file: %s", (arguments) ? arguments : "none");}@* +@code{@}}@* +@code{...}@* +@code{plugin->cmd_handler_add (plugin, "test", "Test command", +"[file]", "file: a file name", &cmd_test, NULL, NULL);}@* +@* + +@item +@command{void cmd_handler_remove (t_weechat_plugin *plugin, +t_plugin_cmd_handler *cmd_handler)}@* +@* +Remove a command handler.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{cmd_handler}: command handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->cmd_handler_remove (plugin, my_cmd_handler);}@* +@* + +@item +@command{void cmd_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all command handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example :}@* +@* +@code{plugin->cmd_handler_remove_all (plugin);}@* +@* + +@item +@command{void exec_command (t_weechat_plugin +*plugin, char *server, char *channel, char *command)}@* +@* +Execute a WeeChat command (or send a message to a channel).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server for executing command (may be +NULL) +@item @option{channel}: name of channel for executing command (may be +NULL) +@item @option{command}: command +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->exec_command (plugin, NULL, NULL, "/help nick");}@* +@code{plugin->exec_command (plugin, "freenode", "#weechat", "hello");}@* +@* + +@item +@command{char *get_info (t_weechat_plugin +*plugin, char *info, char *server, char *channel)}@* +@* +Return an info about WeeChat or a channel.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{info}: name of info to read: +@itemize @minus +@item @option{version}: get WeeChat's version +@item @option{nick}: get nick +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir +@end itemize +@item @option{server}: name of server for reading info (if needed) +@item @option{channel}: name of channel for reading info (if needed) +@end itemize +@* +@emph{Return value:}@* +@* +Information asked, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *version = plugin->get_info (plugin, "version", NULL, NULL);}@* +@code{char *nick = plugin->get_info (plugin, "nick", "freenode", NULL);}@* +@* + +@item +@command{t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin)}@* +@* +Returns list of DCC currently active or finished.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +Chained list of DCC.@* +Note: result has to be free by a call to ``free_dcc_info'' function +after use.@* +@* +@emph{Example:}@* +@* +@code{t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin);}@* +@code{for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = +ptr_dcc->next_dcc)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "DCC type=%d, with: %s", +ptr_dcc->type, ptr_dcc->nick);}@* +@code{@}}@* +@* + +@item +@command{void free_dcc_info (t_weechat_plugin *plugin, +t_plugin_dcc_info *dcc_info)}@* +@* +Free memory used by a DCC list.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{dcc_info}: pointer to DCC list returned by +``get_dcc_info'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->free_dcc_info (plugin, dcc_info);}@* +@* + +@item +@command{char *get_config (t_weechat_plugin +*plugin, char *option)}@* +@* +Return value of a WeeChat config option.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{option}: name of option to read +@end itemize +@* +@emph{Return value:}@* +@* +Value of option, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *value1 = plugin->get_config (plugin, "look_set_title");}@* +@code{char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Compile plugin + +Compile does not need WeeChat sources, only file +``weechat-plugin.h''.@* + +To compile a plugin which has one file ``toto.c'' (sous GNU/Linux):@* +@* +gcc -fPIC -Wall -c toto.c@* +gcc -shared -fPIC -o libtoto.so toto.o + +@subsection Load plugin under WeeChat -@subsection Cargar/descargar programas Perl +Copy ``libtoto.so'' file into general plugins dir (for example +/usr/local/lib/weechat/plugins) or into user's plugins dir (for +example /home/xxxxx/.weechat/plugins).@* +@* +Under WeeChat:@* +@command{/plugin load toto} + +@node Plugin example, Scripts plugins, Write a plugin, Plugins +@section Plugin example + +Full example of plugin, which adds a /double command, which displays +two times arguments on current channel (ok that's not very useful, but +that's just an example!): + +@verbatim +#include <stdlib.h> + +#include "weechat-plugin.h" + +char plugin_name[] = "Toto"; +char plugin_version[] = "0.1"; +char plugin_description[] = "Test plugin for WeeChat"; + +/* gestionnaire de commande "/hello" */ + +int toto_cmd_double (t_weechat_plugin *plugin, char *server, + char *command, char *arguments, + char *handler_args, void *handler_pointer) +{ + if (arguments && arguments[0] && (arguments[0] != '/')) + { + plugin->exec_command (plugin, NULL, NULL, arguments); + plugin->exec_command (plugin, NULL, NULL, arguments); + } + return 1; +} + +int weechat_plugin_init (t_weechat_plugin *plugin) +{ + plugin->cmd_handler_add (plugin, "double", + "Display two times a message", + "msg", + "msg: message", + &toto_cmd_double, + NULL, NULL); + return 1; +} + +int weechat_plugin_end (t_weechat_plugin *plugin) +{ + /* on ne fait rien ici */ + return 1; +} +@end verbatim + +@node Scripts plugins, , Plugin example, Plugins +@section Scripts plugins + +Three plugins are provided with WeeChat to load scripts: Perl, +Python and Ruby. + +@subsection Perl scripts + +@subsubsection Cargar/descargar programas Perl Los programas Perl se cargan y descargan con el comando @command{/perl} (escribiendo @kbd{/help perl} en WeeChat para obtener la ayuda acerca del comando).@* @@ -1530,7 +2116,7 @@ Cargar un programa Perl: @kbd{/perl load /tmp/ejemplo.pl}@* Listar los programas Perl cargados: @kbd{/perl}@* @end itemize -@subsection Interfaz WeeChat / Perl +@subsubsection Interfaz WeeChat / Perl @itemize @bullet @item @@ -1550,6 +2136,7 @@ tener un nombre distinto) @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat::register ("ejemplo", "1.0", "fin_ejemplo", "programa de ejemplo...");}@* @* @@ -1565,7 +2152,8 @@ Escribe un mensaje en un canal.@* @item @option{servidor}: (opcional) nombre interno del servidor @end itemize @* -@emph{Ejemplo:}@* +@emph{Ejemplos:}@* +@* @code{weechat::print ("mensaje");}@* @code{weechat::print ("mensaje", "#weechat");}@* @code{weechat::print ("mensaje", "#weechat", "freenode");}@* @@ -1584,6 +2172,7 @@ Escribir un mensaje en la barra de informaciones.@* @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat::print_infobar (5, "mensaje");}@* @* @@ -1604,6 +2193,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat::add_message_handler ("privmsg", mi_funcion);}@* @code{sub mi_funcion}@* @code{@{ }@* @@ -1627,9 +2217,16 @@ Puede ser un comando que ya existe, y en este caso el nuevo comando sustituir@'a el antiguo. Ten cuidado cuando sustituyas a un comando de WeeChat, no podr@'a acceder al antiguo comando si el script Perl est@'a cargado. @item @option{funcion}: funci@'on Perl assiciada al comando. +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat::add_command_handler ("comando", mi_comando);}@* @code{sub mi_comando}@* @code{@{ }@* @@ -1651,6 +2248,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat::command ("hello world!");}@* @code{weechat::command ("/kick toto please leave this chan", "#weechat");}@* @code{weechat::command ("/nick newnick", "", "freenode");}@* @@ -1664,28 +2262,85 @@ Obtener informaciones distintas sobre WeeChat, el servidor o el usuario.@* @emph{Par@'ametros:} @itemize @minus @item @option{nombre}: nombre de la informaci@'on que se quiere obtener: -@item @option{servidor}: nombre interno del servidor @itemize @minus -@item @option{0 o version}: obtener la versi@'on de WeeChat -@item @option{1 o nick}: obtener el seud@'onimo -@item @option{2 o channel}: obtener el nombre del canal -@item @option{3 o server}: obtener el nombre del servidor -@item @option{4 o weechatdir}: obtener el directorio home de WeeChat -@item @option{5 o away}: obtener la informaci@'on "away" del servidor +@item @option{version}: obtener la versi@'on de WeeChat +@item @option{nick}: obtener el seud@'onimo +@item @option{channel}: obtener el nombre del canal +@item @option{server}: obtener el nombre del servidor +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{servidor}: nombre interno del servidor @end itemize @* @emph{Ejemplos:}@* +@* @code{$version = weechat::get_info("version");}@* @code{$nick = weechat::get_info("nick", "freenode");}@* @* +@item +@command{weechat::get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) +@end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat::get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat::get_config ("look_set_title");}@* +@code{$value2 = weechat::get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Programas Python, Programas Ruby, Programas Perl, Extensiones -@section Programas Python +@subsection Python scripts -@subsection Cargar/descargar programas Python +@subsubsection Cargar/descargar programas Python Los programas Python se cargan y descargan con el comando @command{/python} (escribiendo @kbd{/help python} en WeeChat para obtener la ayuda acerca del comando).@* @@ -1699,7 +2354,7 @@ Cargar un programa Python: @kbd{/python load /tmp/ejemplo.py}@* Listar los programas Python cargados: @kbd{/python}@* @end itemize -@subsection Interfaz WeeChat / Python +@subsubsection Interfaz WeeChat / Python @itemize @bullet @item @@ -1719,6 +2374,7 @@ tener un nombre distinto) @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat.register ("ejemplo", "1.0", "fin_ejemplo", "programa de ejemplo...")}@* @* @@ -1734,7 +2390,8 @@ Escribe un mensaje en un canal.@* @item @option{servidor}: (opcional) nombre interno del servidor @end itemize @* -@emph{Ejemplo:}@* +@emph{Ejemplos:}@* +@* @code{weechat.prnt ("mensaje")}@* @code{weechat.prnt ("mensaje", "#weechat")}@* @code{weechat.prnt ("mensaje", "#weechat", "freenode")}@* @@ -1753,6 +2410,7 @@ Escribir un mensaje en la barra de informaciones.@* @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat.print_infobar (5, "mensaje")}@* @* @@ -1773,6 +2431,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat.add_message_handler ("privmsg", mi_funcion)}@* @code{def mi_funcion(servidor, args):}@* @code{@ @ @ @ weechat.prnt("servidor="+servidor)}@* @@ -1794,9 +2453,16 @@ Puede ser un comando que ya existe, y en este caso el nuevo comando sustituir@'a el antiguo. Ten cuidado cuando sustituyas a un comando de WeeChat, no podr@'a acceder al antiguo comando si el script Python est@'a cargado. @item @option{funcion}: funci@'on Python assiciada al comando. +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Ejemplo:}@* +@* @code{weechat.add_command_handler ("comando", mi_comando)}@* @code{def mi_comando(servidor, args):}@* @code{@ @ @ @ weechat.prnt("Servidor:"+servidor+" Par@'ametros:"+args)}@* @@ -1815,6 +2481,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat.command ("hello world!")}@* @code{weechat.command ("/kick toto please leave this chan", "#weechat")}@* @code{weechat.command ("/nick newnick", "", "freenode")}@* @@ -1828,32 +2495,90 @@ Obtener informaciones distintas sobre WeeChat, el servidor o el usuario.@* @emph{Par@'ametros:} @itemize @minus @item @option{nombre}: nombre de la informaci@'on que se quiere obtener: -@item @option{servidor}: nombre interno del servidor @itemize @minus -@item @option{0 o version}: obtener la versi@'on de WeeChat -@item @option{1 o nick}: obtener el seud@'onimo -@item @option{2 o channel}: obtener el nombre del canal -@item @option{3 o server}: obtener el nombre del servidor -@item @option{4 o weechatdir}: obtener el directorio home de WeeChat -@item @option{5 o away}: obtener la informaci@'on "away" del servidor +@item @option{version}: obtener la versi@'on de WeeChat +@item @option{nick}: obtener el seud@'onimo +@item @option{channel}: obtener el nombre del canal +@item @option{server}: obtener el nombre del servidor +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{servidor}: nombre interno del servidor @end itemize @* @emph{Ejemplos:}@* +@* @code{$version = weechat.get_info("version")}@* @code{$nick = weechat.get_info("nick", "freenode")}@* @* +@item +@command{weechat.get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) +@end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat.get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat.get_config ("look_set_title");}@* +@code{$value2 = weechat.get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Programas Ruby, , Programas Python, Extensiones -@section Programas Ruby +@subsection Ruby scripts @exclamdown{}No desarrollado! + @c **************************** Autores / Soporte ***************************** -@node Autores / Soporte, , Extensiones, Top +@node Autores / Soporte, , Plugins, Top @chapter Autores / Soporte @ifhtml diff --git a/weechat/doc/weechat_doc_fr.texi b/weechat/doc/weechat_doc_fr.texi index a3afdea6b..4c40f648c 100644 --- a/weechat/doc/weechat_doc_fr.texi +++ b/weechat/doc/weechat_doc_fr.texi @@ -36,7 +36,7 @@ @title WeeChat - Guide utilisateur @subtitle Client IRC rapide, l@'eger et extensible -@subtitle Documentation pour WeeChat v0.1.6-cvs - 2 octobre 2005 +@subtitle Documentation pour WeeChat v0.1.6-cvs - 17 octobre 2005 @author FlashCode <@email{flashcode@@flashtux.org, flashcode AT flashtux.org}> @@ -430,7 +430,7 @@ Couleur pour le texte saisi (pseudo)@* Type: couleur (couleur Curses ou Gtk), valeur par d@'efaut: 'lightcyan'@* @item col_input_delimiters Couleur pour le texte saisi (d@'elimiteurs)@* -Type: couleur (couleur Curses ou Gtk), valeur par d@'efaut: 'cyan'@* +Type: couleur (couleur Curses ou Gtk), valeur par d@'efaut: 'lightgreen'@* @item col_input_bg Couleur de fond pour la fen@^etre de saisie@* Type: couleur (couleur Curses ou Gtk), valeur par d@'efaut: 'default'@* @@ -629,6 +629,15 @@ Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: ''@* @item proxy_password Mot de passe pour le serveur proxy@* Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: ''@* +@item plugins_path +Chemin de recherche des extensions@* +Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: '~/.weechat/plugins'@* +@item plugins_autoload +Liste des extensions @`a charger automatiquement au d@'emarrage, "*" signifie toutes (s@'epar@'ees par des virgules, les noms peuvent @^etre partiels, par exemple "perl" est ok pour "libperl.so")@* +Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: '*'@* +@item plugins_extension +Extension standard des extensions dans le nom de fichier, pour le chargement automatique (si vide, alors tous les fichiers sont charg@'es si autoload vaut "*")@* +Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: '.so'@* @item server_name Nom associ@'e au serveur IRC (pour affichage seulement)@* Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: ''@* @@ -907,29 +916,13 @@ unbind: supprimer l'association @`a une touche (si "all", toutes les association functions: lister la liste des fonctions internes pour les associations de touches@* reset: restaur les touches aux valeurs par d@'efaut et supprime TOUTES les touches personnelles (utiliser avec pr@'ecaution !)@* @* -@item perl [load fichier] | [autoload] | [reload] | [unload] -@* -liste/charge/d@'echarge des scripts Perl@* -@* -fichier: script Perl (fichier) @`a charger@* -@* -Sans param@`etre, la commande /perl liste tous les scripts Perl charg@'es.@* -@* -@item python [load fichier] | [autoload] | [reload] | [unload] +@item plugin [load fichier] | [autoload] | [reload] | [unload] @* -liste/charge/d@'echarge des scripts Python@* +liste/charge/d@'echarge des extensions@* @* -fichier: script Python (fichier) @`a charger@* +fichier: extension WeeChat (fichier) @`a charger@* @* -Sans param@`etre, la commande /python liste tous les scripts Python charg@'es.@* -@* -@item ruby [load fichier] | [autoload] | [reload] | [unload] -@* -liste/charge/d@'echarge des scripts Ruby@* -@* -fichier: script Ruby (fichier) @`a charger@* -@* -Sans param@`etre, la commande /ruby liste tous les scripts Ruby charg@'es.@* +Sans param@`etre, la commande /plugin liste toutes les extensions charg@'ees.@* @* @item server [nom_serveur] | [nom_serveur nom/IP port [-auto | -noauto] [-ipv6] [-ssl] [-pwd mot_de_passe] [-nicks pseudo1 pseudo2 pseudo3] [-username nom_utilisateur] [-realname nom_r@'eel] [-command commande] [-autojoin canal[,canal]] ] | [del nom_serveur] @* @@ -1153,6 +1146,7 @@ modes de canaux :@* m: canal mod@'er@'e@* l: fixer la limite d'utilisateurs pour le canal@* b: param@'etrer un masque de banissement pour garder des utilisateurs dehors@* + e: param@'etrer un masque d'exception@* v: donner/reprendre la possibilit@'e de parler sur un canal mod@'er@'e@* k: d@'efinir une cl@'e (mot de passe) pour acc@'eder au canal@* modes utilisateur :@* @@ -1510,15 +1504,625 @@ Si le script s'appelle "auto_weechat_command", vous pouvez le lancer ainsi :@* @chapter Extensions @menu -* Scripts Perl:: -* Scripts Python:: -* Scripts Ruby:: +* Les extensions dans WeeChat:: +* Ecrire une extension:: +* Exemple d'extension:: +* Extensions pour scripts:: @end menu -@node Scripts Perl, Scripts Python, Extensions, Extensions -@section Scripts Perl +@node Les extensions dans WeeChat, Ecrire une extension, Extensions, Extensions +@section Les extensions dans WeeChat + +Une extension (``plugin'' en anglais) est un programme @'ecrit en C +qui peut appeler des fonctions de WeeChat d@'efinies dans une +interface.@* +Ce programme C n'a pas besoin des sources WeeChat pour @^etre +compil@'e et peut @^etre charg@'e/d@'echarg@'e dynamiquement dans +WeeChat via la commande @command{/plugin}.@* +@* +L'extension doit @^etre au format biblioth@`eque, chargeable +dynamiquement par le syst@^eme d'exploitation.@* +Sous GNU/Linux, il s'agit d'un fichier ayant pour extension ``.so''. + +@node Ecrire une extension, Exemple d'extension, Les extensions dans WeeChat, Extensions +@section Ecrire une extension + +@subsection R@`egles de base + +L'extension doit appeler le fichier ``weechat-plugin.h'' (disponible +dans les sources de WeeChat).@* +Ce fichier d@'efinit les structures et types dont l'extension aura +besoin pour communiquer avec WeeChat.@* +@* +L'extension doit comporter certaines variables et fonctions +obligatoires (sans quoi l'extension ne peut être chargée) :@* +@itemize @bullet +@item variables de description de l'extension : +@itemize @minus +@item plugin_name[]: le nom de l'extension +@item plugin_version[]: la version de l'extension +@item plugin_description[]: une courte description de l'extension +@end itemize +@item fonctions d'initialisation et fin de l'extension : +@itemize @minus +@item weechat_plugin_init: fonction appel@'e au chargement de l'extension +@item weechat_plugin_end: fonction appel@'e au d@'echargement de l'extension +@end itemize +@end itemize + +@subsection Fonctions de l'interface (API) + +L'extension peut appeler un certain nombre de fonctions d@'efinies +dans la structure t_weechat_plugin.@* +Ces fonctions sont d@'etaill@'ees ci-dessous : + +@itemize @bullet +@item +@command{int ascii_strcasecmp (t_weechat_plugin *plugin, +char *string1, char *string2)}@* +@* +Effectue une comparaison entre deux cha@^ines, sans tenir compte des +majuscules/minuscules ni de la locale.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{string1}: la premi@`ere cha@^ine @`a comparer +@item @option{string2}: la deuxi@`eme cha@^ine @`a comparer +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +La diff@'erence entre les deux cha@^ines: n@'egatif si chaine1 < +chaine2, nul si chaine1 == chaine 2, positif si chaine1 > chaine2@* +@* +@emph{Exemple :}@* +@* +@code{if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...}@* +@* + +@item +@command{char **explode_string (t_weechat_plugin *plugin, +char *string, char *separators, int num_items_max, int *num_items)}@* +@* +Explose une cha@^ine en plusieurs selon un/des d@'elimiteur(s).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{string}: la cha@^ine @`a exploser +@item @option{separators}: les d@'elimiteurs utilis@'s pour exploser +la cha@^ine +@item @option{num_items_max}: nombre maximum de sous-cha@^ines +cr@'é@'ees (si 0, alors le nombre est infini) +@item @option{num_items}: pointeur vers un entier qui contiendra le +nombre de sous-cha@^ines cr@'e@'ees en retour +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Un tableau de cha@^ines, ou NULL si un probl@^eme a @'et@'e rencontr@'e.@* +NB: le r@'esultat doit @^etre lib@'er@'e par un appel @`a la fonction +``free_exploded_string'' apr@`es utilisation.@* +@* +@emph{Exemple :}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{char **free_exploded_string (t_weechat_plugin *plugin, +char **string)}@* +@* +Lib@`ere la m@'emoire utilis@'ee pour une explosion de cha@^ine.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{string}: la cha@^ine explos@'ee par la fonction +``explode_string'' +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{void exec_on_files (t_weechat_plugin *plugin, char *directory, +int (*callback)(t_weechat_plugin *, char *))}@* +@* +Ex@'ecute une fonction sur tous les fichiers d'un r@'epertoire.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{directory}: le r@'epertoire o@`u les fichiers sont +recherch@'es +@item @option{callback}: une fonction appel@'ee pour chaque fichier trouv@'e +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{int callback (t_weechat_plugin *plugin, char *file)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "fichier: %s", file);}@* +@code{@ @ @ @ return 1;}@* +@code{@}}@* +@code{}@* +@code{...}@* +@code{plugin->exec_on_files (plugin, "/tmp", &callback);}@* +@* + +@item +@command{void printf (t_weechat_plugin *plugin, +char *server, char *channel, char *message, ...)}@* +@* +Affiche un message sur un tampon WeeChat, identifi@'e par le serveur et +le canal (tous deux pouvant @^etre NULL).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{server}: nom du serveur pour trouver le tampon dans +lequel afficher (peut @^etre NULL) +@item @option{channel}: nom du canal pour trouver le tampon dans +lequel afficher (peut @^etre NULL) +@item @option{message}: message @`a afficher +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemples :}@* +@* +@code{plugin->printf (NULL, NULL, "hello");}@* +@code{plugin->printf (NULL, "#weechat", "hello");}@* +@code{plugin->printf ("freenode", "#weechat", "hello");}@* +@* + +@item +@command{void printf_server (t_weechat_plugin *plugin, +char *message, ...)}@* +@* +Affiche un message sur la fen@^etre du serveur courant.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{message}: message @`a afficher +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->printf_server ("hello");}@* +@* + +@item +@command{void printf_infobar (t_weechat_plugin *plugin, +int time, char *message, ...)}@* +@* +Affiche un message sur la barre d'infos pour un temps d@'etermin@'e.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{time}: temps pendant lequel le message est affich@'e, en +secondes (0 = jamais effac@'e) +@item @option{message}: message @`a afficher +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->printf_infobar (5, "hello");}@* +@* + +@item +@command{t_plugin_msg_handler *msg_handler_add (t_weechat_plugin +*plugin, char *message, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Ajoute un gestionnaire de messages IRC, appel@'e d@`s qu'un message +IRC est re@,cu.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{message}: message IRC (par exemple ``PRIVMSG'') +@item @option{handler_func}: fonction appel@'ee lorsque le message est +re@,cu +@item @option{handler_args}: param@`etres pass@'es @`a la fonction +appel@'ee +@item @option{handler_pointer}: pointeur pass@'e @`a la fonction +appel@'ee +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Le pointeur vers le nouveau gestionnaire de messages.@* +@* +@emph{Exemple :}@* +@* +@code{int msg_kick (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "KICK re@,cu");}@* +@code{@}}@* +@code{...}@* +@code{plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);}@* +@* + +@item +@command{void msg_handler_remove (t_weechat_plugin *plugin, +t_plugin_msg_handler *msg_handler)}@* +@* +Supprime un gestionnaire de messages IRC.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{msg_handler}: le gestionnaire de messages @`a supprimer +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->msg_handler_remove (plugin, my_msg_handler);}@* +@* + +@item +@command{void msg_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Supprime tous les gestionnaires de messages IRC d'une extension.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->msg_handler_remove_all (plugin);}@* +@* + +@item +@command{t_plugin_cmd_handler *cmd_handler_add (t_weechat_plugin +*plugin, char *command, char *description, char *arguments, +char *arguments_description, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Ajoute un gestionnaire de commande WeeChat, appel@'e d@`s que +l'utilisateur utilise la commande (par exemple /commande).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{commande}: la nouvelle commande +@item @option{description}: description de la commande (affich@'ee par +/help commande) +@item @option{arguments}: br@`eve description des param@`etres de la +commande (affich@'ee par /help commande) +@item @option{arguments_description}: longue description des +param@`etres de la commande (affich@'ee par /help commande) +@item @option{handler_func}: fonction appel@'ee lorsque la commande est +ex@'ecut@'ee +@item @option{handler_args}: param@`etres pass@'es @`a la fonction +appel@'ee +@item @option{handler_pointer}: pointeur pass@'e @`a la fonction +appel@'ee +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Le pointeur vers le nouveau gestionnaire de commande.@* +@* +@emph{Exemple :}@* +@* +@code{int cmd_test (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "commande test, +fichier: %s", (arguments) ? arguments : "aucun");}@* +@code{@}}@* +@code{...}@* +@code{plugin->cmd_handler_add (plugin, "test", "Commande test", +"[fichier]", "fichier: un nom de fichier", &cmd_test, NULL, NULL);}@* +@* + +@item +@command{void cmd_handler_remove (t_weechat_plugin *plugin, +t_plugin_cmd_handler *cmd_handler)}@* +@* +Supprime un gestionnaire de commande.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{cmd_handler}: le gestionnaire de commande @`a supprimer +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->cmd_handler_remove (plugin, my_cmd_handler);}@* +@* + +@item +@command{void cmd_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Supprime tous les gestionnaires de commande d'une extension.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->cmd_handler_remove_all (plugin);}@* +@* + +@item +@command{void exec_command (t_weechat_plugin +*plugin, char *server, char *channel, char *command)}@* +@* +Execute une commande WeeChat (ou envoie un message @`a un canal).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{server}: nom du serveur o@`u ex@'ecuter la commande +(peut @^etre NULL) +@item @option{channel}: nom du canal o@`u ex@'ecuter la commande (peut +@^etre NULL) +@item @option{command}: la commande @`a ex@'ecuter +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemples :}@* +@* +@code{plugin->exec_command (plugin, NULL, NULL, "/help nick");}@* +@code{plugin->exec_command (plugin, "freenode", "#weechat", "hello");}@* +@* -@subsection Charger/d@'echarger des scripts Perl +@item +@command{char *get_info (t_weechat_plugin +*plugin, char *info, char *server, char *channel)}@* +@* +Renvoie une information sur WeeChat ou un canal.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{info}: nom de l'info @`a obtenir : +@itemize @minus +@item @option{version}: obtenir la version de WeeChat +@item @option{nick}: obtenir le pseudo +@item @option{channel}: obtenir le nom du canal +@item @option{server}: obtenir le nom du serveur +@item @option{away}: obtenir le drapeau ``away'' +@item @option{weechat_dir}: obtenir le r@'epertoire maison de WeeChat +@item @option{weechat_libdir}: obtenir le r@'epertoire ``lib'' +syst@`eme de WeeChat +@item @option{weechat_sharedir}: obtenir le r@'epertoire ``share'' +syst@`eme de partage WeeChat +@end itemize +@item @option{server}: nom du serveur o@`u r@'ecup@'erer l'information +(ni n@'ecessaire) +@item @option{channel}: nom du canal o@`u r@'ecup@'erer l'information +(si n@'ecessaire) +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +L'information recherch@'ee, NULL si non trouv@'ee.@* +NB: le r@'esultat doit @^etre lib@'er@'e par un appel @`a la fonction +``free'' apr@`es utilisation.@* +@* +@emph{Exemples :}@* +@* +@code{char *version = plugin->get_info (plugin, "version", NULL, NULL);}@* +@code{char *nick = plugin->get_info (plugin, "nick", "freenode", NULL);}@* +@* + +@item +@command{t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin)}@* +@* +Renvoie la liste des DCC en cours ou termin@'es.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +La liste cha@^in@'ee des DCC.@* +NB: le r@'esultat doit @^etre lib@'er@'e par un appel @`a la fonction +``free_dcc_info'' apr@`es utilisation.@* +@* +@emph{Exemple :}@* +@* +@code{t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin);}@* +@code{for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = +ptr_dcc->next_dcc)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "DCC type=%d, avec: %s", +ptr_dcc->type, ptr_dcc->nick);}@* +@code{@}}@* +@* + +@item +@command{void free_dcc_info (t_weechat_plugin *plugin, +t_plugin_dcc_info *dcc_info)}@* +@* +Lib@`ere la m@'emoire utilis@'ee par une liste de DCC.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{dcc_info}: pointeur vers une structure renvoy@'ee par la +fonction ``get_dcc_info'' +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{plugin->free_dcc_info (plugin, dcc_info);}@* +@* + +@item +@command{char *get_config (t_weechat_plugin +*plugin, char *option)}@* +@* +Renvoie la valeur d'une option de configuration WeeChat.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: un pointeur vers la structure de l'extension +@item @option{option}: nom de l'option @`a lire +@end itemize +@* +@emph{Valeur renvoy@'ee :}@* +@* +La valeur de l'option, NULL si non trouv@'ee.@* +NB: le r@'esultat doit @^etre lib@'er@'e par un appel @`a la fonction +``free'' apr@`es utilisation.@* +@* +@emph{Exemples :}@* +@* +@code{char *value1 = plugin->get_config (plugin, "look_set_title");}@* +@code{char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Compiler l'extension + +La compilation ne n@'ecessite pas les sources WeeChat, mais seulement +le fichier ``weechat-plugin.h''.@* + +Pour compiler une extension compos@'ee d'un fichier ``toto.c'' (sous +GNU/Linux) :@* +@* +gcc -fPIC -Wall -c toto.c@* +gcc -shared -fPIC -o libtoto.so toto.o + +@subsection Charger l'extension dans WeeChat + +Copier le fichier ``libtoto.so'' dans le r@'epertoire des extensions +g@'en@'eral (par exemple /usr/local/lib/weechat/plugins) ou bien dans +celui de l'utilisateur (par exemple /home/xxxxx/.weechat/plugins).@* +@* +Sous WeeChat :@* +@command{/plugin load toto} + +@node Exemple d'extension, Extensions pour scripts, Ecrire une extension, Extensions +@section Exemple d'extension + +Un exemple complet d'extension, qui ajoute une commande /double +affichant deux fois les param@`etres pass@'es sur le canal courant +(d'accord ce n'est pas tr@`es utile mais ceci est un exemple !) : + +@verbatim +#include <stdlib.h> + +#include "weechat-plugin.h" + +char plugin_name[] = "Toto"; +char plugin_version[] = "0.1"; +char plugin_description[] = "Plugin de test pour WeeChat"; + +/* gestionnaire de commande "/hello" */ + +int toto_cmd_double (t_weechat_plugin *plugin, char *server, + char *command, char *arguments, + char *handler_args, void *handler_pointer) +{ + if (arguments && arguments[0] && (arguments[0] != '/')) + { + plugin->exec_command (plugin, NULL, NULL, arguments); + plugin->exec_command (plugin, NULL, NULL, arguments); + } + return 1; +} + +int weechat_plugin_init (t_weechat_plugin *plugin) +{ + plugin->cmd_handler_add (plugin, "double", + "Affiche deux fois un message", + "msg", + "msg: message @`a afficher deux fois", + &toto_cmd_double, + NULL, NULL); + return 1; +} + +int weechat_plugin_end (t_weechat_plugin *plugin) +{ + /* on ne fait rien ici */ + return 1; +} +@end verbatim + +@node Extensions pour scripts, , Exemple d'extension, Extensions +@section Extensions pour scripts + +Trois extensions sont fournies en standard avec WeeChat pour utiliser +des langages de script: Perl, Python et Ruby. + +@subsection Scripts Perl + +@subsubsection Charger/d@'echarger des scripts Perl Les scripts Perl sont charg@'es et d@'echarg@'es avec la commande @command{/perl} (tapez @kbd{/help perl} dans WeeChat pour obtenir de l'aide sur la commande).@* @@ -1532,7 +2136,7 @@ Charger un script Perl : @kbd{/perl load /tmp/essai.pl}@* Lister les scripts Perl charg@'es : @kbd{/perl}@* @end itemize -@subsection Interface WeeChat / Perl +@subsubsection Interface WeeChat / Perl @itemize @bullet @item @@ -1553,6 +2157,7 @@ de fonction @`a appeler) @end itemize @* @emph{Exemple :}@* +@* @code{weechat::register ("essai", "1.0", "fin_essai", "Script d'essai !");}@* @* @@ -1568,7 +2173,8 @@ Affiche un message dans un canal.@* @item @option{serveur}: nom interne du serveur @end itemize @* -@emph{Exemple :}@* +@emph{Exemples :}@* +@* @code{weechat::print ("message");}@* @code{weechat::print ("message", "#weechat");}@* @code{weechat::print ("message", "#weechat", "freenode");}@* @@ -1587,6 +2193,7 @@ Affiche un message dans la barre d'infos.@* @end itemize @* @emph{Exemple :}@* +@* @code{weechat::print_infobar (5, "message");}@* @* @@ -1607,6 +2214,7 @@ RFC 2812 : @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Exemple :}@* +@* @code{weechat::add_message_handler ("privmsg", ma_fonction);}@* @code{sub ma_fonction}@* @code{@{ }@* @@ -1618,7 +2226,8 @@ RFC 2812 : @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @* @item -@command{weechat::add_command_handler ( nom, fonction );}@* +@command{weechat::add_command_handler ( nom, fonction, [description, +arguments, arguments_description] );}@* @* Cr@'e@'e une nouvelle commande WeeChat, associ@'ee @`a une fonction Perl.@* La fonction sera appel@'ee lorsque l'utilisateur lancera la commande par @kbd{/nom}.@* @@ -1630,9 +2239,16 @@ Il peut s'agir d'une commande existante, auquel cas celle-ci est @'ecras@'ee par la fonction Perl. Soyez prudent en @'ecrasant les commandes WeeChat, car elles ne seront plus accessibles tant que le script Perl sera charg@'e. @item @option{fonction}: fonction Perl associ@'ee @`a la commande +@item @option{description}: description de la commande (affich@'ee par +/help commande) +@item @option{arguments}: br@`eve description des param@`etres de la +commande (affich@'ee par /help commande) +@item @option{arguments_description}: longue description des +param@`etres de la commande (affich@'ee par /help commande) @end itemize @* @emph{Exemple :}@* +@* @code{weechat::add_command_handler ("commande", ma_commande);}@* @code{sub ma_commande}@* @code{@{ }@* @@ -1654,6 +2270,7 @@ Ex@'ecute une commande ou envoie un message @'a un canal.@* @end itemize @* @emph{Exemples :}@* +@* @code{weechat::command ("bonjour tout le monde !");}@* @code{weechat::command ("/kick toto merci de quitter ce canal", "#weechat");}@* @code{weechat::command ("/nick newnick", "", "freenode");}@* @@ -1667,28 +2284,87 @@ Obtenir des informations vari@'ees sur WeeChat, le serveur ou l'utilisateur.@* @emph{Param@`etres :} @itemize @minus @item @option{nom}: nom de l'info @`a obtenir : -@item @option{serveur}: nom interne du serveur @itemize @minus -@item @option{0 ou version}: obtenir la version de WeeChat -@item @option{1 ou nick}: obtenir le pseudo -@item @option{2 ou channel}: obtenir le nom du canal -@item @option{3 ou server}: obtenir le nom du serveur -@item @option{4 ou weechatdir}: obtenir le r@'epertoire maison de WeeChat -@item @option{5 ou away}: obtenir le drapeau "away" du serveur +@item @option{version}: obtenir la version de WeeChat +@item @option{nick}: obtenir le pseudo +@item @option{channel}: obtenir le nom du canal +@item @option{server}: obtenir le nom du serveur +@item @option{away}: obtenir le drapeau ``away'' +@item @option{weechat_dir}: obtenir le r@'epertoire maison de WeeChat +@item @option{weechat_libdir}: obtenir le r@'epertoire ``lib'' +syst@`eme de WeeChat +@item @option{weechat_sharedir}: obtenir le r@'epertoire ``share'' +syst@`eme de partage WeeChat @end itemize +@item @option{serveur}: nom interne du serveur @end itemize @* @emph{Exemples :}@* +@* @code{$version = get_info("version");}@* @code{$nick = get_info("nick", "freenode");}@* @* +@item +@command{weechat::get_dcc_info ( );}@* +@* +Obtenir la liste des DCC.@* + +Le tableau renvoy@'e contient les champs suivants : +@itemize @minus +@item server: le serveur IRC +@item channel: le canal IRC +@item type: le type de DCC : +@itemize @minus +@item 0: discussion (re@,cue) +@item 1: discussion (envoy@'ee) +@item 2: fichier en r@'eception +@item 3: fichier en @'emission +@end itemize +@item status: statut du DCC : +@itemize @minus +@item 0: en attente +@item 1: en cours de connexion +@item 2: actif +@item 3: termin@'e +@item 4: @'echou@'e +@item 5: interrompu par l'utilisateur +@end itemize +@item start_time: la date et heure de cr@'eation du DCC +@item start_transfer: la date et heure de d@'emarrage du transfert +@item addr: adresse de l'utilisateur distant +@item port: port utilis@'e pour le DCC +@item nick: pseudo de l'utilisateur distant +@item filename: nom de fichier +@item local_filename: nom de fichier local +@item size: taille du fichier +@item pos: position actuelle dans le fichier +@item start_resume: position de d@'emarrage apr@`es une interruption +@item bytes_per_sec: nombre d'octets transmis par seconde depuis le d@'ebut +@end itemize +@* + +@item +@command{weechat::get_config ( nom );}@* +@* +Obtenir la valeur d'une option de configuration WeeChat.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{nom}: nom de l'option +@end itemize +@* +@emph{Exemples :}@* +@* +@code{$value1 = weechat::get_config ("look_set_title");}@* +@code{$value2 = weechat::get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Scripts Python, Scripts Ruby, Scripts Perl, Extensions -@section Scripts Python +@subsection Scripts Python -@subsection Charger/d@'echarger des scripts Python +@subsubsection Charger/d@'echarger des scripts Python Les scripts Python sont charg@'es et d@'echarg@'es avec la commande @command{/python} (tapez @kbd{/help python} dans WeeChat pour obtenir de l'aide sur la commande).@* @@ -1702,7 +2378,7 @@ Charger un script Python : @kbd{/python load /tmp/essai.py}@* Lister les scripts Python charg@'es : @kbd{/python}@* @end itemize -@subsection Interface WeeChat / Python +@subsubsection Interface WeeChat / Python @itemize @bullet @item @@ -1723,6 +2399,7 @@ de fonction @`a appeler) @end itemize @* @emph{Exemple :}@* +@* @code{weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !")}@* @* @@ -1738,7 +2415,8 @@ Affiche un message dans un canal.@* @item @option{serveur}: nom interne du serveur @end itemize @* -@emph{Exemple :}@* +@emph{Exemples :}@* +@* @code{weechat.prnt ("message")}@* @code{weechat.prnt ("message", "#weechat")}@* @code{weechat.prnt ("message", "#weechat", "freenode")}@* @@ -1757,6 +2435,7 @@ Affiche un message dans la barre d'infos.@* @end itemize @* @emph{Exemple :}@* +@* @code{weechat.print_infobar (5, "message")}@* @* @@ -1777,6 +2456,7 @@ RFC 2812 : @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Exemple :}@* +@* @code{weechat.add_message_handler ("privmsg", ma_fonction)}@* @code{def ma_fonction(serveur, args):}@* @code{@ @ @ @ weechat.prnt("serveur="+serveur)}@* @@ -1798,9 +2478,16 @@ Il peut s'agir d'une commande existante, auquel cas celle-ci est @'ecras@'ee par la fonction Python. Soyez prudent en @'ecrasant les commandes WeeChat, car elles ne seront plus accessibles tant que le script Python sera charg@'e. @item @option{fonction}: fonction Python associ@'ee @`a la commande +@item @option{description}: description de la commande (affich@'ee par +/help commande) +@item @option{arguments}: br@`eve description des param@`etres de la +commande (affich@'ee par /help commande) +@item @option{arguments_description}: longue description des +param@`etres de la commande (affich@'ee par /help commande) @end itemize @* @emph{Exemple :}@* +@* @code{weechat.add_command_handler ("commande", ma_commande)}@* @code{def ma_commande(serveur, args):}@* @code{@ @ @ @ weechat.prnt("serveur:"+serveur+" param@`etres:"+args)}@* @@ -1819,6 +2506,7 @@ Ex@'ecute une commande ou envoie un message @'a un canal.@* @end itemize @* @emph{Exemples :}@* +@* @code{weechat.command ("bonjour tout le monde !")}@* @code{weechat.command ("/kick toto merci de quitter ce canal", "#weechat")}@* @code{weechat.command ("/nick newnick", "", "freenode")}@* @@ -1832,29 +2520,89 @@ Obtenir des informations vari@'ees sur WeeChat, le serveur ou l'utilisateur.@* @emph{Param@`etres :} @itemize @minus @item @option{nom}: nom de l'info @`a obtenir : +@itemize @minus +@item @option{version}: obtenir la version de WeeChat +@item @option{nick}: obtenir le pseudo +@item @option{channel}: obtenir le nom du canal +@item @option{server}: obtenir le nom du serveur +@item @option{away}: obtenir le drapeau ``away'' +@item @option{weechat_dir}: obtenir le r@'epertoire maison de WeeChat +@item @option{weechat_libdir}: obtenir le r@'epertoire ``lib'' +syst@`eme de WeeChat +@item @option{weechat_sharedir}: obtenir le r@'epertoire ``share'' +syst@`eme de partage WeeChat +@end itemize @item @option{serveur}: nom interne du serveur +@end itemize +@* +@emph{Exemples :}@* +@* +@code{$version = weechat.get_info ("version")}@* +@code{$nick = weechat.get_info ("nick", "freenode")}@* +@* + +@item +@command{weechat.get_dcc_info ( );}@* +@* +Obtenir la liste des DCC.@* + +Le tableau renvoy@'e contient les champs suivants : +@itemize @minus +@item server: le serveur IRC +@item channel: le canal IRC +@item type: le type de DCC : +@itemize @minus +@item 0: discussion (re@,cue) +@item 1: discussion (envoy@'ee) +@item 2: fichier en r@'eception +@item 3: fichier en @'emission +@end itemize +@item status: statut du DCC : @itemize @minus -@item @option{0 ou version}: obtenir la version de WeeChat -@item @option{1 ou nick}: obtenir le pseudo -@item @option{2 ou channel}: obtenir le nom du canal -@item @option{3 ou server}: obtenir le nom du serveur -@item @option{4 ou weechatdir}: obtenir le r@'epertoire maison de WeeChat -@item @option{5 ou away}: obtenir le drapeau "away" du serveur +@item 0: en attente +@item 1: en cours de connexion +@item 2: actif +@item 3: termin@'e +@item 4: @'echou@'e +@item 5: interrompu par l'utilisateur @end itemize +@item start_time: la date et heure de cr@'eation du DCC +@item start_transfer: la date et heure de d@'emarrage du transfert +@item addr: adresse de l'utilisateur distant +@item port: port utilis@'e pour le DCC +@item nick: pseudo de l'utilisateur distant +@item filename: nom de fichier +@item local_filename: nom de fichier local +@item size: taille du fichier +@item pos: position actuelle dans le fichier +@item start_resume: position de d@'emarrage apr@`es une interruption +@item bytes_per_sec: nombre d'octets transmis par seconde depuis le d@'ebut +@end itemize +@* + +@item +@command{weechat.get_config ( nom );}@* +@* +Obtenir la valeur d'une option de configuration WeeChat.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{nom}: nom de l'option @end itemize @* @emph{Exemples :}@* -@code{$version = weechat.get_info("version")}@* -@code{$nick = weechat.get_info("nick", "freenode")}@* +@* +@code{$value1 = weechat.get_config ("look_set_title");}@* +@code{$value2 = weechat.get_config ("freenode.server_autojoin");}@* @* @end itemize -@node Scripts Ruby, , Scripts Python, Extensions -@section Scripts Ruby +@subsection Scripts Ruby Non d@'evelopp@'e ! + @c **************************** Auteurs / Support ***************************** @node Auteurs / Support, , Extensions, Top diff --git a/weechat/doc/weechat_doc_pt.texi b/weechat/doc/weechat_doc_pt.texi index 5cb6a17c7..816d7e8c4 100644 --- a/weechat/doc/weechat_doc_pt.texi +++ b/weechat/doc/weechat_doc_pt.texi @@ -36,7 +36,7 @@ @title WeeChat - Guia do Utilizador @subtitle Cliente de IRC rapido, leve e extencivel -@subtitle Documenta@,{c}@~ao do WeeChat v0.1.6-cvs - 2 de outubro de 2005 +@subtitle Documenta@,{c}@~ao do WeeChat v0.1.6-cvs - 17 de outubro de 2005 @author FlashCode <@email{flashcode@@flashtux.org, flashcode AT flashtux.org}> @@ -65,7 +65,7 @@ License) vers@~ao 2 ou superior. * Introducao:: Descri@,{c}@~ao do WeeChat * Instalacao:: Instala@,{c}@~ao do WeeChat * Utilizacao:: Utiliza@,{c}@~ao do WeeChat -* Extencoes:: Exten@,{c}@~oes do Weechat +* Plugins:: WeeChat plugins * Autores/Suporte:: Contactar os autores e obter suporte @end menu @@ -198,7 +198,7 @@ Segue agora as instru@,{c}@~oes para compilar o c@'odigo fonte - @xref{Codigo Fo @c ******************************* Utilizacao ******************************** -@node Utilizacao, Extencoes, Instalacao, Top +@node Utilizacao, Plugins, Instalacao, Top @chapter Utiliza@,{c}@~ao @menu @@ -427,7 +427,7 @@ Color for input text (nick name)@* Type: color (Curses or Gtk color), default value: 'lightcyan'@* @item col_input_delimiters Color for input text (delimiters)@* -Type: color (Curses or Gtk color), default value: 'cyan'@* +Type: color (Curses or Gtk color), default value: 'lightgreen'@* @item col_input_bg Background for input window@* Type: color (Curses or Gtk color), default value: 'default'@* @@ -626,6 +626,15 @@ Type: string (any string), default value: ''@* @item proxy_password Password for proxy server@* Type: string (any string), default value: ''@* +@item plugins_path +Path for searching plugins@* +Type: string (any string), default value: '~/.weechat/plugins'@* +@item plugins_autoload +Comma separated list of plugins to load automatically at startup, "*" means all plugins found (names may be partial, for example "perl" is ok for "libperl.so")@* +Type: string (any string), default value: '*'@* +@item plugins_extension +Standard plugins extension in filename, used for autoload (if empty, then all files are loaded when autoload is "*")@* +Type: string (any string), default value: '.so'@* @item server_name Name associated to IRC server (for display only)@* Type: string (any string), default value: ''@* @@ -904,29 +913,13 @@ unbind: unbind a key (if "all", default bindings are restored)@* functions: list internal functions for key bindings@* reset: restore bindings to the default values and delete ALL personal binding (use carefully!)@* @* -@item perl [load filename] | [autoload] | [reload] | [unload] -@* -list/load/unload Perl scripts@* -@* -filename: Perl script (file) to load@* -@* -Without argument, /perl command lists all loaded Perl scripts.@* -@* -@item python [load filename] | [autoload] | [reload] | [unload] +@item plugin [load filename] | [autoload] | [reload] | [unload] @* -list/load/unload Python scripts@* +list/load/unload plugins@* @* -filename: Python script (file) to load@* +filename: WeeChat plugin (file) to load@* @* -Without argument, /python command lists all loaded Python scripts.@* -@* -@item ruby [load filename] | [autoload] | [reload] | [unload] -@* -list/load/unload Ruby scripts@* -@* -filename: Ruby script (file) to load@* -@* -Without argument, /ruby command lists all loaded Ruby scripts.@* +Without argument, /plugin command lists all loaded plugins.@* @* @item server [servername] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [del servername] @* @@ -1150,6 +1143,7 @@ channel modes:@* m: moderated channel@* l: set the user limit to channel@* b: set a ban mask to keep users out@* + e: set exception mask@* v: give/take the ability to speak on a moderated channel@* k: set a channel key (password)@* user modes:@* @@ -1497,21 +1491,613 @@ If the script is called "auto_weechat_command", you can run it with:@* @command{./auto_weechat_command "freenode,#weechat *hello"} -@c ******************************* Extencoes ********************************* +@c ********************************* Plugins ********************************** -@node Extencoes, Autores/Suporte, Utilizacao, Top -@chapter Exten@,{c}@~oes +@node Plugins, Autores/Suporte, Utilizacao, Top +@chapter Plugins @menu -* Scripts Perl:: -* Scripts Python:: -* Scripts Ruby:: +* Plugins in WeeChat:: +* Write a plugin:: +* Plugin example:: +* Scripts plugins:: @end menu -@node Scripts Perl, Scripts Python, Extencoes, Extencoes -@section Scripts Perl +@node Plugins in WeeChat, Write a plugin, Plugins, Plugins +@section Plugins in WeeChat + +A plugin is a C program which can call WeeChat functions defined in an +interface.@* +@* +This C program does not need WeeChat sources to compile and can be +dynamically loaded into WeeChat with command @command{/plugin}.@* +@* +The plugin has to be a dynamic library, for dynamic loading by +operating system. +Under GNU/Linux, the file has ``.so'' extension. + +@node Write a plugin, Plugin example, Plugins in WeeChat, Plugins +@section Write a plugin + +@subsection Base rules + +The plugin should include ``weechat-plugin.h'' file (available in +WeeChat source code).@* +This file defines structures and types used to communicate with WeeChat.@* +@* +The plugin must have some variables and functions (mandatory, without +them the plugin can't load):@* +@itemize @bullet +@item variables for plugin description: +@itemize @minus +@item plugin_name[]: plugin name +@item plugin_version[]: plugin version +@item plugin_description[]: short description of plugin +@end itemize +@item functions for init and end of plugin: +@itemize @minus +@item weechat_plugin_init: function called when plugin is loaded +@item weechat_plugin_end: function called when plugin is unloaded +@end itemize +@end itemize + +@subsection API functions + +The plugin can call some functions defined in t_weechat_plugin structure.@* +These functions are detailed below: + +@itemize @bullet +@item +@command{int ascii_strcasecmp (t_weechat_plugin *plugin, +char *string1, char *string2)}@* +@* +locale and case independent string comparison.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string1}: first string for comparison +@item @option{string2}: second string for comparison +@end itemize +@* +@emph{Return value:}@* +@* +Difference between two strings: negative if chaine1 < chaine2, +nul if chaine1 == chaine 2, positive if chaine1 > chaine2@* +@* +@emph{Example:}@* +@* +@code{if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...}@* + +@* + +@item +@command{char **explode_string (t_weechat_plugin *plugin, +char *string, char *separators, int num_items_max, int *num_items)}@* +@* +Explode a string according to one or more delimiter(s).@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string to explode +@item @option{separators}: delimiters used for explosion +@item @option{num_items_max}: maximum number of items created (0 means +no limit) +@item @option{num_items}: pointer to int which will contain number of +items created +@end itemize +@* +@emph{Return value:}@* +@* +Array of strings, NULL if problem.@* +Note: the result has to be free by a call to ``free_exploded_string'' +function after use.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{char **free_exploded_string (t_weechat_plugin *plugin, +char **string)}@* +@* +Free memory used by a string explosion.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{string}: string exploded by ``explode_string'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{char *argv;}@* +@code{int argc;}@* +@code{argv = plugin->explode_string (plugin, string, " ", 0, &argc);}@* +@code{...}@* +@code{if (argv != NULL)}@* +@code{plugin->free_exploded_string (plugin, argv);}@* +@* + +@item +@command{void exec_on_files (t_weechat_plugin *plugin, char *directory, +int (*callback)(t_weechat_plugin *, char *))}@* +@* +Execute a function on all files of a directory.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{directory}: directory for searching files +@item @option{callback}: function called for each file found +@end itemize +@* +@emph{Return value:}@* +@* +Aucune.@* +@* +@emph{Exemple :}@* +@* +@code{int callback (t_weechat_plugin *plugin, char *file)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "file: %s", file);}@* +@code{@ @ @ @ return 1;}@* +@code{@}}@* +@code{}@* +@code{...}@* +@code{plugin->exec_on_files (plugin, "/tmp", &callback);}@* +@* + +@item +@command{void printf (t_weechat_plugin *plugin, +char *server, char *channel, char *message, ...)}@* +@* +Display a message on a WeeChat buffer, identified by server and +channel (both may be NULL).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server to find buffer for message +display (may be NULL) +@item @option{channel}: name of channel to find buffer for message +display (may be NULL) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->printf (NULL, NULL, "hello");}@* +@code{plugin->printf (NULL, "#weechat", "hello");}@* +@code{plugin->printf ("freenode", "#weechat", "hello");}@* +@* + +@item +@command{void printf_server (t_weechat_plugin *plugin, +char *message, ...)}@* +@* +Display a message on server buffer.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_server ("hello");}@* +@* + +@item +@command{void printf_infobar (t_weechat_plugin *plugin, +int time, char *message, ...)}@* +@* +Display a message in infobar for a specified time.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{time}: time in seconds for displaying message (0 means +never erased) +@item @option{message}: message +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->printf_infobar (5, "hello");}@* +@* + +@item +@command{t_plugin_msg_handler *msg_handler_add (t_weechat_plugin +*plugin, char *message, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add an IRC message handler, called when an IRC message is received.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{message}: IRC message (for example: ``PRIVMSG'') +@item @option{handler_func}: function called when message is received +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new message handler.@* +@* +@emph{Example:}@* +@* +@code{int msg_kick (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "KICK received");}@* +@code{@}}@* +@code{...}@* +@code{plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);}@* +@* + +@item +@command{void msg_handler_remove (t_weechat_plugin *plugin, +t_plugin_msg_handler *msg_handler)}@* +@* +Remove an IRC message handler.@* -@subsection Carregar/Descarregar Scripts Perl +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{msg_handler}: handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove (plugin, my_msg_handler);}@* +@* + +@item +@command{void msg_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all IRC message handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->msg_handler_remove_all (plugin);}@* +@* + +@item +@command{t_plugin_cmd_handler *cmd_handler_add (t_weechat_plugin +*plugin, char *command, char *description, char *arguments, +char *arguments_description, t_plugin_handler_func *handler_func, +char *handler_args, void *handler_pointer)}@* +@* +Add a WeeChat command handler, called when user uses command +(for example /command).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{commande}: the new command +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) +@item @option{handler_func}: function called when comand is executed +@item @option{handler_args}: arguments given to function when called +@item @option{handler_pointer}: pointer given to function when called +@end itemize +@* +@emph{Return value:}@* +@* +Pointer to new command handler.@* +@* +@emph{Example:}@* +@* +@code{int cmd_test (t_weechat_plugin *plugin, char *server, +char *command, char *arguments, char *handler_args, +void *handler_pointer)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf (plugin, server, NULL, "test command, +file: %s", (arguments) ? arguments : "none");}@* +@code{@}}@* +@code{...}@* +@code{plugin->cmd_handler_add (plugin, "test", "Test command", +"[file]", "file: a file name", &cmd_test, NULL, NULL);}@* +@* + +@item +@command{void cmd_handler_remove (t_weechat_plugin *plugin, +t_plugin_cmd_handler *cmd_handler)}@* +@* +Remove a command handler.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{cmd_handler}: command handler to remove +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->cmd_handler_remove (plugin, my_cmd_handler);}@* +@* + +@item +@command{void cmd_handler_remove_all (t_weechat_plugin *plugin)}@* +@* +Remove all command handlers for a plugin.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example :}@* +@* +@code{plugin->cmd_handler_remove_all (plugin);}@* +@* + +@item +@command{void exec_command (t_weechat_plugin +*plugin, char *server, char *channel, char *command)}@* +@* +Execute a WeeChat command (or send a message to a channel).@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{server}: name of server for executing command (may be +NULL) +@item @option{channel}: name of channel for executing command (may be +NULL) +@item @option{command}: command +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Examples:}@* +@* +@code{plugin->exec_command (plugin, NULL, NULL, "/help nick");}@* +@code{plugin->exec_command (plugin, "freenode", "#weechat", "hello");}@* +@* + +@item +@command{char *get_info (t_weechat_plugin +*plugin, char *info, char *server, char *channel)}@* +@* +Return an info about WeeChat or a channel.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{info}: name of info to read: +@itemize @minus +@item @option{version}: get WeeChat's version +@item @option{nick}: get nick +@item @option{channel}: get channel name +@item @option{server}: get server name +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir +@end itemize +@item @option{server}: name of server for reading info (if needed) +@item @option{channel}: name of channel for reading info (if needed) +@end itemize +@* +@emph{Return value:}@* +@* +Information asked, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *version = plugin->get_info (plugin, "version", NULL, NULL);}@* +@code{char *nick = plugin->get_info (plugin, "nick", "freenode", NULL);}@* +@* + +@item +@command{t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin)}@* +@* +Returns list of DCC currently active or finished.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@end itemize +@* +@emph{Return value:}@* +@* +Chained list of DCC.@* +Note: result has to be free by a call to ``free_dcc_info'' function +after use.@* +@* +@emph{Example:}@* +@* +@code{t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin);}@* +@code{for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = +ptr_dcc->next_dcc)}@* +@code{@{}@* +@code{@ @ @ @ plugin->printf_server (plugin, "DCC type=%d, with: %s", +ptr_dcc->type, ptr_dcc->nick);}@* +@code{@}}@* +@* + +@item +@command{void free_dcc_info (t_weechat_plugin *plugin, +t_plugin_dcc_info *dcc_info)}@* +@* +Free memory used by a DCC list.@* + +@emph{Param@`etres :} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{dcc_info}: pointer to DCC list returned by +``get_dcc_info'' function +@end itemize +@* +@emph{Return value:}@* +@* +None.@* +@* +@emph{Example:}@* +@* +@code{plugin->free_dcc_info (plugin, dcc_info);}@* +@* + +@item +@command{char *get_config (t_weechat_plugin +*plugin, char *option)}@* +@* +Return value of a WeeChat config option.@* + +@emph{Arguments:} +@itemize @minus +@item @option{plugin}: pointer to plugin structure +@item @option{option}: name of option to read +@end itemize +@* +@emph{Return value:}@* +@* +Value of option, NULL if not found.@* +Note: result has to be free by a call to ``free'' function after +use.@* +@* +@emph{Examples:}@* +@* +@code{char *value1 = plugin->get_config (plugin, "look_set_title");}@* +@code{char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Compile plugin + +Compile does not need WeeChat sources, only file +``weechat-plugin.h''.@* + +To compile a plugin which has one file ``toto.c'' (sous GNU/Linux):@* +@* +gcc -fPIC -Wall -c toto.c@* +gcc -shared -fPIC -o libtoto.so toto.o + +@subsection Load plugin under WeeChat + +Copy ``libtoto.so'' file into general plugins dir (for example +/usr/local/lib/weechat/plugins) or into user's plugins dir (for +example /home/xxxxx/.weechat/plugins).@* +@* +Under WeeChat:@* +@command{/plugin load toto} + +@node Plugin example, Scripts plugins, Write a plugin, Plugins +@section Plugin example + +Full example of plugin, which adds a /double command, which displays +two times arguments on current channel (ok that's not very useful, but +that's just an example!): + +@verbatim +#include <stdlib.h> + +#include "weechat-plugin.h" + +char plugin_name[] = "Toto"; +char plugin_version[] = "0.1"; +char plugin_description[] = "Test plugin for WeeChat"; + +/* gestionnaire de commande "/hello" */ + +int toto_cmd_double (t_weechat_plugin *plugin, char *server, + char *command, char *arguments, + char *handler_args, void *handler_pointer) +{ + if (arguments && arguments[0] && (arguments[0] != '/')) + { + plugin->exec_command (plugin, NULL, NULL, arguments); + plugin->exec_command (plugin, NULL, NULL, arguments); + } + return 1; +} + +int weechat_plugin_init (t_weechat_plugin *plugin) +{ + plugin->cmd_handler_add (plugin, "double", + "Display two times a message", + "msg", + "msg: message", + &toto_cmd_double, + NULL, NULL); + return 1; +} + +int weechat_plugin_end (t_weechat_plugin *plugin) +{ + /* on ne fait rien ici */ + return 1; +} +@end verbatim + +@node Scripts plugins, , Plugin example, Plugins +@section Scripts plugins + +Three plugins are provided with WeeChat to load scripts: Perl, +Python and Ruby. + +@subsection Perl scripts + +@subsubsection Carregar/Descarregar Scripts Perl Os Scripts Perl s@~ao carregados e descarregados com o comando @command{/perl}. (escreve @kbd{/help perl} dentro do WeeChat para obteres ajuda acerca do comando).@* @@ -1526,7 +2112,7 @@ Descarregar todos os Scripts Perl: @kbd{/perl unload}@* Listar todos os Scripts Perl: @kbd{/perl}@* @end itemize -@subsection Interface WeeChat / Perl +@subsubsection Interface WeeChat / Perl @itemize @bullet @item @@ -1544,6 +2130,7 @@ Todos os Scripts Perl para o Weechat devem invocar esta fun@,{c}@~ao.@* @end itemize @* @emph{Exemplo:}@* +@* @code{weechat::register ("sample", "1.0", "sample_end", "Sample script!");}@* @* @@ -1559,7 +2146,8 @@ Imprimne uma mensagem na canal.@* @item @option{servidor}: nome interno da servidor @end itemize @* -@emph{Exemplo:}@* +@emph{Exemplos:}@* +@* @code{weechat::print ("mensagem");}@* @code{weechat::print ("mensagem", "#weechat");}@* @code{weechat::print ("mensagem", "#weechat", "freenode");}@* @@ -1578,6 +2166,7 @@ Imprimne uma mensagem na barra do info.@* @end itemize @* @emph{Exemplo:}@* +@* @code{weechat::print_infobar (5, "mensagem");}@* @* @@ -1597,6 +2186,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Exemplo:}@* +@* @code{weechat::add_message_handler ("privmsg", my_function);}@* @code{sub my_function}@* @code{@{ }@* @@ -1617,9 +2207,16 @@ A fun@,{c}@~ao ser@'a chamada quando o utilizador a invocar utilizando @command{ @item @option{nome}: nome do novo comando@* Este nome pode pertencer a um comando já existente, o qual ser@'a sobreposto pela fun@,{c}@~ao Perl. Tem cuidado quando fizeres isto: os comandos originais não estar@~ao acessiveis antes de teres descarregado o Script Perl. @item @option{fun@,{c}@~ao}: fun@,{c}@~ao Perl ligada ao comando +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Exemplo:}@* +@* @code{weechat::add_command_handler ("command", my_command);}@* @code{sub my_command}@* @code{@{ }@* @@ -1641,6 +2238,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat::command ("hello world!");}@* @code{weechat::command ("/kick toto please leave this chan", "#weechat");}@* @code{weechat::command ("/nick newnick", "", "freenode");}@* @@ -1654,28 +2252,85 @@ Comece o v@'ario info sobre WeeChat, servidor ou usu@'ario.@* @emph{Argumentos:} @itemize @minus @item @option{nome}: nome do info a recuperar: -@item @option{servidor}: nome interno da servidor @itemize @minus -@item @option{0 ou version}: comece a vers@~ao de WeeChat -@item @option{1 ou nick}: comece o nickname -@item @option{2 ou channel}: comece o nome da canal -@item @option{3 ou server}: comece o nome do servidor -@item @option{4 ou weechatdir}: comece a WeeChat o diret@'orio home -@item @option{5 ou away}: comece a bandeira ausente para o servidor +@item @option{version}: comece a vers@~ao de WeeChat +@item @option{nick}: comece o nickname +@item @option{channel}: comece o nome da canal +@item @option{server}: comece o nome do servidor +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{servidor}: nome interno da servidor @end itemize @* @emph{Exemplos:}@* +@* @code{$version = get_info("version");}@* @code{$nick = get_info("nick", "freenode");}@* @* +@item +@command{weechat::get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) @end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* -@node Scripts Python, Scripts Ruby, Scripts Perl, Extencoes -@section Scripts Python +@item +@command{weechat::get_config ( name );}@* +@* +Get WeeChat config option value.@* -@subsection Carregar/Descarregar Scripts Python +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat::get_config ("look_set_title");}@* +@code{$value2 = weechat::get_config ("freenode.server_autojoin");}@* +@* + +@end itemize + +@subsection Python scripts + +@subsubsection Carregar/Descarregar Scripts Python Os Scripts Python s@~ao carregados e descarregados com o comando @command{/python}. (escreve @kbd{/help python} dentro do WeeChat para obteres ajuda acerca do comando).@* @@ -1690,7 +2345,7 @@ Descarregar todos os Scripts Python: @kbd{/python unload}@* Listar todos os Scripts Python: @kbd{/python}@* @end itemize -@subsection Interface WeeChat / Python +@subsubsection Interface WeeChat / Python @itemize @bullet @item @@ -1708,6 +2363,7 @@ Todos os Scripts Python para o Weechat devem invocar esta fun@,{c}@~ao.@* @end itemize @* @emph{Exemplo:}@* +@* @code{weechat.register ("sample", "1.0", "sample_end", "Sample script!")}@* @* @@ -1723,7 +2379,8 @@ Imprimne uma mensagem na canal.@* @item @option{servidor}: nome interno da servidor @end itemize @* -@emph{Exemplo:}@* +@emph{Exemplos:}@* +@* @code{weechat.prnt ("mensagem")}@* @code{weechat.prnt ("mensagem", "#weechat")}@* @code{weechat.prnt ("mensagem", "#weechat", "freenode")}@* @@ -1742,6 +2399,7 @@ Imprimne uma mensagem na barra do info.@* @end itemize @* @emph{Exemplo:}@* +@* @code{weechat.print_infobar (5, "mensagem")}@* @* @@ -1761,6 +2419,7 @@ RFC 2812: @uref{ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt} @end itemize @* @emph{Exemplo:}@* +@* @code{weechat.add_message_handler ("privmsg", my_function)}@* @code{def my_function(server, args):}@* @code{@ @ @ @ weechat.prnt("server="+server)}@* @@ -1780,9 +2439,16 @@ A fun@,{c}@~ao ser@'a chamada quando o utilizador a invocar utilizando @command{ @item @option{nome}: nome do novo comando@* Este nome pode pertencer a um comando já existente, o qual ser@'a sobreposto pela fun@,{c}@~ao Python. Tem cuidado quando fizeres isto: os comandos originais não estar@~ao acessiveis antes de teres descarregado o Script Python. @item @option{fun@,{c}@~ao}: fun@,{c}@~ao Python ligada ao comando +@item @option{description}: command description (displayed by /help +command) +@item @option{arguments}: short description of command arguments +(displayed by /help command) +@item @option{arguments_description}: long description of command +arguments (displayed by /help command) @end itemize @* @emph{Exemplo:}@* +@* @code{weechat.add_command_handler ("command", my_command)}@* @code{def my_command(server, args):}@* @code{@ @ @ @ weechat.prnt("Servidor:"+server+" Argumentos:"+args)}@* @@ -1801,6 +2467,7 @@ Execute a command or send a message to a channel.@* @end itemize @* @emph{Examples:}@* +@* @code{weechat.command ("hello world!")}@* @code{weechat.command ("/kick toto please leave this chan", "#weechat")}@* @code{weechat.command ("/nick newnick", "", "freenode")}@* @@ -1814,33 +2481,90 @@ Comece o v@'ario info sobre WeeChat, servidor ou usu@'ario.@* @emph{Argumentos:} @itemize @minus @item @option{nome}: nome do info a recuperar: -@item @option{servidor}: nome interno da servidor @itemize @minus -@item @option{0 ou version}: comece a vers@~ao de WeeChat -@item @option{1 ou nick}: comece o nickname -@item @option{2 ou channel}: comece o nome da canal -@item @option{3 ou server}: comece o nome do servidor -@item @option{4 ou weechatdir}: comece a WeeChat o diret@'orio home -@item @option{5 ou away}: comece a bandeira ausente para o servidor +@item @option{version}: comece a vers@~ao de WeeChat +@item @option{nick}: comece o nickname +@item @option{channel}: comece o nome da canal +@item @option{server}: comece o nome do servidor +@item @option{away}: get ``away'' flag +@item @option{weechat_dir}: get WeeChat home dir +@item @option{weechat_libdir}: get WeeChat system lib dir +@item @option{weechat_sharedir}: get WeeChat system share dir @end itemize +@item @option{servidor}: nome interno da servidor @end itemize @* @emph{Exemplos:}@* +@* @code{$version = weechat.get_info("version")}@* @code{$nick = weechat.get_info("nick", "freenode")}@* @* +@item +@command{weechat::get_dcc_info ( );}@* +@* +Get DCC list.@* + +Returned array has following fields: +@itemize @minus +@item server: IRC server +@item channel: IRC channel +@item type: DCC type: +@itemize @minus +@item 0: chat (received) +@item 1: chat (sent) +@item 2: file (receiving) +@item 3: file (sending) +@end itemize +@item status: DCC status: +@itemize @minus +@item 0: waiting +@item 1: connecting +@item 2: active +@item 3: done +@item 4: failed +@item 5: aborted +@end itemize +@item start_time: date/time of DCC creation +@item start_transfer: date/time of transfer start +@item addr: remote address +@item port: port used for DCC +@item nick: remote nick +@item filename: filename +@item local_filename: local filename +@item size: file size +@item pos: current position in file +@item start_resume: restart position after interruption +@item bytes_per_sec: bytes sent/received per second +@end itemize +@* + +@item +@command{weechat.get_config ( name );}@* +@* +Get WeeChat config option value.@* + +@emph{Arguments:} +@itemize @minus +@item @option{name}: name of option +@end itemize +@* +@emph{Examples:}@* +@* +@code{$value1 = weechat.get_config ("look_set_title");}@* +@code{$value2 = weechat.get_config ("freenode.server_autojoin");}@* +@* + @end itemize -@node Scripts Ruby, , Scripts Python, Extencoes -@section Scripts Ruby +@subsection Ruby scripts N@~AO DESENVOLVIDO! @c **************************** Autores/Suporte ***************************** -@node Autores/Suporte, , Extencoes, Top +@node Autores/Suporte, , Plugins, Top @chapter Autores / Suporte @ifhtml |