summaryrefslogtreecommitdiff
path: root/doc/en/dev/plugin_scripts.en.xml
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-11-06 09:47:52 +0100
committerSebastien Helleu <flashcode@flashtux.org>2008-11-06 09:47:52 +0100
commit885df965e50855cc07db442ea920ff524b860d25 (patch)
tree08b8360420675f54db0d541ead44b0e4d3753df0 /doc/en/dev/plugin_scripts.en.xml
parent60d95151c52ac5d235be6bd87c3e7c454b33eb68 (diff)
downloadweechat-885df965e50855cc07db442ea920ff524b860d25.zip
Rename developer doc (-devel to -dev)
Diffstat (limited to 'doc/en/dev/plugin_scripts.en.xml')
-rw-r--r--doc/en/dev/plugin_scripts.en.xml2849
1 files changed, 2849 insertions, 0 deletions
diff --git a/doc/en/dev/plugin_scripts.en.xml b/doc/en/dev/plugin_scripts.en.xml
new file mode 100644
index 000000000..a4aa2ea7a
--- /dev/null
+++ b/doc/en/dev/plugin_scripts.en.xml
@@ -0,0 +1,2849 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+WeeChat documentation (english version)
+
+Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
+
+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 3 of the License, or
+(at your option) any later version.
+
+This manual 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, see <http://www.gnu.org/licenses/>.
+
+-->
+
+<section id="secScriptsPlugins">
+ <title>Scripts plugins</title>
+
+ <para>
+ Four plugins are provided with WeeChat to use script languages:
+ Perl, Python, Ruby and Lua.
+ </para>
+
+ <section id="secLoadUnloadScripts">
+ <title>Load / unload scripts</title>
+
+ <para>
+ Scripts are loaded and unloaded with <command>/perl</command>,
+ <command>/python</command>, <command>/ruby</command> and
+ <command>/lua</command> commands
+ (type <command>/help</command> in WeeChat for help about commands).
+ </para>
+
+ <para>
+ Examples:
+ <itemizedlist>
+ <listitem>
+ <para>
+ Load a Perl script:
+ <command><userinput>/perl load /tmp/test.pl</userinput></command>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ List all loaded Perl scripts:
+ <command><userinput>/perl</userinput></command>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Load a Python script:
+ <command><userinput>/python load /tmp/test.py</userinput></command>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ List all loaded Python scripts:
+ <command><userinput>/python</userinput></command>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Load a Ruby script:
+ <command><userinput>/ruby load /tmp/test.rb</userinput></command>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ List all loaded Ruby scripts:
+ <command><userinput>/ruby</userinput></command>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Load a Lua script:
+ <command><userinput>/lua load /tmp/test.lua</userinput></command>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ List all loaded Lua scripts:
+ <command><userinput>/lua</userinput></command>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+
+ </section>
+
+ <section id="secSyntaxByLanguage">
+ <title>Syntax by language</title>
+
+ <section id="secScriptPerl">
+ <title>Perl</title>
+
+ <para>
+ In a WeeChat Perl script, all API functions and variables are
+ prefixed by "<literal>weechat::</literal>".
+ Example:
+<screen>weechat::register("test", "1.0", "end_test", "WeeChat perl script");</screen>
+ </para>
+
+ </section>
+
+ <section id="secScriptPython">
+ <title>Python</title>
+
+ <para>
+ A WeeChat Python script has to start by importing weechat:
+ <screen>import weechat</screen>
+ </para>
+
+ <para>
+ All API functions and variables are prefixed by
+ "<literal>weechat.</literal>".
+ Example:
+<screen>weechat.register("test", "1.0", "end_test", "WeeChat python script")</screen>
+ </para>
+
+ </section>
+
+ <section id="secScriptRuby">
+ <title>Ruby</title>
+
+ <para>
+ In a WeeChat Ruby script, all code has to be in functions.
+ So for main code, you have to define a
+ "<literal>weechat_init</literal>" function, which is automatically
+ called when script is loaded by WeeChat. Example:
+<screen>
+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
+</screen>
+ </para>
+
+ <para>
+ All API functions are prefixed by
+ "<literal>Weechat.</literal>" and variables by
+ "<literal>Weechat::</literal>".
+ </para>
+
+ </section>
+
+ <section id="secScriptLua">
+ <title>Lua</title>
+
+ <para>
+ In a WeeChat Lua script, all API functions are prefixed by
+ "<literal>weechat.</literal>".
+ Variables are prefixed by "<literal>weechat.</literal>" and
+ suffixed by "<literal>()</literal>".
+ Example:
+<screen>
+function message_handler(server, args)
+ weechat.print("I am a message handler")
+ return weechat.PLUGIN_RC_OK()
+end
+</screen>
+ </para>
+
+ </section>
+
+ </section>
+
+ <section id="secWeeChatScriptsAPI">
+ <title>WeeChat / scripts API</title>
+
+ <section id="secScript_register">
+ <title>register</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::register(name, version, end_function, description,
+ [charset]);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.register(name, version, end_function, description,
+ [charset])
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.register(name, version, end_function, description,
+ [charset])
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.register(name, version, end_function, description,
+ [charset])
+ </command>
+ </para>
+ <para>
+ This is first function to call in script.
+ All WeeChat scripts have to call this function.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>name</option>: unique name to identify script
+ (each script must have unique name)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>version</option>: script version
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>end_function</option>: function called when script is
+ unloaded (optional parameter, empty string means nothing is
+ called at the end)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>description</option>: short description of script
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>charset</option>: charset used by script, you should
+ set this if script is not written with UTF-8
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if script was registered, 0 if an error occured.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_set_charset">
+ <title>set_charset</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::set_charset(charset);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.set_charset(charset)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.set_charset(charset)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.set_charset(charset)
+ </command>
+ </para>
+ <para>
+ Set new script charset.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>charset</option>: new script charset
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if new charset was set, 0 if an error occured.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_print">
+ <title>print</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::print(message, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.prnt(message, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.print(message, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.print(message, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Display a message on a WeeChat buffer, identified by server
+ and channel.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>message</option>: message
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>channel</option>: name of channel to find buffer
+ for message display
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>server</option>: internal name of server to find
+ buffer for message display
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ To display colored text, see <xref linkend="secAPI_print" />.
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# perl
+weechat::print("message");
+weechat::print("message", "#weechat");
+weechat::print("message", "#weechat", "freenode");
+weechat::print("test: \x0305 red \x0F normal");
+
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_print_server">
+ <title>print_server</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::print_server(message)
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.print_server(message)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.print_server(message)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.print_server(message)
+ </command>
+ </para>
+ <para>
+ Display a message on server buffer.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>message</option>: message
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ To display colored text, see <xref linkend="secAPI_print" />.
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# perl
+weechat::print_server("message");
+weechat::print_server("test: \x0305 red \x0F normal");
+
+# python
+weechat.print_server("message")
+
+# ruby
+Weechat.print_server("message")
+
+-- lua
+weechat.print_server("message")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_log">
+ <title>log</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::log(message, [channel, [server]]);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.log(message, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.log(message, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.log(message, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Write a message in log file for a server or a channel.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>message</option>: message
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>channel</option>: name of channel to find buffer
+ for log
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>server</option>: internal name of server to find
+ buffer for log
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# perl
+weechat::log("message", "#weechat", "freenode");
+
+# python
+weechat.log("message", "#weechat", "freenode")
+
+# ruby
+Weechat.log("message", "#weechat", "freenode")
+
+-- lua
+weechat.log("message", "#weechat", "freenode")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_add_message_handler">
+ <title>add_message_handler</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::add_message_handler(message, function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.add_message_handler(message, function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.add_message_handler(message, function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.add_message_handler(message, function)
+ </command>
+ </para>
+ <para>
+ Add an IRC message handler, called when an IRC message is
+ received.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>message</option>: name of IRC message. To know list
+ of IRC messages, please consult <acronym>RFC</acronym>s
+ <ulink url="http://www.ietf.org/rfc/rfc1459.txt">1459</ulink>
+ and
+ <ulink url="http://www.ietf.org/rfc/rfc2812.txt">2812</ulink>.
+ Moreover you can use a special name, prefixed by "weechat_"
+ to catch special events (see
+ <xref linkend="secAPI_msg_handler_add" />).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>function</option>: function called when message is
+ received
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ <para>
+ Note: function called when message is received has to return
+ one of following values:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_KO</literal>: function failed
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_OK</literal>: function successfully
+ completed
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_OK_IGNORE_WEECHAT</literal>: message
+ will not be sent to WeeChat
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_OK_IGNORE_PLUGINS</literal>: message
+ will not be sent to other plugins
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_OK_IGNORE_ALL</literal>: message
+ will not be sent to WeeChat neither other plugins
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_OK_WITH_HIGHLIGHT</literal>: function
+ successfully completed and make "highlight" on received
+ message
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <section id="secScript_add_command_handler">
+ <title>add_command_handler</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::add_command_handler(command, function,
+ [description, arguments, arguments_description,
+ completion_template]);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.add_command_handler(command, function,
+ [description, arguments, arguments_description,
+ completion_template])
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.add_command_handler(command, function,
+ [description, arguments, arguments_description,
+ completion_template])
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.add_command_handler(command, function,
+ [description, arguments, arguments_description,
+ completion_template])
+ </command>
+ </para>
+ <para>
+ Add a WeeChat command handler, called when user uses command
+ (for example /command).
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>command</option>: the new command name, which
+ may be an existing command (be careful, replaced command
+ will not be available until script is unloaded)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>function</option>: function called when command
+ is executed
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>arguments</option>: short description of command
+ arguments (displayed by /help command)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>arguments_description</option>: long description
+ of command arguments (displayed by /help command)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>completion_template</option>: template for
+ completion, like "<literal>abc|%w def|%i</literal>" which
+ means "abc" or a WeeChat command for first argument,
+ "def" or IRC command for second.
+ (see <xref linkend="secAPI_cmd_handler_add" />)
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ <para>
+ Notes: function called when command is executed has to return
+ one of following values:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_KO</literal> : function failed
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_OK</literal> : function successfully
+ completed
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <section id="secScript_add_timer_handler">
+ <title>add_timer_handler</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::add_timer_handler(interval, function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.add_timer_handler(interval, function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.add_timer_handler(interval, function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.add_timer_handler(interval, function)
+ </command>
+ </para>
+ <para>
+ Add a timer handler which periodically calls a function.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>interval</option>: interval (in seconds) between
+ two calls of function.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>function</option>: function called
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ <para>
+ Note: function called has to return one of following values:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_KO</literal>: function failed
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_OK</literal>: function successfully
+ completed
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <section id="secScript_add_keyboard_handler">
+ <title>add_keyboard_handler</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::add_keyboard_handler(function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.add_keyboard_handler(function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.add_keyboard_handler(function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.add_keyboard_handler(function)
+ </command>
+ </para>
+ <para>
+ Add a keyboard handler, called for any key pressed.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>function</option>: function called
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ <para>
+ Note: function called has to return one of following values:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_KO</literal>: function failed
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_OK</literal>: function successfully
+ completed
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <section id="secScript_add_event_handler">
+ <title>add_event_handler</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::add_event_handler(event, function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.add_event_handler(event, function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.add_event_handler(event, function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.add_event_handler(event, function)
+ </command>
+ </para>
+ <para>
+ Add an event handler, called when an event happens.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>event</option> : event
+ (see <xref linkend="secAPI_event_handler_add" />)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>function</option>: function called
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ <para>
+ Note: function called has to return one of following values:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_KO</literal>: function failed
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PLUGIN_RC_OK</literal>: function successfully
+ completed
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <section id="secScript_remove_handler">
+ <title>remove_handler</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::remove_handler(name, function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.remove_handler(name, function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.remove_handler(name, function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.remove_handler(name, function)
+ </command>
+ </para>
+ <para>
+ Remove a message or command handler.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>name</option>: name of IRC message or command
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>function</option>: function
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_remove_timer_handler">
+ <title>remove_timer_handler</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::remove_timer_handler(function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.remove_timer_handler(function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.remove_timer_handler(function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.remove_timer_handler(function)
+ </command>
+ </para>
+ <para>
+ Remove a timer handler.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>function</option>: function
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScrip_remove_keyboard_handler">
+ <title>remove_keyboard_handler</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::remove_keyboard_handler(function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.remove_keyboard_handler(function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.remove_keyboard_handler(function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.remove_keyboard_handler(function)
+ </command>
+ </para>
+ <para>
+ Remove a keyboard handler.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>function</option>: function
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScrip_remove_event_handler">
+ <title>remove_event_handler</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::remove_event_handler(function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.remove_event_handler(function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.remove_event_handler(function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.remove_event_handler(function)
+ </command>
+ </para>
+ <para>
+ Remove an event handler.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>function</option>: function
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_add_modifier">
+ <title>add_modifier</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::add_modifier(type, message, function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.add_modifier(type, message, function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.add_modifier(type, message, function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.add_modifier(type, message, function)
+ </command>
+ </para>
+ <para>
+ Add a message modifier.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>type</option>: modifier type:
+ <informaltable colsep="0" frame="none">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>irc_in</literal></entry>
+ <entry>called for incoming IRC messages</entry>
+ </row>
+ <row>
+ <entry><literal>irc_user</literal></entry>
+ <entry>
+ called for each user message (or command) (before
+ WeeChat parses message)
+ </entry>
+ </row>
+ <row>
+ <entry><literal>irc_out</literal></entry>
+ <entry>
+ called for outgoing messages, immediately before
+ sending it to IRC server (this includes messages
+ sent automatically by WeeChat to server)
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>message</option>: name of IRC message (used only for
+ types "irc_in" and "irc_out").
+ To know list of IRC messages, please consult
+ <acronym>RFC</acronym>s
+ <ulink url="http://www.ietf.org/rfc/rfc1459.txt">1459</ulink>
+ and
+ <ulink url="http://www.ietf.org/rfc/rfc2812.txt">2812</ulink>.
+ Moreover, special value "*" means all messages (no filter).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>function</option>: function called
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_remove_modifier">
+ <title>remove_modifier</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::remove_modifier(type, message, function);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.remove_modifier(type, message, function)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.remove_modifier(type, message, function)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.remove_modifier(type, message, function)
+ </command>
+ </para>
+ <para>
+ Remove a message modifier.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>type</option>: modifier type
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>message</option>: message managed by modifier
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>function</option>: function
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_command">
+ <title>command</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::command(command, [channel, [server]]);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.command(command, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.command(command, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.command(command, [channel, [server]])
+ </command>
+ </para>
+ <para>
+ Execute a WeeChat command (or send a message to a channel).
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>command</option>: command
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>channel</option>: name of channel for executing
+ command
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>server</option>: internal name of server for
+ executing command
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if success, 0 if an error occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_info">
+ <title>get_info</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_info(name, [server]);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_info(name, [server])
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_info(name, [server])
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_info(name, [server])
+ </command>
+ </para>
+ <para>
+ Return an info about WeeChat or a channel.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>name</option>: name of info to read
+ (see <xref linkend="secAPI_get_info" />)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>server</option>: internal name of server for
+ reading info (if needed)
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: information asked, empty string if an error
+ occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_dcc_info">
+ <title>get_dcc_info</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_dcc_info();
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_dcc_info()
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_dcc_info()
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_dcc_info()
+ </command>
+ </para>
+ <para>
+ Return list of DCC currently active or finished.
+ </para>
+ <para>
+ Return value: list of DCC
+ (see <xref linkend="secAPI_get_dcc_info" />).
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_server_info">
+ <title>get_server_info</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_server_info();
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_server_info()
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_server_info()
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_server_info()
+ </command>
+ </para>
+ <para>
+ Return list of IRC servers (connected or not).
+ </para>
+ <para>
+ Return value: list of servers
+ (see <xref linkend="secAPI_get_server_info" />).
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_channel_info">
+ <title>get_channel_info</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_channel_info(server);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_channel_info(server)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_channel_info(server)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_channel_info(server)
+ </command>
+ </para>
+ <para>
+ Return list of IRC channels for a server.
+ </para>
+ <para>
+ Return value: list of IRC channels for server
+ (see <xref linkend="secAPI_get_channel_info" />).
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_nick_info">
+ <title>get_nick_info</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_nick_info(server, channel);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_nick_info(server, channel)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_nick_info(server, channel)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_nick_info(server, channel)
+ </command>
+ </para>
+ <para>
+ Return list of nicks for a channel.
+ </para>
+ <para>
+ Return value: list of nicks on channel
+ (see <xref linkend="secAPI_get_nick_info" />).
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_config">
+ <title>get_config</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_config(option);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_config(option)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_config(option)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_config(option)
+ </command>
+ </para>
+ <para>
+ Return value of a WeeChat config option.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>option</option>: name of option to read
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: option value, empty string if not found.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_set_config">
+ <title>set_config</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::set_config(option, value);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.set_config(option, value)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.set_config(option, value)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.set_config(option, value)
+ </command>
+ </para>
+ <para>
+ Update value of a WeeChat config option.
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>option</option>: name of option to update
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>value</option>: new value for option
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if option was successfully updated, 0 if an error
+ occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_plugin_config">
+ <title>get_plugin_config</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_plugin_config(option);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_plugin_config(option)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_plugin_config(option)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_plugin_config(option)
+ </command>
+ </para>
+ <para>
+ Return value of a plugin option. Option is read from file
+ "<literal>~/.weechat/plugins.rc</literal>" and is like:
+ "<literal>plugin.option=value</literal>" (note: plugin name
+ is automatically added).
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>option</option>: name of option to read
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: value of option, empty string if not found.
+ </para>
+ <para>
+ Examples :
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_set_plugin_config">
+ <title>set_plugin_config</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::set_plugin_config(option, value);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.set_plugin_config(option, value)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.set_plugin_config(option, value)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.set_plugin_config(option, value)
+ </command>
+ </para>
+ <para>
+ Update value of a plugin option. Option is written in file
+ "<literal>~/.weechat/plugins.rc</literal>" and is like:
+ "<literal>plugin.option=value</literal>" (note: plugin name
+ is automatically added).
+ </para>
+ <para>
+ Arguments:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <option>option</option>: name of option to update
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <option>value</option>: new value for option
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Return value: 1 if option was successfully updated, 0 if an error
+ occurred.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_irc_color">
+ <title>get_irc_color</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_irc_color(color);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_irc_color(color)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_irc_color(color)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_irc_color(color)
+ </command>
+ </para>
+ <para>
+ Return IRC color index with name.
+ </para>
+ <para>
+ Return value: IRC color index, -1 if color is not found
+ (see <xref linkend="secAPI_get_irc_color" />).
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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")
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_input_color">
+ <title>input_color</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::input_color(color);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.input_color(color)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.input_color(color)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.input_color(color)
+ </command>
+ </para>
+ <para>
+ Add color in input buffer.
+ </para>
+ <para>
+ Return value: none.
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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)
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_window_info">
+ <title>get_window_info</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_window_info();
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_window_info()
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_window_info()
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_window_info()
+ </command>
+ </para>
+ <para>
+ Return list of WeeChat windows.
+ </para>
+ <para>
+ Return value: list of WeeChat windows
+ (see <xref linkend="secAPI_get_window_info" />).
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_buffer_info">
+ <title>get_buffer_info</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_buffer_info();
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_buffer_info()
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_buffer_info()
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_buffer_info()
+ </command>
+ </para>
+ <para>
+ Return list of WeeChat buffers.
+ </para>
+ <para>
+ Return value: list of WeeChat buffers
+ (see <xref linkend="secAPI_get_buffer_info" />).
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ </section>
+
+ <section id="secScript_get_buffer_data">
+ <title>get_buffer_data</title>
+
+ <para>
+ Perl prototype:
+ <command>
+ weechat::get_buffer_data(server, channel);
+ </command>
+ </para>
+ <para>
+ Python prototype:
+ <command>
+ weechat.get_buffer_data(server, channel)
+ </command>
+ </para>
+ <para>
+ Ruby prototype:
+ <command>
+ Weechat.get_buffer_data(server, channel)
+ </command>
+ </para>
+ <para>
+ Lua prototype:
+ <command>
+ weechat.get_buffer_data(server, channel)
+ </command>
+ </para>
+ <para>
+ Return content of buffer.
+ </para>
+ <para>
+ Return value: list of lines for buffer
+ (see <xref linkend="secAPI_get_buffer_data" />).
+ </para>
+ <para>
+ Examples:
+<screen>
+# 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
+</screen>
+ </para>
+ </section>
+
+ </section>
+
+</section>