diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2006-02-09 20:47:16 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2006-02-09 20:47:16 +0000 |
commit | 4c34ac5d8f775782b89adaf796102eec7686c72c (patch) | |
tree | 54b9a58450203113ca0289684fb53345c0f136fd | |
parent | 73990d8caab268c7611979315d9fb77958eace3c (diff) | |
download | weechat-4c34ac5d8f775782b89adaf796102eec7686c72c.zip |
Added Lua script plugin
-rw-r--r-- | doc/en/weechat.en.xml | 336 | ||||
-rw-r--r-- | doc/fr/weechat.fr.xml | 340 | ||||
-rw-r--r-- | weechat/doc/en/weechat.en.xml | 336 | ||||
-rw-r--r-- | weechat/doc/fr/weechat.fr.xml | 340 |
4 files changed, 1308 insertions, 44 deletions
diff --git a/doc/en/weechat.en.xml b/doc/en/weechat.en.xml index c40f97151..65988b542 100644 --- a/doc/en/weechat.en.xml +++ b/doc/en/weechat.en.xml @@ -1151,7 +1151,7 @@ fi <para> This chapter describes WeeChat plugins interface (API) and - the default scripts plugins (Perl, Python, Ruby), provided with + the default scripts plugins (Perl, Python, Ruby, Lua), provided with WeeChat. </para> @@ -3203,8 +3203,8 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <title>Scripts plugins</title> <para> - Three plugins are provided with WeeChat to use script languages: - Perl, Python and Ruby. + Four plugins are provided with WeeChat to use script languages: + Perl, Python, Ruby and Lua. </para> <section id="secLoadUnloadScripts"> @@ -3212,7 +3212,8 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <para> Scripts are loaded and unloaded with <command>/perl</command>, - <command>/python</command> and <command>/ruby</command> commands + <command>/python</command>, <command>/ruby</command> and + <command>/lua</command> commands (type <command>/help</command> in WeeChat for help about commands). </para> @@ -3255,6 +3256,18 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <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> @@ -3285,6 +3298,12 @@ void weechat_plugin_end (t_weechat_plugin *plugin) </command> </para> <para> + Lua prototype: + <command> + weechat.register ( name, version, end_function, description ) + </command> + </para> + <para> This is first function to call in script. All WeeChat scripts have to call this function. </para> @@ -3330,6 +3349,9 @@ weechat.register ("test", "1.0", "end_test", "Test script!") # ruby Weechat.register ("test", "1.0", "end_test", "Test script!") + +-- lua +weechat.register ("test", "1.0", "end_test", "Test script!") </screen> </para> </section> @@ -3356,6 +3378,12 @@ Weechat.register ("test", "1.0", "end_test", "Test script!") </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> @@ -3401,6 +3429,11 @@ weechat.prnt ("message", "#weechat", "freenode") 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> @@ -3427,6 +3460,12 @@ Weechat.print ("message", "#weechat", "freenode") </command> </para> <para> + Lua prototype: + <command> + weechat.print_infobar ( time, message ) + </command> + </para> + <para> Display a message in infobar for a specified time. </para> <para> @@ -3459,6 +3498,9 @@ weechat.print_infobar (5, "message") # ruby Weechat.print_infobar (5, "message") + +-- lua +weechat.print_infobar (5, "message") </screen> </para> </section> @@ -3485,6 +3527,12 @@ Weechat.print_infobar (5, "message") </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> @@ -3526,12 +3574,26 @@ sub my_function # python weechat.add_message_handler ("privmsg", my_function) -def ma_fonction(server, args): +def my_function(server, args): weechat.prnt("server="+server) null, channel, message = string.split(args, ":", 2) masque, null, channel = string.split(string.strip(channel), " ", 2) weechat.prnt("mask="+mask+", canal="+channel+", message="+message) return weechat.PLUGIN_RC_OK + +# ruby +def my_function(server, args) + Weechat.print("server=#{server}, args=#{args}") + return Weechat::PLUGIN_RC_OK +end +Weechat.add_message_handler ("privmsg", "my_function") + +-- 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> @@ -3600,6 +3662,14 @@ def ma_fonction(server, args): </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> @@ -3652,15 +3722,29 @@ def ma_fonction(server, args): weechat::add_command_handler ("command", my_command); sub my_command { - weechat::print("Server: $_[0], arguments: $_[1]\n"); + weechat::print("server= $_[0], args: $_[1]\n"); return weechat::PLUGIN_RC_OK; } # python weechat.add_command_handler ("command", my_command) def my_command(server, args): - weechat.prnt("server:"+server+" arguments:"+args) + weechat.prnt("server="+server+", args="+args) return weechat.PLUGIN_RC_OK + +# ruby +def my_command(server, args) + Weechat.print("server=#{server}, args=#{args}") + return Weechat::PLUGIN_RC_OK +end +Weechat.add_command_handler ("command", "my_command") + +-- 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> @@ -3705,6 +3789,12 @@ def my_command(server, args): </command> </para> <para> + Lua prototype: + <command> + weechat.remove_handler ( name, function ) + </command> + </para> + <para> Remove a handler. </para> <para> @@ -3736,6 +3826,9 @@ weechat.remove_handler ("command", my_command) # ruby Weechat.remove_handler ("command", my_command) + +-- lua +weechat.remove_handler ("command", "my_command") </screen> </para> </section> @@ -3762,6 +3855,12 @@ Weechat.remove_handler ("command", my_command) </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> @@ -3806,6 +3905,11 @@ weechat.command ("/nick newnick", "", "freenode") 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> @@ -3832,6 +3936,12 @@ Weechat.command ("/nick newnick", "", "freenode") </command> </para> <para> + Lua prototype: + <command> + weechat.get_info ( name, [server] ) + </command> + </para> + <para> Return an info about WeeChat or a channel. </para> <para> @@ -3865,6 +3975,14 @@ $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> @@ -3891,12 +4009,87 @@ nick = weechat.get_info ("nick", "freenode") </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> @@ -3921,6 +4114,12 @@ nick = weechat.get_info ("nick", "freenode") </command> </para> <para> + Lua prototype: + <command> + weechat.get_server_info ( ) + </command> + </para> + <para> Return list of IRC servers (connected or not). </para> <para> @@ -3974,6 +4173,26 @@ if servers != nil 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(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> @@ -4000,6 +4219,12 @@ end </command> </para> <para> + Lua prototype: + <command> + weechat.get_channel_info ( server ) + </command> + </para> + <para> Return list of IRC channels for a server. </para> <para> @@ -4010,7 +4235,7 @@ end Examples: <screen> # perl -my $channels = weechat::get_channel_info(weechat::get_info('server')); +my $channels = weechat::get_channel_info(weechat::get_info("server")); if ($channels) { while (my ($channame, $chaninfos) = each %$channels) @@ -4027,7 +4252,7 @@ else } # python -chans = weechat.get_channel_info(weechat.get_info('server')) +chans = weechat.get_channel_info(weechat.get_info("server")) if chans != None: if chans == {}: weechat.prnt("no channel") @@ -4039,7 +4264,7 @@ else: weechat.prnt("error while getting channels") # ruby -channels = Weechat.get_channel_info(Weechat.get_info('server')) +channels = Weechat.get_channel_info(Weechat.get_info("server")) if channels != nil if channels == {} Weechat.print("no channel") @@ -4053,6 +4278,26 @@ if channels != nil 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(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> @@ -4079,6 +4324,12 @@ end </command> </para> <para> + Lua prototype: + <command> + weechat.get_nick_info ( server, channel ) + </command> + </para> + <para> Return list of nicks for a channel. </para> <para> @@ -4132,6 +4383,26 @@ if nicks != nil 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> @@ -4158,6 +4429,12 @@ end </command> </para> <para> + Lua prototype: + <command> + weechat.get_config ( option ) + </command> + </para> + <para> Return value of a WeeChat config option. </para> <para> @@ -4183,6 +4460,14 @@ $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> @@ -4209,6 +4494,12 @@ value2 = weechat.get_config ("freenode.server_autojoin") </command> </para> <para> + Lua prototype: + <command> + weechat.set_config ( option, value ) + </command> + </para> + <para> Update value of a WeeChat config option. </para> <para> @@ -4244,6 +4535,10 @@ 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> @@ -4270,6 +4565,12 @@ Weechat.set_config ("freenode.server_autojoin, "#weechat") </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 @@ -4296,6 +4597,12 @@ $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> @@ -4322,6 +4629,12 @@ value = weechat.get_plugin_config ("my_var") </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 @@ -4357,6 +4670,9 @@ 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> diff --git a/doc/fr/weechat.fr.xml b/doc/fr/weechat.fr.xml index 2d802c518..77a8e6b17 100644 --- a/doc/fr/weechat.fr.xml +++ b/doc/fr/weechat.fr.xml @@ -1168,7 +1168,7 @@ fi <para> Ce chapitre décrit l'interface des extensions (API) et les extensions - pour scripts (Perl, Python, Ruby), fournies avec WeeChat. + pour scripts (Perl, Python, Ruby, Lua), fournies avec WeeChat. </para> <section id="secLesExtensionsDansWeeChat"> @@ -3267,7 +3267,7 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <para> Trois extensions sont fournies en standard avec WeeChat pour utiliser - des langages de script : Perl, Python et Ruby. + des langages de script : Perl, Python, Ruby et Lua. </para> <section id="secChargerDechargerScripts"> @@ -3275,9 +3275,10 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <para> Les scripts sont chargés et déchargés avec les commandes - <command>/perl</command>, <command>/python</command> et - <command>/ruby</command> (tapez <command>/help</command> dans - WeeChat pour obtenir de l'aide sur les commandes). + <command>/perl</command>, <command>/python</command>, + <command>/ruby</command> et <command>/lua</command> + (tapez <command>/help</command> dans WeeChat pour obtenir + de l'aide sur les commandes). </para> <para> @@ -3319,6 +3320,18 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <command><userinput>/ruby</userinput></command> </para> </listitem> + <listitem> + <para> + Charger un script Lua : + <command><userinput>/lua load /tmp/essai.lua</userinput></command> + </para> + </listitem> + <listitem> + <para> + Lister les scripts Lua chargés : + <command><userinput>/lua</userinput></command> + </para> + </listitem> </itemizedlist> </para> @@ -3349,6 +3362,12 @@ void weechat_plugin_end (t_weechat_plugin *plugin) </command> </para> <para> + Prototype Lua : + <command> + weechat.register ( nom, version, fonction_de_fin, description ) + </command> + </para> + <para> C'est la première fonction à appeler dans le script. Tout script pour WeeChat doit appeler cette fonction. </para> @@ -3395,6 +3414,9 @@ weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !") # ruby Weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !") + +-- lua +weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !") </screen> </para> </section> @@ -3421,6 +3443,12 @@ Weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !") </command> </para> <para> + Prototype Lua : + <command> + weechat.print ( message, [canal, [serveur]] ) + </command> + </para> + <para> Affiche un message sur un tampon WeeChat, identifié par le serveur et le canal. </para> @@ -3466,6 +3494,11 @@ weechat.prnt ("message", "#weechat", "freenode") 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> @@ -3492,6 +3525,12 @@ Weechat.print ("message", "#weechat", "freenode") </command> </para> <para> + Prototype Lua : + <command> + weechat.print_infobar ( temps, message ) + </command> + </para> + <para> Affiche un message sur la barre d'infos pour un temps déterminé. </para> <para> @@ -3524,6 +3563,9 @@ weechat.print_infobar (5, "message") # ruby Weechat.print_infobar (5, "message") + +-- lua +weechat.print_infobar (5, "message") </screen> </para> </section> @@ -3550,6 +3592,12 @@ Weechat.print_infobar (5, "message") </command> </para> <para> + Prototype Lua : + <command> + weechat.add_message_handler ( message, fonction ) + </command> + </para> + <para> Ajoute un gestionnaire de messages IRC, appelé dès qu'un message IRC est reçu. </para> @@ -3599,6 +3647,20 @@ def ma_fonction(serveur, args): masque, null, canal = string.split(string.strip(canal), " ", 2) weechat.prnt("masque="+masque+", canal="+canal+", message="+message) return weechat.PLUGIN_RC_OK + +# ruby +def ma_fonction(server, args) + Weechat.print("serveur=#{server}, args=#{args}") + return Weechat::PLUGIN_RC_OK +end +Weechat.add_message_handler ("privmsg", "ma_fonction") + +-- lua +weechat.add_message_handler ("privmsg", "ma_fonction") +function ma_fonction(server, args) + weechat.print("serveur=" .. server .. ", args=" .. args) + return weechat.PLUGIN_RC_OK() +end </screen> </para> <para> @@ -3666,6 +3728,14 @@ def ma_fonction(serveur, args): </command> </para> <para> + Prototype Lua : + <command> + weechat.add_command_handler ( commande, fonction, + [description, arguments, arguments_description, + modele_completion] ) + </command> + </para> + <para> Ajoute un gestionnaire de commande WeeChat, appelé dès que l'utilisateur utilise la commande (par exemple /commande). </para> @@ -3719,15 +3789,29 @@ def ma_fonction(serveur, args): weechat::add_command_handler ("commande", ma_commande); sub ma_commande { - weechat::print("Serveur: $_[0], paramètres: $_[1]\n"); + weechat::print("serveur=$_[0], args=$_[1]\n"); return weechat::PLUGIN_RC_OK; } # python weechat.add_command_handler ("commande", ma_commande) def ma_commande(serveur, args): - weechat.prnt("serveur:"+serveur+" paramètres:"+args) + weechat.prnt("serveur="+serveur+", args="+args) return weechat.PLUGIN_RC_OK + +# ruby +def ma_commande(server, args) + Weechat.print("serveur=#{server} args=#{args}") + return Weechat::PLUGIN_RC_OK +end +Weechat.add_command_handler ("command", "ma_commande") + +-- lua +weechat.add_command_handler ("command", "ma_commande") +def my_command(server, args) + weechat.print("serveur="..server..", args="..args) + return weechat.PLUGIN_RC_OK() +end </screen> </para> <para> @@ -3771,6 +3855,12 @@ def ma_commande(serveur, args): </command> </para> <para> + Prototype Lua : + <command> + weechat.remove_handler ( nom, fonction ) + </command> + </para> + <para> Supprime un gestionnaire. </para> <para> @@ -3802,6 +3892,9 @@ weechat.remove_handler ("commande", ma_commande) # ruby Weechat.remove_handler ("commande", ma_commande) + +-- lua +weechat.remove_handler ("commande", "ma_commande") </screen> </para> </section> @@ -3828,6 +3921,12 @@ Weechat.remove_handler ("commande", ma_commande) </command> </para> <para> + Prototype Lua : + <command> + weechat.command ( commande, [canal, [serveur]] ) + </command> + </para> + <para> Exécute une commande ou envoie un message à un canal. </para> <para> @@ -3872,6 +3971,11 @@ weechat.command ("/nick newnick", "", "freenode") Weechat.command ("bonjour tout le monde !") Weechat.command ("/kick toto merci de quitter ce canal", "#weechat") Weechat.command ("/nick newnick", "", "freenode") + +-- lua +weechat.command ("bonjour tout le monde !") +weechat.command ("/kick toto merci de quitter ce canal", "#weechat") +weechat.command ("/nick newnick", "", "freenode") </screen> </para> </section> @@ -3898,6 +4002,12 @@ Weechat.command ("/nick newnick", "", "freenode") </command> </para> <para> + Prototype Lua : + <command> + weechat.get_info ( nom, [serveur] ) + </command> + </para> + <para> Renvoie une information sur WeeChat ou un canal. </para> <para> @@ -3931,6 +4041,14 @@ $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> @@ -3957,12 +4075,87 @@ nick = weechat.get_info ("nick", "freenode") </command> </para> <para> + Prototype Lua : + <command> + weechat.get_dcc_info ( ) + </command> + </para> + <para> Renvoie la liste des DCC en cours ou terminés. </para> <para> Valeur renvoyée : la liste des DCC (voir <xref linkend="secAPI_get_dcc_info" />). </para> + <para> + Exemples : +<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("pas de DCC"); +} + +# python +dccs = weechat.get_dcc_info() +if dccs != None: + if dccs == []: + weechat.prnt("pas de DCC") + else: + for d in dccs: + for b in d.keys(): + weechat.prnt("%s = '%s'" %(b, d[b])) +else: + weechat.prnt("erreur de lecture des DCC") + +# ruby +dccs = Weechat.get_dcc_info() +if dccs != nil + if dccs == [] + Weechat.print("pas de DCC") + else + dccs.each do |m| + m.each do |key, value| + Weechat.print("#{key} = '#{value}'") + end + end + end +else + Weechat.print("erreur de lecture des 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("pas de DCC") + end +else + weechat.print("erreur de lecture des DCC") +end +</screen> + </para> </section> <section> @@ -3987,6 +4180,12 @@ nick = weechat.get_info ("nick", "freenode") </command> </para> <para> + Prototype Lua : + <command> + weechat.get_server_info ( ) + </command> + </para> + <para> Renvoie la liste des serveurs IRC (connectés ou non). </para> <para> @@ -4002,7 +4201,7 @@ if ($servers) { while (my ($srvname, $srvinfos) = each %$servers) { - while ( my ($key, $value) = each %$srvinfos) + while (my ($key, $value) = each %$srvinfos) { weechat::print("$srvname[$key] = '$value'"); } @@ -4040,6 +4239,26 @@ if servers != nil else Weechat.print("erreur de lecture des serveurs") 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(key.." = '"..value.."'") + key, value = next (srvinfos, key) + end + srv, srvinfos = next (servers, srv) + end + else + weechat.print("pas de serveur") + end +else + weechat.print("erreur de lecture des serveurs") +end </screen> </para> </section> @@ -4066,6 +4285,12 @@ end </command> </para> <para> + Prototype Lua : + <command> + weechat.get_channel_info ( serveur ) + </command> + </para> + <para> Renvoie la liste des canaux IRC pour un serveur. </para> <para> @@ -4076,7 +4301,7 @@ end Exemples : <screen> # perl -my $channels = weechat::get_channel_info(weechat::get_info('server')); +my $channels = weechat::get_channel_info(weechat::get_info("server")); if ($channels) { while (my ($channame, $chaninfos) = each %$channels) @@ -4093,7 +4318,7 @@ else } # python -chans = weechat.get_channel_info(weechat.get_info('server')) +chans = weechat.get_channel_info(weechat.get_info("server")) if chans != None: if chans == {}: weechat.prnt("pas de canal") @@ -4105,7 +4330,7 @@ else: weechat.prnt("erreur de lecture des canaux") # ruby -channels = Weechat.get_channel_info(Weechat.get_info('server')) +channels = Weechat.get_channel_info(Weechat.get_info("server")) if channels != nil if channels == {} Weechat.print("pas de canal") @@ -4119,6 +4344,26 @@ if channels != nil else Weechat.print("erreur de lecture des canaux") 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(key.." = '"..value.."'") + key, value = next (chaninfos, key) + end + chan, chaninfos = next (chans, chan) + end + else + weechat.print("pas de canal") + end +else + weechat.print("erreur de lecture des canaux") +end </screen> </para> </section> @@ -4129,7 +4374,7 @@ end <para> Prototype Perl : <command> - weechat::get_nick_info ( server, canal ); + weechat::get_nick_info ( serveur, canal ); </command> </para> <para> @@ -4145,6 +4390,12 @@ end </command> </para> <para> + Prototype Lua : + <command> + weechat.get_nick_info ( serveur, canal ) + </command> + </para> + <para> Renvoie la liste des pseudos pour un canal. </para> <para> @@ -4198,6 +4449,26 @@ if nicks != nil else Weechat.print("erreur de lecture des pseudos") 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("pas de pseudo") + end +else + weechat.print("erreur de lecture des pseudos") +end </screen> </para> </section> @@ -4224,6 +4495,12 @@ end </command> </para> <para> + Prototype Lua : + <command> + weechat.get_config ( option ) + </command> + </para> + <para> Renvoie la valeur d'une option de configuration WeeChat. </para> <para> @@ -4250,6 +4527,14 @@ $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> @@ -4276,6 +4561,12 @@ value2 = weechat.get_config ("freenode.server_autojoin") </command> </para> <para> + Prototype Lua : + <command> + weechat.set_config ( option, valeur ) + </command> + </para> + <para> Modifie la valeur d'une option de configuration WeeChat. </para> <para> @@ -4312,6 +4603,10 @@ 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> @@ -4338,6 +4633,12 @@ Weechat.set_config ("freenode.server_autojoin, "#weechat") </command> </para> <para> + Prototype Lua : + <command> + weechat.get_plugin_config ( option ) + </command> + </para> + <para> Renvoie la valeur d'une option de l'extension. L'option est lue depuis le fichier "<literal>~/.weechat/plugins.rc</literal>" et est @@ -4368,6 +4669,12 @@ $value = weechat::get_plugin_config ("ma_variable"); # python value = weechat.get_plugin_config ("ma_variable") + +# ruby +value = Weechat.get_plugin_config ("ma_variable") + +-- lua +value = weechat.get_plugin_config ("ma_variable") </screen> </para> </section> @@ -4394,6 +4701,12 @@ value = weechat.get_plugin_config ("ma_variable") </command> </para> <para> + Prototype Lua : + <command> + weechat.set_plugin_config ( option, valeur ) + </command> + </para> + <para> Modifie la valeur d'une option de l'extension. L'option est écrite dans le fichier "<literal>~/.weechat/plugins.rc</literal>" et est @@ -4433,6 +4746,9 @@ weechat.set_plugin_config ("ma_variable", "valeur") # ruby Weechat.set_plugin_config ("ma_variable", "valeur") + +-- lua +weechat.set_plugin_config ("ma_variable", "valeur") </screen> </para> </section> diff --git a/weechat/doc/en/weechat.en.xml b/weechat/doc/en/weechat.en.xml index c40f97151..65988b542 100644 --- a/weechat/doc/en/weechat.en.xml +++ b/weechat/doc/en/weechat.en.xml @@ -1151,7 +1151,7 @@ fi <para> This chapter describes WeeChat plugins interface (API) and - the default scripts plugins (Perl, Python, Ruby), provided with + the default scripts plugins (Perl, Python, Ruby, Lua), provided with WeeChat. </para> @@ -3203,8 +3203,8 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <title>Scripts plugins</title> <para> - Three plugins are provided with WeeChat to use script languages: - Perl, Python and Ruby. + Four plugins are provided with WeeChat to use script languages: + Perl, Python, Ruby and Lua. </para> <section id="secLoadUnloadScripts"> @@ -3212,7 +3212,8 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <para> Scripts are loaded and unloaded with <command>/perl</command>, - <command>/python</command> and <command>/ruby</command> commands + <command>/python</command>, <command>/ruby</command> and + <command>/lua</command> commands (type <command>/help</command> in WeeChat for help about commands). </para> @@ -3255,6 +3256,18 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <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> @@ -3285,6 +3298,12 @@ void weechat_plugin_end (t_weechat_plugin *plugin) </command> </para> <para> + Lua prototype: + <command> + weechat.register ( name, version, end_function, description ) + </command> + </para> + <para> This is first function to call in script. All WeeChat scripts have to call this function. </para> @@ -3330,6 +3349,9 @@ weechat.register ("test", "1.0", "end_test", "Test script!") # ruby Weechat.register ("test", "1.0", "end_test", "Test script!") + +-- lua +weechat.register ("test", "1.0", "end_test", "Test script!") </screen> </para> </section> @@ -3356,6 +3378,12 @@ Weechat.register ("test", "1.0", "end_test", "Test script!") </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> @@ -3401,6 +3429,11 @@ weechat.prnt ("message", "#weechat", "freenode") 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> @@ -3427,6 +3460,12 @@ Weechat.print ("message", "#weechat", "freenode") </command> </para> <para> + Lua prototype: + <command> + weechat.print_infobar ( time, message ) + </command> + </para> + <para> Display a message in infobar for a specified time. </para> <para> @@ -3459,6 +3498,9 @@ weechat.print_infobar (5, "message") # ruby Weechat.print_infobar (5, "message") + +-- lua +weechat.print_infobar (5, "message") </screen> </para> </section> @@ -3485,6 +3527,12 @@ Weechat.print_infobar (5, "message") </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> @@ -3526,12 +3574,26 @@ sub my_function # python weechat.add_message_handler ("privmsg", my_function) -def ma_fonction(server, args): +def my_function(server, args): weechat.prnt("server="+server) null, channel, message = string.split(args, ":", 2) masque, null, channel = string.split(string.strip(channel), " ", 2) weechat.prnt("mask="+mask+", canal="+channel+", message="+message) return weechat.PLUGIN_RC_OK + +# ruby +def my_function(server, args) + Weechat.print("server=#{server}, args=#{args}") + return Weechat::PLUGIN_RC_OK +end +Weechat.add_message_handler ("privmsg", "my_function") + +-- 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> @@ -3600,6 +3662,14 @@ def ma_fonction(server, args): </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> @@ -3652,15 +3722,29 @@ def ma_fonction(server, args): weechat::add_command_handler ("command", my_command); sub my_command { - weechat::print("Server: $_[0], arguments: $_[1]\n"); + weechat::print("server= $_[0], args: $_[1]\n"); return weechat::PLUGIN_RC_OK; } # python weechat.add_command_handler ("command", my_command) def my_command(server, args): - weechat.prnt("server:"+server+" arguments:"+args) + weechat.prnt("server="+server+", args="+args) return weechat.PLUGIN_RC_OK + +# ruby +def my_command(server, args) + Weechat.print("server=#{server}, args=#{args}") + return Weechat::PLUGIN_RC_OK +end +Weechat.add_command_handler ("command", "my_command") + +-- 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> @@ -3705,6 +3789,12 @@ def my_command(server, args): </command> </para> <para> + Lua prototype: + <command> + weechat.remove_handler ( name, function ) + </command> + </para> + <para> Remove a handler. </para> <para> @@ -3736,6 +3826,9 @@ weechat.remove_handler ("command", my_command) # ruby Weechat.remove_handler ("command", my_command) + +-- lua +weechat.remove_handler ("command", "my_command") </screen> </para> </section> @@ -3762,6 +3855,12 @@ Weechat.remove_handler ("command", my_command) </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> @@ -3806,6 +3905,11 @@ weechat.command ("/nick newnick", "", "freenode") 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> @@ -3832,6 +3936,12 @@ Weechat.command ("/nick newnick", "", "freenode") </command> </para> <para> + Lua prototype: + <command> + weechat.get_info ( name, [server] ) + </command> + </para> + <para> Return an info about WeeChat or a channel. </para> <para> @@ -3865,6 +3975,14 @@ $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> @@ -3891,12 +4009,87 @@ nick = weechat.get_info ("nick", "freenode") </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> @@ -3921,6 +4114,12 @@ nick = weechat.get_info ("nick", "freenode") </command> </para> <para> + Lua prototype: + <command> + weechat.get_server_info ( ) + </command> + </para> + <para> Return list of IRC servers (connected or not). </para> <para> @@ -3974,6 +4173,26 @@ if servers != nil 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(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> @@ -4000,6 +4219,12 @@ end </command> </para> <para> + Lua prototype: + <command> + weechat.get_channel_info ( server ) + </command> + </para> + <para> Return list of IRC channels for a server. </para> <para> @@ -4010,7 +4235,7 @@ end Examples: <screen> # perl -my $channels = weechat::get_channel_info(weechat::get_info('server')); +my $channels = weechat::get_channel_info(weechat::get_info("server")); if ($channels) { while (my ($channame, $chaninfos) = each %$channels) @@ -4027,7 +4252,7 @@ else } # python -chans = weechat.get_channel_info(weechat.get_info('server')) +chans = weechat.get_channel_info(weechat.get_info("server")) if chans != None: if chans == {}: weechat.prnt("no channel") @@ -4039,7 +4264,7 @@ else: weechat.prnt("error while getting channels") # ruby -channels = Weechat.get_channel_info(Weechat.get_info('server')) +channels = Weechat.get_channel_info(Weechat.get_info("server")) if channels != nil if channels == {} Weechat.print("no channel") @@ -4053,6 +4278,26 @@ if channels != nil 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(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> @@ -4079,6 +4324,12 @@ end </command> </para> <para> + Lua prototype: + <command> + weechat.get_nick_info ( server, channel ) + </command> + </para> + <para> Return list of nicks for a channel. </para> <para> @@ -4132,6 +4383,26 @@ if nicks != nil 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> @@ -4158,6 +4429,12 @@ end </command> </para> <para> + Lua prototype: + <command> + weechat.get_config ( option ) + </command> + </para> + <para> Return value of a WeeChat config option. </para> <para> @@ -4183,6 +4460,14 @@ $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> @@ -4209,6 +4494,12 @@ value2 = weechat.get_config ("freenode.server_autojoin") </command> </para> <para> + Lua prototype: + <command> + weechat.set_config ( option, value ) + </command> + </para> + <para> Update value of a WeeChat config option. </para> <para> @@ -4244,6 +4535,10 @@ 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> @@ -4270,6 +4565,12 @@ Weechat.set_config ("freenode.server_autojoin, "#weechat") </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 @@ -4296,6 +4597,12 @@ $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> @@ -4322,6 +4629,12 @@ value = weechat.get_plugin_config ("my_var") </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 @@ -4357,6 +4670,9 @@ 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> diff --git a/weechat/doc/fr/weechat.fr.xml b/weechat/doc/fr/weechat.fr.xml index 2d802c518..77a8e6b17 100644 --- a/weechat/doc/fr/weechat.fr.xml +++ b/weechat/doc/fr/weechat.fr.xml @@ -1168,7 +1168,7 @@ fi <para> Ce chapitre décrit l'interface des extensions (API) et les extensions - pour scripts (Perl, Python, Ruby), fournies avec WeeChat. + pour scripts (Perl, Python, Ruby, Lua), fournies avec WeeChat. </para> <section id="secLesExtensionsDansWeeChat"> @@ -3267,7 +3267,7 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <para> Trois extensions sont fournies en standard avec WeeChat pour utiliser - des langages de script : Perl, Python et Ruby. + des langages de script : Perl, Python, Ruby et Lua. </para> <section id="secChargerDechargerScripts"> @@ -3275,9 +3275,10 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <para> Les scripts sont chargés et déchargés avec les commandes - <command>/perl</command>, <command>/python</command> et - <command>/ruby</command> (tapez <command>/help</command> dans - WeeChat pour obtenir de l'aide sur les commandes). + <command>/perl</command>, <command>/python</command>, + <command>/ruby</command> et <command>/lua</command> + (tapez <command>/help</command> dans WeeChat pour obtenir + de l'aide sur les commandes). </para> <para> @@ -3319,6 +3320,18 @@ void weechat_plugin_end (t_weechat_plugin *plugin) <command><userinput>/ruby</userinput></command> </para> </listitem> + <listitem> + <para> + Charger un script Lua : + <command><userinput>/lua load /tmp/essai.lua</userinput></command> + </para> + </listitem> + <listitem> + <para> + Lister les scripts Lua chargés : + <command><userinput>/lua</userinput></command> + </para> + </listitem> </itemizedlist> </para> @@ -3349,6 +3362,12 @@ void weechat_plugin_end (t_weechat_plugin *plugin) </command> </para> <para> + Prototype Lua : + <command> + weechat.register ( nom, version, fonction_de_fin, description ) + </command> + </para> + <para> C'est la première fonction à appeler dans le script. Tout script pour WeeChat doit appeler cette fonction. </para> @@ -3395,6 +3414,9 @@ weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !") # ruby Weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !") + +-- lua +weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !") </screen> </para> </section> @@ -3421,6 +3443,12 @@ Weechat.register ("essai", "1.0", "fin_essai", "Script d'essai !") </command> </para> <para> + Prototype Lua : + <command> + weechat.print ( message, [canal, [serveur]] ) + </command> + </para> + <para> Affiche un message sur un tampon WeeChat, identifié par le serveur et le canal. </para> @@ -3466,6 +3494,11 @@ weechat.prnt ("message", "#weechat", "freenode") 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> @@ -3492,6 +3525,12 @@ Weechat.print ("message", "#weechat", "freenode") </command> </para> <para> + Prototype Lua : + <command> + weechat.print_infobar ( temps, message ) + </command> + </para> + <para> Affiche un message sur la barre d'infos pour un temps déterminé. </para> <para> @@ -3524,6 +3563,9 @@ weechat.print_infobar (5, "message") # ruby Weechat.print_infobar (5, "message") + +-- lua +weechat.print_infobar (5, "message") </screen> </para> </section> @@ -3550,6 +3592,12 @@ Weechat.print_infobar (5, "message") </command> </para> <para> + Prototype Lua : + <command> + weechat.add_message_handler ( message, fonction ) + </command> + </para> + <para> Ajoute un gestionnaire de messages IRC, appelé dès qu'un message IRC est reçu. </para> @@ -3599,6 +3647,20 @@ def ma_fonction(serveur, args): masque, null, canal = string.split(string.strip(canal), " ", 2) weechat.prnt("masque="+masque+", canal="+canal+", message="+message) return weechat.PLUGIN_RC_OK + +# ruby +def ma_fonction(server, args) + Weechat.print("serveur=#{server}, args=#{args}") + return Weechat::PLUGIN_RC_OK +end +Weechat.add_message_handler ("privmsg", "ma_fonction") + +-- lua +weechat.add_message_handler ("privmsg", "ma_fonction") +function ma_fonction(server, args) + weechat.print("serveur=" .. server .. ", args=" .. args) + return weechat.PLUGIN_RC_OK() +end </screen> </para> <para> @@ -3666,6 +3728,14 @@ def ma_fonction(serveur, args): </command> </para> <para> + Prototype Lua : + <command> + weechat.add_command_handler ( commande, fonction, + [description, arguments, arguments_description, + modele_completion] ) + </command> + </para> + <para> Ajoute un gestionnaire de commande WeeChat, appelé dès que l'utilisateur utilise la commande (par exemple /commande). </para> @@ -3719,15 +3789,29 @@ def ma_fonction(serveur, args): weechat::add_command_handler ("commande", ma_commande); sub ma_commande { - weechat::print("Serveur: $_[0], paramètres: $_[1]\n"); + weechat::print("serveur=$_[0], args=$_[1]\n"); return weechat::PLUGIN_RC_OK; } # python weechat.add_command_handler ("commande", ma_commande) def ma_commande(serveur, args): - weechat.prnt("serveur:"+serveur+" paramètres:"+args) + weechat.prnt("serveur="+serveur+", args="+args) return weechat.PLUGIN_RC_OK + +# ruby +def ma_commande(server, args) + Weechat.print("serveur=#{server} args=#{args}") + return Weechat::PLUGIN_RC_OK +end +Weechat.add_command_handler ("command", "ma_commande") + +-- lua +weechat.add_command_handler ("command", "ma_commande") +def my_command(server, args) + weechat.print("serveur="..server..", args="..args) + return weechat.PLUGIN_RC_OK() +end </screen> </para> <para> @@ -3771,6 +3855,12 @@ def ma_commande(serveur, args): </command> </para> <para> + Prototype Lua : + <command> + weechat.remove_handler ( nom, fonction ) + </command> + </para> + <para> Supprime un gestionnaire. </para> <para> @@ -3802,6 +3892,9 @@ weechat.remove_handler ("commande", ma_commande) # ruby Weechat.remove_handler ("commande", ma_commande) + +-- lua +weechat.remove_handler ("commande", "ma_commande") </screen> </para> </section> @@ -3828,6 +3921,12 @@ Weechat.remove_handler ("commande", ma_commande) </command> </para> <para> + Prototype Lua : + <command> + weechat.command ( commande, [canal, [serveur]] ) + </command> + </para> + <para> Exécute une commande ou envoie un message à un canal. </para> <para> @@ -3872,6 +3971,11 @@ weechat.command ("/nick newnick", "", "freenode") Weechat.command ("bonjour tout le monde !") Weechat.command ("/kick toto merci de quitter ce canal", "#weechat") Weechat.command ("/nick newnick", "", "freenode") + +-- lua +weechat.command ("bonjour tout le monde !") +weechat.command ("/kick toto merci de quitter ce canal", "#weechat") +weechat.command ("/nick newnick", "", "freenode") </screen> </para> </section> @@ -3898,6 +4002,12 @@ Weechat.command ("/nick newnick", "", "freenode") </command> </para> <para> + Prototype Lua : + <command> + weechat.get_info ( nom, [serveur] ) + </command> + </para> + <para> Renvoie une information sur WeeChat ou un canal. </para> <para> @@ -3931,6 +4041,14 @@ $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> @@ -3957,12 +4075,87 @@ nick = weechat.get_info ("nick", "freenode") </command> </para> <para> + Prototype Lua : + <command> + weechat.get_dcc_info ( ) + </command> + </para> + <para> Renvoie la liste des DCC en cours ou terminés. </para> <para> Valeur renvoyée : la liste des DCC (voir <xref linkend="secAPI_get_dcc_info" />). </para> + <para> + Exemples : +<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("pas de DCC"); +} + +# python +dccs = weechat.get_dcc_info() +if dccs != None: + if dccs == []: + weechat.prnt("pas de DCC") + else: + for d in dccs: + for b in d.keys(): + weechat.prnt("%s = '%s'" %(b, d[b])) +else: + weechat.prnt("erreur de lecture des DCC") + +# ruby +dccs = Weechat.get_dcc_info() +if dccs != nil + if dccs == [] + Weechat.print("pas de DCC") + else + dccs.each do |m| + m.each do |key, value| + Weechat.print("#{key} = '#{value}'") + end + end + end +else + Weechat.print("erreur de lecture des 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("pas de DCC") + end +else + weechat.print("erreur de lecture des DCC") +end +</screen> + </para> </section> <section> @@ -3987,6 +4180,12 @@ nick = weechat.get_info ("nick", "freenode") </command> </para> <para> + Prototype Lua : + <command> + weechat.get_server_info ( ) + </command> + </para> + <para> Renvoie la liste des serveurs IRC (connectés ou non). </para> <para> @@ -4002,7 +4201,7 @@ if ($servers) { while (my ($srvname, $srvinfos) = each %$servers) { - while ( my ($key, $value) = each %$srvinfos) + while (my ($key, $value) = each %$srvinfos) { weechat::print("$srvname[$key] = '$value'"); } @@ -4040,6 +4239,26 @@ if servers != nil else Weechat.print("erreur de lecture des serveurs") 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(key.." = '"..value.."'") + key, value = next (srvinfos, key) + end + srv, srvinfos = next (servers, srv) + end + else + weechat.print("pas de serveur") + end +else + weechat.print("erreur de lecture des serveurs") +end </screen> </para> </section> @@ -4066,6 +4285,12 @@ end </command> </para> <para> + Prototype Lua : + <command> + weechat.get_channel_info ( serveur ) + </command> + </para> + <para> Renvoie la liste des canaux IRC pour un serveur. </para> <para> @@ -4076,7 +4301,7 @@ end Exemples : <screen> # perl -my $channels = weechat::get_channel_info(weechat::get_info('server')); +my $channels = weechat::get_channel_info(weechat::get_info("server")); if ($channels) { while (my ($channame, $chaninfos) = each %$channels) @@ -4093,7 +4318,7 @@ else } # python -chans = weechat.get_channel_info(weechat.get_info('server')) +chans = weechat.get_channel_info(weechat.get_info("server")) if chans != None: if chans == {}: weechat.prnt("pas de canal") @@ -4105,7 +4330,7 @@ else: weechat.prnt("erreur de lecture des canaux") # ruby -channels = Weechat.get_channel_info(Weechat.get_info('server')) +channels = Weechat.get_channel_info(Weechat.get_info("server")) if channels != nil if channels == {} Weechat.print("pas de canal") @@ -4119,6 +4344,26 @@ if channels != nil else Weechat.print("erreur de lecture des canaux") 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(key.." = '"..value.."'") + key, value = next (chaninfos, key) + end + chan, chaninfos = next (chans, chan) + end + else + weechat.print("pas de canal") + end +else + weechat.print("erreur de lecture des canaux") +end </screen> </para> </section> @@ -4129,7 +4374,7 @@ end <para> Prototype Perl : <command> - weechat::get_nick_info ( server, canal ); + weechat::get_nick_info ( serveur, canal ); </command> </para> <para> @@ -4145,6 +4390,12 @@ end </command> </para> <para> + Prototype Lua : + <command> + weechat.get_nick_info ( serveur, canal ) + </command> + </para> + <para> Renvoie la liste des pseudos pour un canal. </para> <para> @@ -4198,6 +4449,26 @@ if nicks != nil else Weechat.print("erreur de lecture des pseudos") 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("pas de pseudo") + end +else + weechat.print("erreur de lecture des pseudos") +end </screen> </para> </section> @@ -4224,6 +4495,12 @@ end </command> </para> <para> + Prototype Lua : + <command> + weechat.get_config ( option ) + </command> + </para> + <para> Renvoie la valeur d'une option de configuration WeeChat. </para> <para> @@ -4250,6 +4527,14 @@ $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> @@ -4276,6 +4561,12 @@ value2 = weechat.get_config ("freenode.server_autojoin") </command> </para> <para> + Prototype Lua : + <command> + weechat.set_config ( option, valeur ) + </command> + </para> + <para> Modifie la valeur d'une option de configuration WeeChat. </para> <para> @@ -4312,6 +4603,10 @@ 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> @@ -4338,6 +4633,12 @@ Weechat.set_config ("freenode.server_autojoin, "#weechat") </command> </para> <para> + Prototype Lua : + <command> + weechat.get_plugin_config ( option ) + </command> + </para> + <para> Renvoie la valeur d'une option de l'extension. L'option est lue depuis le fichier "<literal>~/.weechat/plugins.rc</literal>" et est @@ -4368,6 +4669,12 @@ $value = weechat::get_plugin_config ("ma_variable"); # python value = weechat.get_plugin_config ("ma_variable") + +# ruby +value = Weechat.get_plugin_config ("ma_variable") + +-- lua +value = weechat.get_plugin_config ("ma_variable") </screen> </para> </section> @@ -4394,6 +4701,12 @@ value = weechat.get_plugin_config ("ma_variable") </command> </para> <para> + Prototype Lua : + <command> + weechat.set_plugin_config ( option, valeur ) + </command> + </para> + <para> Modifie la valeur d'une option de l'extension. L'option est écrite dans le fichier "<literal>~/.weechat/plugins.rc</literal>" et est @@ -4433,6 +4746,9 @@ weechat.set_plugin_config ("ma_variable", "valeur") # ruby Weechat.set_plugin_config ("ma_variable", "valeur") + +-- lua +weechat.set_plugin_config ("ma_variable", "valeur") </screen> </para> </section> |