]> WeeChat 0.2.5-cvs - User guide Fast, light and extensible IRC client Sébastien Helleu flashcode AT flashtux.org &date.xml; 2007 Sébastien Helleu This manual is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA This manual documents WeeChat IRC client, it is part of WeeChat. Latest version of this document can be found on this page: http://weechat.flashtux.org/doc.php Introduction This chapter describes WeeChat and pre-requisites for its installation.
Description WeeChat (Wee Enhanced Environment for Chat) is a free IRC client, fast and light, designed for many operating systems. Main features are: multi-servers connection (with SSL, IPv6, proxy) many GUI: Curses, wxWidgets, Gtk and Qt small, fast and light customizable and extensible with plugins and scripts compliant with RFCs 1459, 2810, 2811, 2812 and 2813 multi-platform (GNU/Linux, *BSD, MacOS X, Windows and other) 100% GPL, free software WeeChat homepage is here: http://weechat.flashtux.org
Pre-requisites In order to install WeeChat, you need: a running GNU/Linux system (with compiler tools for source package) "root" privileges (to install WeeChat) according to GUI, one of the following libraries: Curses: ncurses library Gtk: *** GUI not developed *** WxWidgets: *** GUI not developed *** Qt: *** GUI not developed ***
Installation This chapter explains how to install WeeChat.
Binary packages Binary packages are available for these distributions: Debian (or any Debian compatible distribution): apt-get install weechat Mandriva/RedHat (or any RPM compatible distribution): rpm -i /chemin/weechat-x.y.z-1.i386.rpm Gentoo : emerge weechat For other distributions, please look at your manual for installation instructions.
Source package All you have to do is to run in a console or a terminal: $ ./configure $ make Then get root privileges and install WeeChat: $ su (enter root password) # make install
CVS sources Warning: CVS sources are for advanced users: it may not compile or not be stable. You're warned! To get CVS sources, issue this command: $ cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/weechat co weechat Execute this script: ./autogen.sh Then follow instructions for source package (see )
Usage This chapter explains how to run WeeChat, the default key bindings used, internal and IRC commands, setup file, and FIFO pipe use.
Running WeeChat Command line arguments: Parameter Description -a, --no-connect Disable auto-connect to servers at startup -c, --config Display config help (list of options) -d, --dir <path> Set path as home for WeeChat (used for configuration files, logs, user plugins and scripts). Default value is "~/.weechat". Please note that directory is created if not found by WeeChat. -f, --key-functions Display WeeChat internal functions for keys -h, --help Display help -i, --irc-commands Display IRC commands list -k, --keys Display WeeChat default keys -l, --license Display WeeChat license -p, --no-plugin Disable plugins auto-load -v, --version Display WeeChat version -w, --weechat-commands Display WeeChat commands list It is also possible to give URL for one or many IRC servers, as follow: irc[6][s]://[pseudo[:mot_passe]@]irc.example.org[:port][/channel][,channel[...] Example to join #weechat and #toto on "irc.freenode.net" server, default port (6667), with "nono" nick: $ weechat-curses irc://nono@irc.freenode.net/#weechat,#toto To start WeeChat, issue this command: for Curses GUI: weechat-curses for Gtk GUI: weechat-gtk for wxWidgets GUI: weechat-wxwidgets for Qt GUI: weechat-qt When you run WeeChat for the first time, a default configuration file is created, with default options. The default configuration file is: "~/.weechat/weechat.rc" You can edit this file at your convenience to configure WeeChat (ONLY if WeeChat is not running), or you can set parameters with "/set" command in WeeChat (see )
Key bindings Key Action Left arrow Go to previous char in command line Right arrow Go to next char in command line Ctrl + left arrow Go to previous word in command line Ctrl + right arrow Go to next word in command line Home / Ctrl + A Go to the beginning of command line End / Ctrl + E Go to the end of command line Ctrl + K Delete from cursor until end of command line Ctrl + L Redraw whole window Ctrl + R Search for text in buffer history (two times: search exact text) Ctrl + T Transpose chars Ctrl + U Delete from cursor until beginning of command line Ctrl + W Delete previous word of command line Ctrl + Y Paste clipboard content Backspace / Ctrl + H Delete previous char in command line Delete Delete next char in command line Tab / Shift + Tab Complete command or nick (Tab again: find next completion) Any char Insert char at cursor position in command line Enter / Ctrl + J / Ctrl + M Execute command or send message (in search mode: stop search) Up arrow / Down arrow Call again last commands/messages (in search mode: search up/down) Ctrl + up arrow / Ctrl + down arrow Call again last commands/messages in global history (common for all buffers) PageUp / PageDown Scroll up / down one page in buffer history Alt + PageUp / Alt + PageDown Scroll up / down a few lines in buffer history Alt + Home / Alt + End Scroll to top / bottom of buffer F5 / Alt + left arrow Switch to previous buffer F6 / Alt + right arrow Switch to next buffer F7 Switch to previous window F8 Switch to next window F9 / F10 Scroll topic F11 / F12 Scroll nicklist Alt + F11 / Alt + F12 Go to the beginning / the end of nicklist Alt + A Switch to next buffer with activity (with priority: highlight, message, other) Alt + B Go to previous word in command line Alt + D Delete next word in command line Alt + F Go to next word in command line Alt + H Clear hotlist (activity notification on other buffers) Alt + I Remove last infobar message Alt + J then Alt + D Display DCC buffer Alt + J then Alt + L Switch to last buffer Alt + J then Alt + R Switch to raw IRC data buffer Alt + J then Alt + S Switch to server buffer Alt + J then Alt + X Switch to first channel of next server (or server buffer if no channel is opened) Alt + digit (0-9) Switch to buffer by number (0 = 10) Alt + J then number (01-99) Switch to buffer by number Alt + K Grab a key and insert its code in command line Alt + N Scroll to next highlight Alt + P Scroll to previous highlight Alt + R Delete entire command line Alt + S Switch servers on servers buffer (if option "look_one_server_buffer" is enabled) Alt + U Scroll to first unread line in buffer Alt + W then Alt + arrow Switch to window with direction
Command line WeeChat command line (at the bottom of window) lets you send text on channels and execute WeeChat or IRC commands (see ). Commands begin with "/" char, followed by name of command. For example, to initiate a private chat with "toto": /query toto Text sent to a channel is any text that does not begin with "/" char. For example, to send text "hello" on current channel: hello However, it is possible to start with "/" char, by adding another. For example, to send text "/query toto" on current channel: //query toto If option for sending IRC colors ("irc_colors_send") is enabled, you can use color codes and attributes, as follow: Code Description %B bold text %Cxx text color "xx" (see colors table below) %Cxx,yy text color "xx" and background "yy" (see colors table below) %O disable color and attributes %R reverse video (revert text color with background) %U underlined text %% display one "%" Note: the same code (without number for %C) may be used to stop the attribute. Color codes for %C are: Code Color 00 white 01 black 02 dark blue 03 dark green 04 light red 05 dark red 06 magenta 07 orange 08 yellow 09 light green 10 cyan 11 light cyan 12 light blue 13 light magenta 14 gray 15 light gray (white) Example: display of "hello everybody!" with "hello" in light blue bold, and "everybody" in light red underlined: %C12%Bhello%B%C04%U everybody%U%C!
WeeChat / IRC commands This chapter lists all WeeChat and IRC commands.
WeeChat commands &weechat_commands.xml;
Key functions Function Description &key_functions.xml;
IRC commands &irc_commands.xml;
Configuration file List of options for config file: Option Type Values Default Description &config.xml; Colors for Curses GUI are: Keyword Color default default color (transparent for background) black black red dark red lightred light red green dark green lightgreen light green brown brown yellow yellow blue dark blue lightblue light blue magenta dark magenta lightmagenta light magenta cyan dark cyan lightcyan light cyan white white
FIFO pipe You can remote control WeeChat, by sending commands or text to a FIFO pipe (you have to enable option "irc_fifo_pipe", it is disabled by default). The FIFO pipe is located in "~/.weechat/" and is called "weechat_fifo_xxxxx" (where xxxxx is the process ID (PID) of running WeeChat). So if many WeeChat are running, you have many FIFO pipes, one for each session. The syntax for the FIFO pipe commands/text is: server,channel *text or command here where server and channel are optional, but if channel is here, server should be too. Some examples: nick change on freenode to "mynick|out" : $ echo 'freenode */nick mynick|out' >~/.weechat/weechat_fifo_12345 display text on #weechat channel: $ echo 'freenode,#weechat *hello everybody!' >~/.weechat/weechat_fifo_12345 display text on current channel (buffer displayed by WeeChat): $ echo '*hello!' >~/.weechat/weechat_fifo_12345 Warning: this is dangerous and you should not do that except if you know what you do! send two commands to unload/reload Perl scripts (you have to separate them with "\n"): $ echo -e "freenode */perl unload\nfreenode */perl autoload" >~/.weechat/weechat_fifo_12345 You can write a script to send command to all running WeeChat at same time, for example: #!/bin/sh if [ $# -eq 1 ]; then for fifo in $(/bin/ls ~/.weechat/weechat_fifo_* 2>/dev/null); do echo -e "$1" >$fifo done fi If the script is called "auto_weechat_command", you can run it with: $ ./auto_weechat_command "freenode,#weechat *hello"
Plugins This chapter describes WeeChat plugins interface (API) and the default scripts plugins (Perl, Python, Ruby, Lua), provided with WeeChat.
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 /plugin. The plugin has to be a dynamic library, for dynamic loading by operating system. Under GNU/Linux, the file has ".so" extension, ".dll" under Windows.
Write a plugin The plugin has to 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): Variable Description char plugin_name[] plugin name char plugin_version[] plugin version char plugin_description[] short description of plugin Function Description int weechat_plugin_init (t_weechat_plugin *plugin) function called when plugin is loaded, must return PLUGIN_RC_OK if successful, PLUGIN_RC_KO if error (if error, plugin will NOT be loaded) void weechat_plugin_end (t_weechat_plugin *plugin) function called when plugin is unloaded
API functions
set_charset Prototype: void set_charset (t_weechat_plugin *plugin, char *charset) Set new plugin charset. Arguments: : pointer to plugin structure : new charset to use Example: plugin->set_charset (plugin, "ISO-8859-1");
iconv_to_internal Prototype: void iconv_to_internal (t_weechat_plugin *plugin, char *charset, char *string) Convert string to WeeChat internal charset (UTF-8). Arguments: : pointer to plugin structure : charset to convert : string to convert Return value: converted string. Note: result has to be free by a call to "free" after use. Example: char *str = plugin->iconv_to_internal (plugin, "ISO-8859-1", "iso string: é à");
iconv_from_internal Prototype: void iconv_from_internal (t_weechat_plugin *plugin, char *charset, char *string) Convert string from internal WeeChat charset (UTF-8) to another. Arguments: : pointer to plugin structure : target charset : string to convert Return value: converted string. Note: result has to be free by a call to "free" after use. Example: char *str = plugin->iconv_from_internal (plugin, "ISO-8859-1", "utf-8 string: é à");
ascii_strcasecmp Prototype: int ascii_strcasecmp (t_weechat_plugin *plugin, char *string1, char *string2) Locale and case independent string comparison. Arguments: : pointer to plugin structure : first string for comparison : second string for comparison Return value: difference between two strings: negative if string1 < string2, zero if string1 == string2, positive if string1 > string2 Example: if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...
ascii_strncasecmp Prototype: int ascii_strncasecmp (t_weechat_plugin *plugin, char *string1, char *string2, int max) Locale and case independent string comparison, for "max" chars. Arguments: : pointer to plugin struct : first string for comparison : second string for comparison : max number of chars for comparison Return value: difference between two strings: negative if string1 < string2, zero if string1 == string2, positive if string1 > string2 Example: if (plugin->ascii_strncasecmp (plugin, "abc", "def", 2) != 0) ...
explode_string Prototype: 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). Arguments: : pointer to plugin struct : string to explode : delimiters used for explosion : maximum number of items created (0 = no limit) : pointer to int which will contain number of items created Return value: array of strings, NULL if problem. Note: result has to be free by a call to "free_exloded_string" after use. Example: char **argv; int argc; argv = plugin->explode_string (plugin, string, " ", 0, &argc); ... if (argv != NULL) plugin->free_exploded_string (plugin, argv);
free_exploded_string Prototype: char **free_exploded_string (t_weechat_plugin *plugin, char **string) Free memory used by a string explosion. Arguments: : pointer to plugin structure : string exploded by "explode_string" function Return value: none. Example: char *argv; int argc; argv = plugin->explode_string (plugin, string, " ", 0, &argc); ... if (argv != NULL) plugin->free_exploded_string (plugin, argv);
mkdir_home Prototype: int mkdir_home (t_weechat_plugin *plugin, char *directory) Create a directory in WeeChat home. Arguments: : pointer to plugin structure : directory to create Return value: 1 if directory was successfully created, 0 if an error occurred. Example: if (!plugin->mkdir_home (plugin, "temp")) plugin->print_server(plugin, "Failed to create 'temp' directory in WeeChat home.");
exec_on_files Prototype: 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. Arguments: : pointer to plugin structure : directory for searching files : function called for each file found Return value: none. Example: int callback (t_weechat_plugin *plugin, char *file) { plugin->print_server (plugin, "file: %s", file); return 1; } ... plugin->exec_on_files (plugin, "/tmp", &callback);
print Prototype: void print (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 for current buffer). Arguments: : pointer to plugin structure : internal name of server to find buffer for message display (may be NULL) : name of channel to find buffer for message display (may be NULL) : message Return value: none. Examples: plugin->print (plugin, NULL, NULL, "hello"); plugin->print (plugin, NULL, "#weechat", "hello"); plugin->print (plugin, "freenode", "#weechat", "hello");
print_server Prototype: void print_server (t_weechat_plugin *plugin, char *message, ...) Display a message on current server buffer. Arguments: : pointer to plugin structure : message Return value: none. Example: plugin->print_server (plugin, "hello");
print_infobar Prototype: void print_infobar (t_weechat_plugin *plugin, int time, char *message, ...) Display a message in infobar for a specified time. Arguments: : pointer to plugin structure : time (in seconds) for displaying message (0 = never erased) Return value: none. Example: plugin->print_infobar (plugin, 5, "hello");
infobar_remove Prototype: void infobar_remove (t_weechat_plugin *plugin, int count) Remove one or more messages in infobar stack. Arguments: : pointer to plugin structure : number of messages to remove (if argument is <= 0, then all messages are removed) Return value: none. Example: plugin->infobar_remove (1);
log Prototype: void log (t_weechat_plugin *plugin, char *server, char *channel, char *message, ...) Write a message in log file for a server or a channel. Arguments: : pointer to plugin structure : internal name of server to find buffer for log (may be NULL) : name of channel to find buffer for log (may be NULL) : message Return value: none. Example: plugin->log (plugin, "freenode", "#weechat", "test");
msg_handler_add Prototype: t_plugin_handler *msg_handler_add (t_weechat_plugin *plugin, char *message, t_plugin_handler_func *function, char *handler_args, void *handler_pointer) Add an IRC message handler, called when an IRC message is received. Arguments: : pointer to plugin structure : name of IRC message ("*" for all messages). To know list of IRC messages, please consult RFCs 1459 and 2812. Moreover you can use a special name, prefixed by "weechat_" to catch special events, as written in table below: Name Description weechat_pv private message received weechat_highlight message with highlight (on a channel or pv) weechat_ctcp CTCP message received (VERSION, PING, ..) weechat_dcc DCC message received (chat or file) : function called when message is received It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) Argument argc is set to 3, following values are set in argv array: argv[0] = server name argv[1] = IRC message argv[2] = command arguments : arguments given to function when called : pointer given to function when called Return value: pointer to new message handler. Note: function called when message is received has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed PLUGIN_RC_OK_IGNORE_WEECHAT: message will not be sent to WeeChat PLUGIN_RC_OK_IGNORE_PLUGINS: message will not be sent to other plugins PLUGIN_RC_OK_IGNORE_ALL: message will not be sent to WeeChat neither other plugins PLUGIN_RC_OK_WITH_HIGHLIGHT: function successfully completed and make "highlight" on received message Example: int msg_kick (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) { plugin->print (plugin, argv[0], NULL, "KICK received"); return PLUGIN_RC_OK; } ... t_plugin_handler *msg_handler; msg_handler = plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);
cmd_handler_add Prototype: t_plugin_handler *cmd_handler_add (t_weechat_plugin *plugin, char *command, char *description, char *arguments, char *arguments_description, char *completion_template, t_plugin_handler_func *fonction, char *handler_args, void *handler_pointer) Add a WeeChat command handler, called when user uses command (for example /command). Arguments: : pointer to plugin structure : the new command name, which may be an existing command (be careful, replaced command will not be available until plugin is unloaded) : short command description (displayed by /help command) : short description of command arguments (displayed by /help command) : long description of command arguments (displayed by /help command) : template for completion, like "abc|%w def|%i" which means "abc" or a WeeChat command for first argument, "def" or IRC command for second. An empty string lets WeeChat complete any argument with a nick from current channel, NULL or "-" disable completion for all command arguments. Following codes can be used: Code Description %- no completion for argument %a alias %A alias and commands (WeeChat, IRC and plugins) %c current channel %C channels of current server %f file name %h plugins commands %i IRC commands (sent) %I IRC commands (received) %k key functions %m nick on current server %n nicks of current channel %N nicks and hostnames of current channel %o setup options %O plugin options %p default "part" message %q default "quit" message %s current server name %S all servers names %t topic of current channel %v setup option value %V plugin option value %w WeeChat commands : function called when command is executed It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) Argument argc is set to 3, following values are set in argc array: argv[0] = server name argv[1] = command argv[2] = command arguments : arguments given to function when called : pointer given to function when called Return value: pointer to new command handler. Note: function called when command is executed has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed Example: int cmd_test (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) { plugin->print (plugin, argv[0], NULL, "test command, nick: %s", (argv[2]) ? argv[2] : "none"); return PLUGIN_RC_OK; } ... t_plugin_handler *cmd_handler; cmd_handler = plugin->cmd_handler_add (plugin, "test", "Test command", "[nick]", "nick: nick of channel", "%n", &cmd_test, NULL, NULL);
timer_handler_add Prototype: t_plugin_handler *timer_handler_add (t_weechat_plugin *plugin, int interval, t_plugin_handler_func *function, char *handler_args, void *handler_pointer) Add a timer handler which periodically calls a function. Arguments: : pointer to plugin structure : interval (in seconds) between two calls of function. : function called It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) Argument argc is set to 0, and argv is set to NULL. : arguments given to function when called : pointer given to function when called Return value: pointer to new timer handler. Note: function called has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed Example: int my_timer (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) { plugin->print (plugin, NULL, NULL, "my timer"); return PLUGIN_RC_OK; } ... t_plugin_handler *timer_handler; timer_handler = plugin->timer_handler_add (plugin, 60, &my_timer);
keyboard_handler_add Prototype: t_plugin_handler *keyboard_handler_add (t_weechat_plugin *plugin, t_plugin_handler_func *function, char *handler_args, void *handler_pointer) Add a keyboard handler, called for any key pressed. Arguments: : pointer to plugin structure : function called It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) Argument argc is set to 3, following values are set in argc array: argv[0] = key pressed (name of internal function or '*' followed by a key code) argv[1] = command line before key action argv[2] = command line after key action : arguments given to function when called : pointer given to function when called Return value: pointer to new message handler. Note: function called has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed Example: int my_keyb (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) { if (argc == 2) { plugin->print (plugin, NULL, NULL, "key pressed: %s", argv[0]); if (argv[1] && (argv[1][0] == '1')) plugin->print (plugin, NULL, NULL, "input text changed"); else plugin->print (plugin, NULL, NULL, "input text not changed"); } return PLUGIN_RC_OK; } ... t_plugin_handler *keyb_handler; keyb_handler = plugin->keyboard_handler_add (plugin, &my_keyb);
event_handler_add Prototype: t_plugin_handler *event_handler_add (t_weechat_plugin *plugin, char *event, t_plugin_handler_func *function, char *handler_args, void *handler_pointer) Add an event handler, called when an event happens. Arguments: : pointer to plugin structure : event, see table below: Event Description buffer_open a buffer was open buffer_close a buffer was closed : function called It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) Argument argc is set to 1, argv[0] is number of buffer open/closed. : arguments given to function when called : pointer given to function when called Return value: pointer to new event handler. Note: function called has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed Example: int my_event (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) { plugin->print (plugin, NULL, NULL, "my_event"); return PLUGIN_RC_OK; } ... t_plugin_handler *event_handler; event_handler = plugin->event_handler_add (plugin, "buffer_open", &my_event);
handler_remove Prototype: void handler_remove (t_weechat_plugin *plugin, t_plugin_handler *handler) Remove a command or message handler. Arguments: : pointer to plugin structure : handler to remove Return value: none. Example: plugin->handler_remove (plugin, my_handler);
handler_remove_all Prototype: void handler_remove_all (t_weechat_plugin *plugin) Remove all handlers for a plugin. Arguments: : pointer to plugin structure Return value: none. Example: plugin->handler_remove_all (plugin);
modifier_add Prototype: t_plugin_modifier *modifier_add (t_weechat_plugin *plugin, char *type, char *message, t_plugin_modifier_func *function, char *modifier_args, void *modifier_pointer) Add a message modifier. Arguments: : pointer to plugin structure : modifier type: Type Description irc_in called for incoming IRC messages irc_user called for each user message (or command) (before WeeChat parses message) irc_out called for outgoing messages, immediately before sending it to IRC server (this includes messages sent automatically by WeeChat to server) : name of IRC message (used only for types "irc_in" and "irc_out"). To know list of IRC messages, please consult RFCs 1459 and 2812. Moreover, special value "*" means all messages (no filter). : function called It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *modifier_args, void *modifier_pointer) Argument argc is set to 2, following values are set in argv array: argv[0] = server name argv[1] = message : arguments given to function when called : pointer given to function when called Return value: pointer to new message modifier. Note: function has to return modified string, or NULL if no changes are made to message. If function returns empty string, then message is dropped and will not be read at all by WeeChat (be careful when dropping messages!). Returned string must have been allocated by malloc() and will be freed (with call to free()) automatically by WeeChat after use. Example: char *adder (t_weechat_plugin *plugin, int argc, char **argv, char *modifier_args, void *modifier_pointer) { char *string; string = (char *)malloc (strlen (argv[1]) + 16); strcpy (string, argv[1]); strcat (string, "test"); return string; } ... t_plugin_modifier *modifier; modifier = plugin->modifier_add (plugin, "irc_in", "privmsg", &adder, NULL, NULL);
modifier_remove Prototype: void modifier_remove (t_weechat_plugin *plugin, t_plugin_modifier *modifier) Remove a message modifier. Arguments: : pointer to plugin structure : modifier to remove Return value: none. Example: plugin->modifier_remove (plugin, my_modifier);
modifier_remove_all Prototype: void modifier_remove_all (t_weechat_plugin *plugin) Remove all modifiers for a plugin. Arguments: : pointer to plugin structure Return value: none. Example: plugin->modifier_remove_all (plugin);
exec_command Prototype: void exec_command (t_weechat_plugin *plugin, char *server, char *channel, char *command) Execute a WeeChat command (or send a message to a channel). Arguments: : pointer to plugin structure : internal name of server for executing command (may be NULL) : name of channel for executing command (may be NULL) : command Return value: none. Examples: plugin->exec_command (plugin, NULL, NULL, "/help nick"); plugin->exec_command (plugin, "freenode", "#weechat", "hello");
get_info Prototype: char *get_info (t_weechat_plugin *plugin, char *info, char *server) Return an info about WeeChat or a channel. Arguments: : pointer to plugin structure : name of info to read: Info Description version WeeChat's version nick nick channel name of channel (NULL for a server or private) server name of server type buffer type: 0=standard, 1=DCC, 2=raw IRC data away "away" flag inactivity number of seconds since last key was pressed input content of command line for current window input_mask content of color mask for command line input_pos cursor position in command line weechat_dir WeeChat home directory (by default: ~/.weechat/) weechat_libdir WeeChat system lib directory weechat_sharedir WeeChat system share directory : internal name of server for reading info (if needed) Return value: information asked, NULL if not found. Note: result has to be free by a call to "free" function after use. Examples: char *version = plugin->get_info (plugin, "version", NULL); char *nick = plugin->get_info (plugin, "nick", "freenode"); char *inactivity = plugin->get_info (plugin, "inactivity", NULL); plugin->print (plugin, NULL, NULL, "WeeChat version %s, you are %s on freenode " "(inactive for %s seconds)", version, nick, inactivity); if (version) free (version); if (nick) free (nick); if (inactivity) free (inactivity);
get_dcc_info Prototype: t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin) Return list of DCC currently active or finished. Arguments: : pointer to plugin structure Return value: linked list of DCC. Type Field Description char * server IRC server char * channel IRC channel int type DCC type: 0 = chat received, 1 = chat sent, 2 = file received, 3 = file sent int* status DCC status: 0 = waiting, 1 = connecting, 2 = active, 3 = finished, 4 = failed, 5 = interrupted by user time_t start_time date/time of DCC creation time_t start_transfer date/time of DCC transfer start unsigned long addr IP address of remote user int port port used for DCC char * nick remote nick char * filename file name char * local_filename local file name int filename_suffix suffix if renaming file unsigned long size file size unsigned long pos position in file unsigned long start_resume start position after interruption unsigned long bytes_per_sec number of bytes per second since transfer start t_plugin_dcc_info * prev_dcc pointer to previous DCC info t_plugin_dcc_info * next_dcc pointer to next DCC info Note: result has to be free by a call to "free_dcc_info" function after use. Examples: t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin); for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc) { plugin->print_server (plugin, "DCC type=%d, with: %s", ptr_dcc->type, ptr_dcc->nick); } if (dcc_info) plugin->free_dcc_info (plugin, dcc_info);
free_dcc_info Prototype: void free_dcc_info (t_weechat_plugin *plugin, t_plugin_dcc_info *dcc_info) Free memory used by a DCC list. Arguments: : pointer to plugin structure : pointer to DCC list returned by "get_dcc_info" function Return value: none. Example: plugin->free_dcc_info (plugin, dcc_info);
get_server_info Prototype: t_plugin_server_info *get_server_info (t_weechat_plugin *plugin) Return list of IRC servers (connected or not). Arguments: : pointer to plugin structure Return value: linked list of IRC servers. Type Field Description char * name server internal name int autoconnect 1 if autoconnect at start-up, 0 otherwise int autoreconnect 1 if autoreconnect when disconnected, 0 otherwise int autoreconnect_delay delay before trying again connection int command_line 1 if server was on command line (so it is temporary), 0 otherwise char * address server address (host or IP) int port port int ipv6 IPv6 connection int ssl SSL connection char * password server password char * nick1 first nickname char * nick2 alternate nickname char * nick3 second alternate nickname char * username user name char * real name real name char * command command run once connected int command_delay delay after execution of command char * autojoin channels joined automatically int autorejoin 1 if channels are rejoined when kicked, 0 otherwise char * notify_levels channels notify levels char * charset_decode_iso channels charsets for decoding ISO char * charset_decode_utf channels charsets for decoding UTF char * charset_encode channels charsets for encoding messages int is_connected 1 if connected to server, 0 otherwise int ssl_connected 1 if connected with SSL, 0 otherwise char * nick current nickname int is_away 1 if away, 0 otherwise time_t away_time time when user is marking as away int lag lag (in milliseconds) t_plugin_server_info * prev_server pointer to previous server info t_plugin_server_info * next_server pointer to next server info Note: result has to be free by a call to "free_server_info" function after use. Example: t_plugin_server_info *server_info, *ptr_server_info; server_info = plugin->get_server_info (plugin); if (server_info) { for (ptr_server_info = server_info; ptr_server_info; ptr_server_info = ptr_server_info->next_server) { plugin->print (plugin, NULL, NULL, "server: %s, address: %s, port: %d %s", ptr_server_info->name, ptr_server_info->address, ptr_server_info->port, (ptr_server_info->is_connected) ? "(connected)" : ""); } plugin->free_server_info (plugin, server_info); }
free_server_info Prototype: void free_server_info (t_weechat_plugin *plugin, t_plugin_server_info *server_info) Free memory used by server info list. Arguments: : pointer to plugin structure : pointer to server list returned by "get_server_info" function Return value: none. Example: plugin->free_server_info (plugin, server_info);
get_channel_info Prototype: t_plugin_channel_info *get_channel_info (t_weechat_plugin *plugin, char *server) Return list of IRC channels for a server. Arguments: : pointer to plugin structure : internal server name Return value: linked list of IRC channels for server. Type Field Description int type 0 for a channel, 1 for a private char * name name of channel char * topic topic of channel char * modes channel modes int limit user limit char * key channel key int nicks_count number of nicks on channel t_plugin_channel_info * prev_channel pointer to previous channel info t_plugin_channel_info * next_channel pointer to next channel info Note: result has to be free by a call to "free_channel_info" function after use. Example: t_plugin_channel_info *channel_info, *ptr_chan_info; channel_info = plugin->get_channel_info (plugin, "freenode"); if (channel_info) { for (ptr_chan_info = channel_info; ptr_chan_info; ptr_chan_info = ptr_chan_info->next_channel) { plugin->print (plugin, NULL, NULL, " %s (type %d)", ptr_chan_info->name, ptr_chan_info->type); } plugin->free_channel_info (plugin, channel_info); }
free_channel_info Prototype: void free_channel_info (t_weechat_plugin *plugin, t_plugin_channel_info *channel_info) Free memory used by channel info list. Arguments: : pointer to plugin structure : pointer to channel info list returned by "get_channel_info" function Return value: none. Example: plugin->free_channel_info (plugin, channel_info);
get_nick_info Prototype: t_plugin_nick_info *get_nick_info (t_weechat_plugin *plugin, char *server, char *channel) Return list of nicks for a channel. Arguments: : pointer to plugin structure : internal server name : channel name Return value: linked list of nicks on channel. Type Field Description char * nick nick name char * host hostname int flags nick flags, binary "or" between values (1 = channel owner, 2 = channel admin, 4 = op, 8 = halfop, 16 = voice, 32 = away) t_plugin_nick_info * prev_nick pointer to previous nick info t_plugin_nick_info * next_nick pointer to next nick info Note: result has to be free by a call to "free_nick_info" function after use. Example: t_plugin_nick_info *nick_info, *ptr_nick_info; nick_info = plugin->get_nick_info (plugin, "freenode", "#weechat"); if (nick_info) { for (ptr_nick_info = nick_info; ptr_nick_info; ptr_nick_info = ptr_nick_info->next_nick) { plugin->print (plugin, NULL, NULL, " %s (flags: %d)", ptr_nick_info->nick, ptr_nick_info->flags); } plugin->free_nick_info (plugin, nick_info); }
free_nick_info Prototype: void free_nick_info (t_weechat_plugin *plugin, t_plugin_nick_info *nick_info) Free memory used by nick info list. Arguments: : pointer to plugin structure : pointer to nick info list returned by "get_nick_info" function Return value: none. Example: plugin->free_nick_info (plugin, nick_info);
get_config Prototype: char *get_config (t_weechat_plugin *plugin, char *option) Return value of a WeeChat config option. Arguments: : pointer to plugin structure : name of option to read Return value: option value, NULL if not found. Note: result has to be free by a call to "free" function after use. Examples: char *value1 = plugin->get_config (plugin, "look_set_title"); char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");
set_config Prototype: int set_config (t_weechat_plugin *plugin, char *option, char *value) Update value of a WeeChat config option. Arguments: : pointer to plugin structure : name of option to update : new value for option Return value: 1 if option was successfully updated, 0 if an error occurred. Example: plugin->set_config (plugin, "look_nicklist", "off");
get_plugin_config Prototype: char *get_plugin_config (t_weechat_plugin *plugin, char *option) Return value of a plugin option. Option is read from file "~/.weechat/plugins.rc" and is like: "plugin.option=value" (note: plugin name is automatically added). Arguments: : pointer to plugin structure : name of option to read Return value: option value, NULL if not found. Note: result has to be free by a call to "free" function after use. Example: char *value = plugin->get_plugin_config (plugin, "my_var");
set_plugin_config Prototype: int set_plugin_config (t_weechat_plugin *plugin, char *option, char *value) Update value of a plugin option. Option is written in file "~/.weechat/plugins.rc" and is like: "plugin.option=value" (note: plugin name is automatically added). Arguments: : pointer to plugin structure : name of option to update : new value for option Return value: 1 if option was successfully updated, 0 if an error occurred. Example: plugin->set_plugin_config (plugin, "my_var", "value");
get_irc_color Prototype: int get_irc_color (t_weechat_plugin *plugin, char *color_name) Get IRC color index with name. Arguments: : pointer to plugin structure : color name Allowed colors are: Color name Value white 0 black 1 blue 2 green 3 lightred 4 red 5 magenta 6 brown 7 yellow 8 lightgreen 9 cyan 10 lightcyan 11 lightblue 12 lightmagenta 13 gray 14 lightgray 15 Return value: IRC color index, -1 if color is not found. Example: int color_blue = plugin->get_irc_color (plugin, "blue"); /* return 2 */
input_color Prototype: void input_color (t_weechat_plugin *plugin, int color, int start, int length) Add color in input buffer. Arguments: : pointer to plugin structure : color for text (if < 0, then input buffer is refresh, and there's no change in input buffer content) : start position for color (if < 0, then mask is reinitialized) : length for color (if <= 0, then mask is reinitialized) Return value: none. Example: plugin->input_color (plugin, plugin->get_irc_color (plugin, "blue"), 10, 5);
get_window_info Prototype: t_plugin_window_info *get_window_info (t_weechat_plugin *plugin) Return list of WeeChat windows. Arguments: : pointer to plugin structure Return value: linked list of WeeChat windows. Type Field Description int win_x horizontal position of window int win_y vertical position of window int win_width width of window int win_height height of window int win_width_pct width % (compared to parent window) int win_height_pct height % (compared to parent window) int num_buffer number of displayed buffer t_plugin_window_info * prev_window pointer to previous window info t_plugin_window_info * next_window pointer to next window info Note: result has to be free by a call to "free_window_info" function after use. Example: t_plugin_window_info *window_info, *ptr_window; window_info = plugin->get_window_info (plugin); if (window_info) { for (ptr_window = window_info; ptr_window; ptr_window = ptr_window->next_window) { plugin->print (plugin, NULL, NULL, "--- window info ---"); plugin->print (plugin, NULL, NULL, "(%d,%d), size: %dx%d, %%size: %d%%x%d%%", ptr_window->win_x, ptr_window->win_y, ptr_window->win_width, ptr_window->win_height, ptr_window->win_width_pct, ptr_window->win_height_pct); plugin->print (plugin, NULL, NULL, "num_buffer: %d", ptr_window->num_buffer); } plugin->free_window_info (plugin, window_info); } else plugin->print (plugin, NULL, NULL, "no window info!");
free_window_info Prototype: void free_window_info (t_weechat_plugin *plugin, t_plugin_window_info *window_info) Free memory used by window info list. Arguments: : pointer to plugin structure : pointer to window info list returned by "get_window_info" function Return value: none. Example: plugin->free_window_info (plugin, window_info);
get_buffer_info Prototype: t_plugin_buffer_info *get_buffer_info (t_weechat_plugin *plugin) Return list of WeeChat buffers. Arguments: : pointer to plugin structure Return value: linked list of WeeChat buffers. Type Field Description int type buffer type: 0=standard, 1=DCC, 2=raw IRC data int number buffer number int num_displayed number of windows displaying buffer char * server_name server name for buffer (may be NULL) char * channel_name channel name for buffer (may be NULL) int notify_level notify level for buffer char * log_filename log filename (NULL means not logging) t_plugin_buffer_info * prev_buffer pointer to previous buffer info t_plugin_buffer_info * next_buffer pointer to next buffer info Note: result has to be free by a call to "free_buffer_info" function after use. Example: t_plugin_buffer_info *buffer_info, *ptr_buffer; buffer_info = plugin->get_buffer_info (plugin); if (buffer_info) { for (ptr_buffer = buffer_info; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) { plugin->print (plugin, NULL, NULL, "--- buffer info ---"); plugin->print (plugin, NULL, NULL, "type: %d", ptr_buffer->type); plugin->print (plugin, NULL, NULL, "number: %d", ptr_buffer->number); plugin->print (plugin, NULL, NULL, "num_displayed: %d", ptr_buffer->num_displayed); plugin->print (plugin, NULL, NULL, "server: %s", ptr_buffer->server_name); plugin->print (plugin, NULL, NULL, "channel: %s", ptr_buffer->channel_name); plugin->print (plugin, NULL, NULL, "notify level: %d", ptr_buffer->notify_level); plugin->print (plugin, NULL, NULL, "log filename: %s", ptr_buffer->log_filename); } plugin->free_buffer_info (plugin, buffer_info); } else plugin->print (plugin, NULL, NULL, "no buffer info!");
free_buffer_info Prototype: void free_buffer_info (t_weechat_plugin *plugin, t_plugin_buffer_info *buffer_info) Free memory used by buffer info list. Arguments: : pointer to plugin structure : pointer to buffer info list returned by "get_buffer_info" function Return value: none. Example: plugin->free_buffer_info (plugin, buffer_info);
get_buffer_data Prototype: t_plugin_buffer_data *get_buffer_info (t_weechat_plugin *plugin, char *server, char *channel) Return content of buffer. Arguments: : pointer to plugin structure : internal name of server : channel name Return value: buffer content (linked list of lines). Type Field Description time_t date date and time char * nick nick char * data line content (color codes are removed) t_plugin_buffer_line * prev_line pointer to previous line t_plugin_buffer_line * next_line pointer to next line Note: result has to be free by a call to "free_buffer_data" function after use. Example: t_plugin_buffer_line *buffer_line, *ptr_line; char text_time[256]; buffer_line = plugin->get_buffer_data (plugin); if (buffer_line) { for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line) { strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date))); plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s", text_time, ptr_line->nick, ptr_line->data); } plugin->free_buffer_data (plugin, buffer_line); }
free_buffer_data Prototype: void free_buffer_data (t_weechat_plugin *plugin, t_plugin_buffer_line *buffer_line) Free memory used by buffer line list. Arguments: : pointer to plugin structure : pointer to buffer line list returned by "get_buffer_data" function Return value: none. Example: plugin->free_buffer_data (plugin, buffer_line);
Compile plugin Compile does not need WeeChat sources, only file "weechat-plugin.h". To compile a plugin which has one file "toto.c" (under GNU/Linux): $ gcc -fPIC -Wall -c toto.c $ gcc -shared -fPIC -o libtoto.so toto.o
Load plugin into WeeChat Copy "libtoto.so" file into system plugins directory (for example "/usr/local/lib/weechat/plugins") or into user's plugins directory (for example "/home/xxxxx/.weechat/plugins"). Under WeeChat: /plugin load toto
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!): #include <stdlib.h> #include "weechat-plugin.h" char plugin_name[] = "Double"; char plugin_version[] = "0.1"; char plugin_description[] = "Test plugin for WeeChat"; /* "/double" command manager */ int double_cmd (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer) { if (argv[2] && (argv[2][0] != '/')) { plugin->exec_command (plugin, NULL, NULL, argv[2]); plugin->exec_command (plugin, NULL, NULL, argv[2]); } return PLUGIN_RC_OK; } int weechat_plugin_init (t_weechat_plugin *plugin) { plugin->cmd_handler_add (plugin, "double", "Display two times a message", "msg", "msg: message to display two times", NULL, &double_cmd, NULL, NULL); return PLUGIN_RC_OK; } void weechat_plugin_end (t_weechat_plugin *plugin) { /* nothing done here */ }
Scripts plugins Four plugins are provided with WeeChat to use script languages: Perl, Python, Ruby and Lua.
Load / unload scripts Scripts are loaded and unloaded with /perl, /python, /ruby and /lua commands (type /help in WeeChat for help about commands). Examples: Load a Perl script: /perl load /tmp/test.pl List all loaded Perl scripts: /perl Load a Python script: /python load /tmp/test.py List all loaded Python scripts: /python Load a Ruby script: /ruby load /tmp/test.rb List all loaded Ruby scripts: /ruby Load a Lua script: /lua load /tmp/test.lua List all loaded Lua scripts: /lua
Syntax by language
Perl In a WeeChat Perl script, all API functions and variables are prefixed by "weechat::". Example: weechat::register("test", "1.0", "end_test", "WeeChat perl script");
Python A WeeChat Python script has to start by importing weechat: import weechat All API functions and variables are prefixed by "weechat.". Example: weechat.register("test", "1.0", "end_test", "WeeChat python script")
Ruby In a WeeChat Ruby script, all code has to be in functions. So for main code, you have to define a "weechat_init" function, which is automatically called when script is loaded by WeeChat. Example: def weechat_init Weechat.register("test", "1.0", "end_test", "WeeChat ruby script") Weechat.add_command_handler("command", "my_command") return Weechat::PLUGIN_RC_OK end def my_command(server, args) Weechat.print("my command") return Weechat::PLUGIN_RC_OK end All API functions are prefixed by "Weechat." and variables by "Weechat::".
Lua In a WeeChat Lua script, all API functions are prefixed by "weechat.". Variables are prefixed by "weechat." and suffixed by "()". Example: function message_handler(server, args) weechat.print("I am a message handler") return weechat.PLUGIN_RC_OK() end
WeeChat / scripts API
register Perl prototype: weechat::register(name, version, end_function, description, [charset]); Python prototype: weechat.register(name, version, end_function, description, [charset]) Ruby prototype: Weechat.register(name, version, end_function, description, [charset]) Lua prototype: weechat.register(name, version, end_function, description, [charset]) This is first function to call in script. All WeeChat scripts have to call this function. Arguments: : unique name to identify script (each script must have unique name) : script version : function called when script is unloaded (optional parameter, empty string means nothing is called at the end) : short description of script : charset used by script, you should set this if script is not written with UTF-8 Return value: 1 if script was registered, 0 if an error occured. Examples: # perl weechat::register("test", "1.0", "end_test", "Test script!", "ISO-8859-1"); # python weechat.register("test", "1.0", "end_test", "Test script!", "ISO-8859-1") # ruby Weechat.register("test", "1.0", "end_test", "Test script!", "ISO-8859-1") -- lua weechat.register("test", "1.0", "end_test", "Test script!", "ISO-8859-1")
set_charset Perl prototype: weechat::set_charset(charset); Python prototype: weechat.set_charset(charset) Ruby prototype: Weechat.set_charset(charset) Lua prototype: weechat.set_charset(charset) Set new script charset. Arguments: : new script charset Return value: 1 if new charset was set, 0 if an error occured. Examples: # perl weechat::set_charset("ISO-8859-1"); # python weechat.set_charset("ISO-8859-1") # ruby Weechat.set_charset("ISO-8859-1") -- lua weechat.set_charset("ISO-8859-1")
print Perl prototype: weechat::print(message, [channel, [server]]) Python prototype: weechat.prnt(message, [channel, [server]]) Ruby prototype: Weechat.print(message, [channel, [server]]) Lua prototype: weechat.print(message, [channel, [server]]) Display a message on a WeeChat buffer, identified by server and channel. Arguments: : message : name of channel to find buffer for message display : internal name of server to find buffer for message display Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::print("message"); weechat::print("message", "#weechat"); weechat::print("message", "#weechat", "freenode"); # python weechat.prnt("message") weechat.prnt("message", "#weechat") weechat.prnt("message", "#weechat", "freenode") # ruby Weechat.print("message") Weechat.print("message", "#weechat") Weechat.print("message", "#weechat", "freenode") -- lua weechat.print("message") weechat.print("message", "#weechat") weechat.print("message", "#weechat", "freenode")
print_infobar Perl prototype: weechat::print_infobar(time, message); Python prototype: weechat.print_infobar(time, message) Ruby prototype: Weechat.print_infobar(time, message) Lua prototype: weechat.print_infobar(time, message) Display a message in infobar for a specified time. Arguments: : time (in seconds) for displaying message (0 = never erased) : message Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::print_infobar(5, "message"); # python weechat.print_infobar(5, "message") # ruby Weechat.print_infobar(5, "message") -- lua weechat.print_infobar(5, "message")
remove_infobar Perl prototype: weechat::remove_infobar([count]); Python prototype: weechat.remove_infobar([count]) Ruby prototype: Weechat.remove_infobar([count]) Lua prototype: weechat.remove_infobar([count]) Remove one or more messages in infobar stack. Arguments: : number of messages to remove (if argument not given or <= 0, then all messages are removed) Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_infobar(1); # python weechat.remove_infobar(1) # ruby Weechat.remove_infobar(1) -- lua weechat.remove_infobar(1)
log Perl prototype: weechat::log(message, [channel, [server]]); Python prototype: weechat.log(message, [channel, [server]]) Ruby prototype: Weechat.log(message, [channel, [server]]) Lua prototype: weechat.log(message, [channel, [server]]) Write a message in log file for a server or a channel. Arguments: : message : name of channel to find buffer for log : internal name of server to find buffer for log Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::log("message", "#weechat", "freenode"); # python weechat.log("message", "#weechat", "freenode") # ruby Weechat.log("message", "#weechat", "freenode") -- lua weechat.log("message", "#weechat", "freenode")
add_message_handler Perl prototype: weechat::add_message_handler(message, function); Python prototype: weechat.add_message_handler(message, function) Ruby prototype: Weechat.add_message_handler(message, function) Lua prototype: weechat.add_message_handler(message, function) Add an IRC message handler, called when an IRC message is received. Arguments: : name of IRC message. To know list of IRC messages, please consult RFCs 1459 and 2812. Moreover you can use a special name, prefixed by "weechat_" to catch special events (see ). : function called when message is received Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_message_handler ("privmsg", "my_function"); sub my_function { weechat::print("server=$_[0]"); ($null, $channel, $message) = split ":",$_[1],3; ($mask, $null, $channel) = split " ", $channel; weechat::print("mask=$mask, channel=$channel, msg=$message"); return weechat::PLUGIN_RC_OK; } # python weechat.add_message_handler ("privmsg", "my_function") def my_function(server, args): weechat.prnt("server="+server) null, channel, message = string.split(args, ":", 2) mask, null, channel = string.split(string.strip(channel), " ", 2) weechat.prnt("mask="+mask+", canal="+channel+", message="+message) return weechat.PLUGIN_RC_OK # ruby Weechat.add_message_handler("privmsg", "my_function") def my_function(server, args) Weechat.print("server=#{server}, args=#{args}") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_message_handler ("privmsg", "my_function") function my_function(server, args) weechat.print("server=" .. server .. ", args=" .. args) return weechat.PLUGIN_RC_OK() end Note: function called when message is received has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed PLUGIN_RC_OK_IGNORE_WEECHAT: message will not be sent to WeeChat PLUGIN_RC_OK_IGNORE_PLUGINS: message will not be sent to other plugins PLUGIN_RC_OK_IGNORE_ALL: message will not be sent to WeeChat neither other plugins PLUGIN_RC_OK_WITH_HIGHLIGHT: function successfully completed and make "highlight" on received message
add_command_handler Perl prototype: weechat::add_command_handler(command, function, [description, arguments, arguments_description, completion_template]); Python prototype: weechat.add_command_handler(command, function, [description, arguments, arguments_description, completion_template]) Ruby prototype: Weechat.add_command_handler(command, function, [description, arguments, arguments_description, completion_template]) Lua prototype: weechat.add_command_handler(command, function, [description, arguments, arguments_description, completion_template]) Add a WeeChat command handler, called when user uses command (for example /command). Arguments: : the new command name, which may be an existing command (be careful, replaced command will not be available until script is unloaded) : function called when command is executed : short description of command arguments (displayed by /help command) : long description of command arguments (displayed by /help command) : template for completion, like "abc|%w def|%i" which means "abc" or a WeeChat command for first argument, "def" or IRC command for second. (see ) Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_command_handler("command", "my_command"); sub my_command { weechat::print("server= $_[0], args: $_[1]"); return weechat::PLUGIN_RC_OK; } # python weechat.add_command_handler("command", "my_command") def my_command(server, args): weechat.prnt("server="+server+", args="+args) return weechat.PLUGIN_RC_OK # ruby Weechat.add_command_handler("command", "my_command") def my_command(server, args) Weechat.print("server=#{server}, args=#{args}") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_command_handler("command", "my_command") def my_command(server, args) weechat.print("server="..server..", args="..args) return weechat.PLUGIN_RC_OK() end Notes: function called when command is executed has to return one of following values: PLUGIN_RC_KO : function failed PLUGIN_RC_OK : function successfully completed
add_timer_handler Perl prototype: weechat::add_timer_handler(interval, function); Python prototype: weechat.add_timer_handler(interval, function) Ruby prototype: Weechat.add_timer_handler(interval, function) Lua prototype: weechat.add_timer_handler(interval, function) Add a timer handler which periodically calls a function. Arguments: : interval (in seconds) between two calls of function. : function called Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_timer_handler(60, "my_timer"); sub my_timer { weechat::print("this is timer handler"); return weechat::PLUGIN_RC_OK; } # python weechat.add_timer_handler(60, "my_timer") def my_timer(): weechat.prnt("this is timer handler") return weechat.PLUGIN_RC_OK # ruby Weechat.add_timer_handler(60, "my_timer") def my_timer() Weechat.print("this is timer handler") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_timer_handler(60, "my_timer") function my_timer() weechat.print("this is timer handler") return weechat.PLUGIN_RC_OK() end Note: function called has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed
add_keyboard_handler Perl prototype: weechat::add_keyboard_handler(function); Python prototype: weechat.add_keyboard_handler(function) Ruby prototype: Weechat.add_keyboard_handler(function) Lua prototype: weechat.add_keyboard_handler(function) Add a keyboard handler, called for any key pressed. Arguments: : function called Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_keyboard_handler("my_keyboard"); sub my_keyboard { my $key = shift; my $input_before = shift; my $input_after = shift; weechat::print("keyboard handler: key = '$key', " ."input before = '$input_before' " ."after = '$input_after'"); return weechat::PLUGIN_RC_OK; } # python weechat.add_keyboard_handler("my_keyboard") def my_keyboard(key, input_before, input_after): weechat.prnt("keyboard handler: key = '%s', " \ "input before = '%s' after = '%s'" %(key, input_before, input_after)) return weechat.PLUGIN_RC_OK # ruby Weechat.add_keyboard_handler("my_keyboard") def my_keyboard(key, input_before, input_after) Weechat.print("keyboard handler: key = '#{key}', " \ "input before = '#{input_before}' " \ "after = '#{input_after}'") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_keyboard_handler("my_keyboard") function my_keyboard(key, input_before, input_after) weechat.print("keyboard handler: key = '"..key.. "', input before = '"..input_before.. "' after = '"..input_after.."'") return weechat.PLUGIN_RC_OK() end Note: function called has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed
add_event_handler Perl prototype: weechat::add_event_handler(event, function); Python prototype: weechat.add_event_handler(event, function) Ruby prototype: Weechat.add_event_handler(event, function) Lua prototype: weechat.add_event_handler(event, function) Add an event handler, called when an event happens. Arguments: : event (see ) : function called Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_event_handler("buffer_open", "my_event"); sub my_event { weechat::print("buffer open"); return weechat::PLUGIN_RC_OK; } # python weechat.add_event_handler("buffer_open", "my_event") def my_event(): weechat.prnt("buffer open") return weechat.PLUGIN_RC_OK # ruby Weechat.add_event_handler("buffer_open", "my_event") def my_event() Weechat.print("buffer open") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_event_handler("buffer_open", "my_event") function my_event() weechat.print("buffer open") return weechat.PLUGIN_RC_OK() end Note: function called has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed
remove_handler Perl prototype: weechat::remove_handler(name, function); Python prototype: weechat.remove_handler(name, function) Ruby prototype: Weechat.remove_handler(name, function) Lua prototype: weechat.remove_handler(name, function) Remove a message or command handler. Arguments: : name of IRC message or command : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_handler("command", "my_command"); # python weechat.remove_handler("command", "my_command") # ruby Weechat.remove_handler("command", "my_command") -- lua weechat.remove_handler("command", "my_command")
remove_timer_handler Perl prototype: weechat::remove_timer_handler(function); Python prototype: weechat.remove_timer_handler(function) Ruby prototype: Weechat.remove_timer_handler(function) Lua prototype: weechat.remove_timer_handler(function) Remove a timer handler. Arguments: : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_timer_handler("my_timer"); # python weechat.remove_timer_handler("my_timer") # ruby Weechat.remove_timer_handler("my_timer") -- lua weechat.remove_timer_handler("my_timer")
remove_keyboard_handler Perl prototype: weechat::remove_keyboard_handler(function); Python prototype: weechat.remove_keyboard_handler(function) Ruby prototype: Weechat.remove_keyboard_handler(function) Lua prototype: weechat.remove_keyboard_handler(function) Remove a keyboard handler. Arguments: : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_keyboard_handler("my_keyboard"); # python weechat.remove_keyboard_handler("my_keyboard") # ruby Weechat.remove_keyboard_handler("my_keyboard") -- lua weechat.remove_keyboard_handler("my_keyboard")
remove_event_handler Perl prototype: weechat::remove_event_handler(function); Python prototype: weechat.remove_event_handler(function) Ruby prototype: Weechat.remove_event_handler(function) Lua prototype: weechat.remove_event_handler(function) Remove an event handler. Arguments: : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_event_handler("my_event"); # python weechat.remove_event_handler("my_event") # ruby Weechat.remove_event_handler("my_event") -- lua weechat.remove_event_handler("my_event")
add_modifier Perl prototype: weechat::add_modifier(type, message, function); Python prototype: weechat.add_modifier(type, message, function) Ruby prototype: Weechat.add_modifier(type, message, function) Lua prototype: weechat.add_modifier(type, message, function) Add a message modifier. Arguments: : modifier type: Type Description irc_in called for incoming IRC messages irc_user called for each user message (or command) (before WeeChat parses message) irc_out called for outgoing messages, immediately before sending it to IRC server (this includes messages sent automatically by WeeChat to server) : name of IRC message (used only for types "irc_in" and "irc_out"). To know list of IRC messages, please consult RFCs 1459 and 2812. Moreover, special value "*" means all messages (no filter). : function called Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_modifier("irc_in", "privmsg", "mod_in"); weechat::add_modifier("irc_out", "privmsg", "mod_out"); sub mod_in { return "$_[1] [modifier IN]"; } sub mod_out { return "$_[1] [modifier OUT]"; } # python weechat.add_modifier("irc_in", "privmsg", "mod_in") weechat.add_modifier("irc_out", "privmsg", "mod_out") def mod_in(serveur, args): return args + " [modifier IN]" def mod_out(serveur, args): return args + " [modifier OUT]" # ruby Weechat.add_modifier("irc_in", "privmsg", "mod_in") Weechat.add_modifier("irc_out", "privmsg", "mod_out") def mod_in(server, args) return args + " [modifier IN]" end def mod_out(server, args) return args + " [modifier OUT]" end -- lua weechat.add_modifier("irc_in", "privmsg", "mod_in") weechat.add_modifier("irc_out", "privmsg", "mod_out") function mod_in(server, args) return args .. " [modifier IN]" end function mod_out(server, args) return args .. " [modifier OUT]" end
remove_modifier Perl prototype: weechat::remove_modifier(type, message, function); Python prototype: weechat.remove_modifier(type, message, function) Ruby prototype: Weechat.remove_modifier(type, message, function) Lua prototype: weechat.remove_modifier(type, message, function) Remove a message modifier. Arguments: : modifier type : message managed by modifier : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_modifier("irc_in", "privmsg", "mod_in"); # python weechat.remove_modifier("irc_in", "privmsg", "mod_in") # ruby Weechat.remove_modifier("irc_in", "privmsg", "mod_in") -- lua weechat.remove_modifier("irc_in", "privmsg", "mod_in")
command Perl prototype: weechat::command(command, [channel, [server]]); Python prototype: weechat.command(command, [channel, [server]]) Ruby prototype: Weechat.command(command, [channel, [server]]) Lua prototype: weechat.command(command, [channel, [server]]) Execute a WeeChat command (or send a message to a channel). Arguments: : command : name of channel for executing command : internal name of server for executing command Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::command("hello everybody!"); weechat::command("/kick toto please leave this channel", "#weechat"); weechat::command("/nick newnick", "", "freenode"); # python weechat.command("hello everybody!") weechat.command("/kick toto please leave this channel", "#weechat") weechat.command("/nick newnick", "", "freenode") # ruby Weechat.command("hello everybody!") Weechat.command("/kick toto please leave this channel", "#weechat") Weechat.command("/nick newnick", "", "freenode") -- lua weechat.command("hello everybody!") weechat.command("/kick toto please leave this channel", "#weechat") weechat.command("/nick newnick", "", "freenode")
get_info Perl prototype: weechat::get_info(name, [server]); Python prototype: weechat.get_info(name, [server]) Ruby prototype: Weechat.get_info(name, [server]) Lua prototype: weechat.get_info(name, [server]) Return an info about WeeChat or a channel. Arguments: : name of info to read (see ) : internal name of server for reading info (if needed) Return value: information asked, empty string if an error occurred. Examples: # perl $version = get_info("version"); $nick = get_info("nick", "freenode"); # python version = weechat.get_info("version") nick = weechat.get_info("nick", "freenode") # ruby version = Weechat.get_info("version") nick = Weechat.get_info("nick", "freenode") -- lua version = weechat.get_info("version") nick = weechat.get_info("nick", "freenode")
get_dcc_info Perl prototype: weechat::get_dcc_info(); Python prototype: weechat.get_dcc_info() Ruby prototype: Weechat.get_dcc_info() Lua prototype: weechat.get_dcc_info() Return list of DCC currently active or finished. Return value: list of DCC (see ). Examples: # perl my @dccs = weechat::get_dcc_info(); if (@dccs) { foreach my $dcc (@dccs) { while (my ($key, $value) = each %$dcc) { weechat::print("$key = '$value'"); } } } else { weechat::print("no DCC"); } # python dccs = weechat.get_dcc_info() if dccs != None: if dccs == []: weechat.prnt("no DCC") else: for d in dccs: for b in d.keys(): weechat.prnt("%s = '%s'" %(b, d[b])) else: weechat.prnt("error while getting DCC") # ruby dccs = Weechat.get_dcc_info() if dccs != nil if dccs == [] Weechat.print("no DCC") else dccs.each do |m| m.each do |key, value| Weechat.print("#{key} = '#{value}'") end end end else Weechat.print("error while getting DCC") end -- lua dccs = weechat.get_dcc_info() if dccs ~= nil then if dccs then dcc, dccinfos = next (dccs, nil) while (dcc) do key, value = next (dccinfos, nil) while (key) do weechat.print(key.." = '"..value.."'") key, value = next (dccinfos, key) end dcc, dccinfos = next (dccs, dcc) end else weechat.print("no DCC") end else weechat.print("error while getting DCC") end
get_server_info Perl prototype: weechat::get_server_info(); Python prototype: weechat.get_server_info() Ruby prototype: Weechat.get_server_info() Lua prototype: weechat.get_server_info() Return list of IRC servers (connected or not). Return value: list of servers (see ). Examples: # perl my $servers = weechat::get_server_info(); if ($servers) { while (my ($srvname, $srvinfos) = each %$servers) { while ( my ($key, $value) = each %$srvinfos) { weechat::print("$srvname -> $key = '$value'"); } } } else { weechat::print("no server"); } # python servers = weechat.get_server_info() if servers != None: if servers == {}: weechat.prnt("no server") else: for s in servers: for i in servers[s]: weechat.prnt("%s -> %s = '%s'" % (s, i, str(servers[s][i]))) else: weechat.prnt("error while getting servers") # ruby servers = Weechat.get_server_info() if servers != nil if servers == [] Weechat.print("no server") else servers.each do |n, s| s.each do |key, value| Weechat.print("#{n} -> #{key} = '#{value}'") end end end else Weechat.print("error while getting servers") end -- lua servers = weechat.get_server_info() if servers ~= nil then if servers then srv, srvinfos = next (servers, nil) while (srv) do key, value = next (srvinfos, nil) while (key) do weechat.print(srv.." -> "..key.." = '"..value.."'") key, value = next (srvinfos, key) end srv, srvinfos = next (servers, srv) end else weechat.print("no server") end else weechat.print("error while getting servers") end
get_channel_info Perl prototype: weechat::get_channel_info(server); Python prototype: weechat.get_channel_info(server) Ruby prototype: Weechat.get_channel_info(server) Lua prototype: weechat.get_channel_info(server) Return list of IRC channels for a server. Return value: list of IRC channels for server (see ). Examples: # perl my $channels = weechat::get_channel_info(weechat::get_info("server")); if ($channels) { while (my ($channame, $chaninfos) = each %$channels) { while (my ($key, $value) = each %$chaninfos) { weechat::print("$channame -> $key = '$value'"); } } } else { weechat::print("no channel"); } # python chans = weechat.get_channel_info(weechat.get_info("server")) if chans != None: if chans == {}: weechat.prnt("no channel") else: for s in chans: for i in chans[s]: weechat.prnt("%s -> %s = '%s'" % (s, i, str(chans[s][i]))) else: weechat.prnt("error while getting channels") # ruby channels = Weechat.get_channel_info(Weechat.get_info("server")) if channels != nil if channels == {} Weechat.print("no channel") else channels.each do |n, c| c.each do |key, value| Weechat.print("#{n} -> #{key} = '#{value}'") end end end else Weechat.print("error while getting channels") end -- lua chans = weechat.get_channel_info(weechat.get_info("server")) if chans ~= nil then if chans then chan, chaninfos = next (chans, nil) while (chan) do key, value = next (chaninfos, nil) while (key) do weechat.print(chan.." -> "..key.." = '"..value.."'") key, value = next (chaninfos, key) end chan, chaninfos = next (chans, chan) end else weechat.print("no channel") end else weechat.print("error while getting channels") end
get_nick_info Perl prototype: weechat::get_nick_info(server, channel); Python prototype: weechat.get_nick_info(server, channel) Ruby prototype: Weechat.get_nick_info(server, channel) Lua prototype: weechat.get_nick_info(server, channel) Return list of nicks for a channel. Return value: list of nicks on channel (see ). Examples: # perl my $nicks = weechat::get_nick_info("freenode", "#weechat"); if ($nicks) { while (my ($nickname, $nickinfos) = each %$nicks) { while ( my ($key, $value) = each %$nickinfos) { weechat::print("$nickname -> $key = '$value'"); } } } else { weechat::print("no nick"); } # python nicks = weechat.get_nick_info("freenode", "#weechat") if nicks != None: if nicks == {}: weechat.prnt("no nick") else: for n in nicks: for f in nicks[n]: weechat.prnt("%s -> %s = '%s'" % (n, f, str(nicks[n][f]))) else: weechat.prnt("error while getting nicks") # ruby nicks = Weechat.get_nick_info("freenode", "#weechat") if nicks != nil if nicks == {} Weechat.print("no nick") else nicks.each do |nk, nattr| nattr.each do |key, value| Weechat.print("#{nk} -> #{key} = '#{value}'") end end end else Weechat.print("error while getting nicks") end -- lua nicks = weechat.get_nick_info("freenode", "#weechat") if nicks ~= nil then if nicks then nick, nickinfos = next (nicks, nil) while (nick) do key, value = next (nickinfos, nil) while (key) do weechat.print(nick.." -> "..key.." = '"..value.."'") key, value = next (nickinfos, key) end nick, nickinfos = next (nicks, nick) end else weechat.print("no nick") end else weechat.print("error while getting nicks") end
get_config Perl prototype: weechat::get_config(option); Python prototype: weechat.get_config(option) Ruby prototype: Weechat.get_config(option) Lua prototype: weechat.get_config(option) Return value of a WeeChat config option. Arguments: : name of option to read Return value: option value, empty string if not found. Examples: # perl $value1 = weechat::get_config("look_nicklist"); $value2 = weechat::get_config("freenode.server_autojoin"); # python value1 = weechat.get_config("look_nicklist") value2 = weechat.get_config("freenode.server_autojoin") # ruby value1 = Weechat.get_config("look_nicklist") value2 = Weechat.get_config("freenode.server_autojoin") -- lua value1 = weechat.get_config("look_nicklist") value2 = weechat.get_config("freenode.server_autojoin")
set_config Perl prototype: weechat::set_config(option, value); Python prototype: weechat.set_config(option, value) Ruby prototype: Weechat.set_config(option, value) Lua prototype: weechat.set_config(option, value) Update value of a WeeChat config option. Arguments: : name of option to update : new value for option Return value: 1 if option was successfully updated, 0 if an error occurred. Examples: # perl weechat::set_config("look_nicklist", "off"); weechat::set_config("freenode.server_autojoin", "#weechat"); # python weechat.set_config("look_nicklist", "off") weechat.set_config("freenode.server_autojoin", "#weechat") # ruby Weechat.set_config("look_nicklist", "off") Weechat.set_config("freenode.server_autojoin", "#weechat") -- lua weechat.set_config("look_nicklist", "off") weechat.set_config("freenode.server_autojoin", "#weechat")
get_plugin_config Perl prototype: weechat::get_plugin_config(option); Python prototype: weechat.get_plugin_config(option) Ruby prototype: Weechat.get_plugin_config(option) Lua prototype: weechat.get_plugin_config(option) Return value of a plugin option. Option is read from file "~/.weechat/plugins.rc" and is like: "plugin.option=value" (note: plugin name is automatically added). Arguments: : name of option to read Return value: value of option, empty string if not found. Examples : # perl $value = weechat::get_plugin_config("my_var"); # python value = weechat.get_plugin_config("my_var") # ruby value = Weechat.get_plugin_config("my_var") -- lua value = weechat.get_plugin_config("my_var")
set_plugin_config Perl prototype: weechat::set_plugin_config(option, value); Python prototype: weechat.set_plugin_config(option, value) Ruby prototype: Weechat.set_plugin_config(option, value) Lua prototype: weechat.set_plugin_config(option, value) Update value of a plugin option. Option is written in file "~/.weechat/plugins.rc" and is like: "plugin.option=value" (note: plugin name is automatically added). Arguments: : name of option to update : new value for option Return value: 1 if option was successfully updated, 0 if an error occurred. Examples: # perl weechat::set_plugin_config("my_var", "value"); # python weechat.set_plugin_config("my_var", "value") # ruby Weechat.set_plugin_config("my_var", "value") -- lua weechat.set_plugin_config("my_var", "value")
get_irc_color Perl prototype: weechat::get_irc_color(color); Python prototype: weechat.get_irc_color(color) Ruby prototype: Weechat.get_irc_color(color) Lua prototype: weechat.get_irc_color(color) Return IRC color index with name. Return value: IRC color index, -1 if color is not found (see ). Examples: # perl my $color_blue = weechat::get_irc_color("blue"); # python color_blue = weechat.get_irc_color("blue") # ruby color_blue = Weechat.get_irc_color("blue") -- lua color_blue = weechat.get_irc_color("blue")
input_color Perl prototype: weechat::input_color(color); Python prototype: weechat.input_color(color) Ruby prototype: Weechat.input_color(color) Lua prototype: weechat.input_color(color) Add color in input buffer. Return value: none. Examples: # perl weechat::input_color(weechat::get_irc_color("blue"), 10, 5); # python weechat.input_color(weechat.get_irc_color("blue"), 10, 5) # ruby Weechat.input_color(Weechat.get_irc_color("blue"), 10, 5) -- lua weechat.input_color(weechat.get_irc_color("blue"), 10, 5)
get_window_info Perl prototype: weechat::get_window_info(); Python prototype: weechat.get_window_info() Ruby prototype: Weechat.get_window_info() Lua prototype: weechat.get_window_info() Return list of WeeChat windows. Return value: list of WeeChat windows (see ). Examples: # perl my @wf = weechat::get_window_info(); if (@wf) { weechat::print("**** windows infos ****"); foreach my $w (@wf) { while ( my ($key, $value) = each %$w) { weechat::print(" > $key => $value"); } weechat::print("----------------------"); } } else { weechat::print("**** no window info ****"); } # python wf = weechat.get_window_info() if wf != None and wf != []: weechat.prnt ("**** windows infos ****") for w in wf: for i in w: weechat.prnt (" > %s => %s" % (i, w[i])) weechat.prnt ("----------------------") else: weechat.prnt ("**** no window info ****") # ruby wf = Weechat.get_window_info() if wf != nil and wf != [] Weechat.print("**** windows infos ****") wf.each do |w| w.each do |key, value| Weechat.print(" > #{key} => #{value}") end Weechat.print("----------------------") end else Weechat.print("**** no window info ****") end -- lua wf = weechat.get_window_info() if wf then weechat.print ("**** windows infos ****") w, winfos = next (wf, nil) while (w) do key, value = next (winfos, nil) while (key) do weechat.print(" > " .. key .. " => " .. value) key, value = next (winfos, key) end weechat.print ("----------------------") w, winfos = next (wf, w) end else weechat.print("**** no window info ****") end
get_buffer_info Perl prototype: weechat::get_buffer_info(); Python prototype: weechat.get_buffer_info() Ruby prototype: Weechat.get_buffer_info() Lua prototype: weechat.get_buffer_info() Return list of WeeChat buffers. Return value: list of WeeChat buffers (see ). Examples: # perl my $bf = weechat::get_buffer_info(); if ($bf) { while ( my ($nobuf, $binfos) = each %$bf) { while ( my ($key, $value) = each %$binfos) { weechat::print(" > $key => $value"); } weechat::print("----------------------"); } } else { weechat::print("**** no buffer info ****"); } # python bf = weechat.get_buffer_info() if bf != None and bf != {}: for b in bf: weechat.prnt ("**** info for buffer no %d ****" % b) for c in bf[b]: weechat.prnt (" > %s => %s" % (c, bf[b][c])) weechat.prnt ("----------------------") else: weechat.prnt ("**** no buffer info ****") # ruby bf = Weechat.get_buffer_info() if bf != nil and bf != {} bf.each do |n, c| Weechat.print("**** info for buffer no #{n} ****") c.each do |key, value| Weechat.print(" > #{key} => #{value}") end Weechat.print("----------------------") end else Weechat.print("**** no buffer info ****") end -- lua bf = weechat.get_buffer_info() if bf then b, binfos = next (bf, nil) while (b) do weechat.print("**** info for buffer no " .. b .. " ****") key, value = next (binfos, nil) while (key) do weechat.print(" > " .. key .. " => " .. value) key, value = next (binfos, key) end weechat.print ("----------------------") b, infos = next (bf, b) end else weechat.print("**** no buffer info ****") end
get_buffer_data Perl prototype: weechat::get_buffer_data(server, channel); Python prototype: weechat.get_buffer_data(server, channel) Ruby prototype: Weechat.get_buffer_data(server, channel) Lua prototype: weechat.get_buffer_data(server, channel) Return content of buffer. Return value: list of lines for buffer (see ). Examples: # perl my $server = weechat::get_info("server"); my $channel = weechat::get_info("channel"); my @bc = weechat::get_buffer_data($server, $channel); if (@bc) { weechat::print("**** buffer data for '$channel'\@'$server' ****"); foreach my $l (@bc) { while ( my ($key, $value) = each %$l) { weechat::print(" > $key => $value"); } weechat::print("----------------------"); } } else { weechat::print("**** no buffer data ****"); } # python server = weechat.get_info("server") channel = weechat.get_info("channel") bc = weechat.get_buffer_data(server, channel) if bc != None and bc != []: weechat.prnt ("**** buffer data for '%s'@'%s' ****" % (channel, server)) for l in bc: for i in l: weechat.prnt (" > %s => %s" % (i, l[i])) weechat.prnt ("----------------------") else: weechat.prnt ("**** no buffer data ****") # ruby server = Weechat.get_info("server") channel = Weechat.get_info("channel") bc = Weechat.get_buffer_data(server, channel) if bc != nil and bc != [] Weechat.print("**** buffer data for '#{channel}'@'#{server}' ****") bc.each do |l| l.each do |key, value| Weechat.print(" > #{key} => #{value}") end Weechat.print("----------------------") end else Weechat.print("**** no buffer data ****") end -- lua server = weechat.get_info("server") channel = weechat.get_info("channel") bc = weechat.get_buffer_data(server, channel) if bc then b, bdatas = next (bc, nil) weechat.print("**** buffer data for '" .. channel .. "'@'" .. server .. "' ****") while (b) do key, value = next (bdatas, nil) while (key) do weechat.print(" > " .. key .. " => " .. value) key, value = next (bdatas, key) end weechat.print ("----------------------") b, bdatas = next (bc, b) end else weechat.print("**** no buffer data ****") end
Authors / Support This chapter lists authors and contributors for WeeChat, and shows ways to get support.
Authors WeeChat is developed by: FlashCode (Sébastien Helleu) flashcode AT flashtux.org - main developer kolter (Emmanuel Bouthenot) kolter AT openics.org - developer Ptitlouis ptitlouis AT sysif.net - Debian packager
Contributors Following people contributed to WeeChat: Jiri Golembiovsky - czech translation, patches Rudolf Polzer - patches Jim Ramsay - patches Odin - SuSE RPM Pistos - patches Gwenn - patches voroskoi - hungarian translation Frank Zacharias - german translation Pavel Shevchuk - russian translation
Get support Before asking for support, be sure you've read documentation and FAQ provided with WeeChat (documentation is this document, if you don't read all lines until this sentence, you can start again!) IRC: server "irc.freenode.net", channel "#weechat" WeeChat forum: http://forums.flashtux.org Mailing list: To subscribe: http://mail.nongnu.org/mailman/listinfo/weechat-support To send a mail on mailing list: weechat-support@nongnu.org Mailing list archives are available here: http://mail.nongnu.org/archive/html/weechat-support