From 3a213f38eca02f158169afd2f140050930f5cdc3 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 19 Feb 2006 10:43:47 +0000 Subject: Added timer handler for plugins --- doc/en/weechat.en.xml | 640 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 481 insertions(+), 159 deletions(-) (limited to 'doc/en/weechat.en.xml') diff --git a/doc/en/weechat.en.xml b/doc/en/weechat.en.xml index 74131e960..a4e6f4b60 100644 --- a/doc/en/weechat.en.xml +++ b/doc/en/weechat.en.xml @@ -1999,6 +1999,87 @@ plugin->cmd_handler_add (plugin, "test", "Test command", +
+ timer_handler_add + + + Prototype: + + t_plugin_handler *timer_handler_add (t_weechat_plugin + *plugin, int interval, t_plugin_handler_func *function, + char *handler_args, void *handler_pointer) + + + + Add a timer handler which periodically calls a function. + + + Arguments: + + + + : pointer to plugin structure + + + + + : interval (in seconds) between + two calls of function. + + + + + : function called + + + + + : arguments given to function + when called + + + + + : pointer given to function + when called + + + + + + Return value: pointer to new message handler. + + + Note: function called has to return one of following values: + + + + PLUGIN_RC_KO: function failed + + + + + PLUGIN_RC_OK: function successfully + completed + + + + + + Example: + +int my_timer (t_weechat_plugin *plugin, char *server, char *command, + char *arguments, char *handler_args, void *handler_pointer) +{ + plugin->print (plugin, NULL, NULL, "my timer"); + return PLUGIN_RC_OK; +} +... +plugin->timer_handler_add (plugin, 60, &my_timer); + + +
+
handler_remove @@ -3324,6 +3405,89 @@ void weechat_plugin_end (t_weechat_plugin *plugin)
+
+ Syntax by language + +
+ Perl + + + In a WeeChat Perl script, all API functions and variables are + prefixed by "weechat::". + Example: +weechat::register("test", "1.0", "end_test", "WeeChat perl script"); + + +
+ +
+ Python + + + A WeeChat Python script has to start by importing weechat: + import weechat + + + + All API functions and variables are prefixed by + "weechat.". + Example: +weechat.register("test", "1.0", "end_test", "WeeChat python script") + + +
+ +
+ Ruby + + + In a WeeChat Ruby script, all code has to be in functions. + So for main code, you have to define a + "weechat_init" function, which is automatically + called when script is loaded by WeeChat. Example: + +def weechat_init + Weechat.register("test", "1.0", "end_test", "WeeChat ruby script") + Weechat.add_command_handler("command", "my_command") + return Weechat::PLUGIN_RC_OK +end + +def my_command(server, args) + Weechat.print("my command") + return Weechat::PLUGIN_RC_OK +end + + + + + All API functions are prefixed by + "Weechat." and variables by + "Weechat::". + + +
+ +
+ Lua + + + In a WeeChat Lua script, all API functions are prefixed by + "weechat.". + Variables are prefixed by "weechat." and + suffixed by "()". + Example: + +function message_handler(server, args) + weechat.print("I am a message handler") + return weechat.PLUGIN_RC_OK() +end + + + +
+ +
+
WeeChat / scripts API @@ -3333,25 +3497,25 @@ void weechat_plugin_end (t_weechat_plugin *plugin) Perl prototype: - weechat::register ( name, version, end_function, description ); + weechat::register(name, version, end_function, description); Python prototype: - weechat.register ( name, version, end_function, description ) + weechat.register(name, version, end_function, description) Ruby prototype: - Weechat.register ( name, version, end_function, description ) + Weechat.register(name, version, end_function, description) Lua prototype: - weechat.register ( name, version, end_function, description ) + weechat.register(name, version, end_function, description) @@ -3393,16 +3557,16 @@ void weechat_plugin_end (t_weechat_plugin *plugin) Examples: # perl -weechat::register ("test", "1.0", "end_test", "Test script!"); +weechat::register("test", "1.0", "end_test", "Test script!"); # python -weechat.register ("test", "1.0", "end_test", "Test script!") +weechat.register("test", "1.0", "end_test", "Test script!") # ruby -Weechat.register ("test", "1.0", "end_test", "Test script!") +Weechat.register("test", "1.0", "end_test", "Test script!") -- lua -weechat.register ("test", "1.0", "end_test", "Test script!") +weechat.register("test", "1.0", "end_test", "Test script!")
@@ -3413,25 +3577,25 @@ weechat.register ("test", "1.0", "end_test", "Test script!") Perl prototype: - weechat::print ( message, [channel, [server]] ) + weechat::print(message, [channel, [server]]) Python prototype: - weechat.prnt ( message, [channel, [server]] ) + weechat.prnt(message, [channel, [server]]) Ruby prototype: - Weechat.print ( message, [channel, [server]] ) + Weechat.print(message, [channel, [server]]) Lua prototype: - weechat.print ( message, [channel, [server]] ) + weechat.print(message, [channel, [server]]) @@ -3467,24 +3631,24 @@ weechat.register ("test", "1.0", "end_test", "Test script!") Examples: # perl -weechat::print ("message"); -weechat::print ("message", "#weechat"); -weechat::print ("message", "#weechat", "freenode"); +weechat::print("message"); +weechat::print("message", "#weechat"); +weechat::print("message", "#weechat", "freenode"); # python -weechat.prnt ("message") -weechat.prnt ("message", "#weechat") -weechat.prnt ("message", "#weechat", "freenode") +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") +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") +weechat.print("message") +weechat.print("message", "#weechat") +weechat.print("message", "#weechat", "freenode") @@ -3495,25 +3659,25 @@ weechat.print ("message", "#weechat", "freenode") Perl prototype: - weechat::print_infobar ( time, message ); + weechat::print_infobar(time, message); Python prototype: - weechat.print_infobar ( time, message ) + weechat.print_infobar(time, message) Ruby prototype: - Weechat.print_infobar ( time, message ) + Weechat.print_infobar(time, message) Lua prototype: - weechat.print_infobar ( time, message ) + weechat.print_infobar(time, message) @@ -3542,16 +3706,16 @@ weechat.print ("message", "#weechat", "freenode") Examples: # perl -weechat::print_infobar (5, "message"); +weechat::print_infobar(5, "message"); # python -weechat.print_infobar (5, "message") +weechat.print_infobar(5, "message") # ruby -Weechat.print_infobar (5, "message") +Weechat.print_infobar(5, "message") -- lua -weechat.print_infobar (5, "message") +weechat.print_infobar(5, "message") @@ -3562,25 +3726,25 @@ weechat.print_infobar (5, "message") Perl prototype: - weechat::log ( message, [channel, [server]] ) + weechat::log(message, [channel, [server]]); Python prototype: - weechat.log ( message, [channel, [server]] ) + weechat.log(message, [channel, [server]]) Ruby prototype: - Weechat.log ( message, [channel, [server]] ) + Weechat.log(message, [channel, [server]]) Lua prototype: - weechat.log ( message, [channel, [server]] ) + weechat.log(message, [channel, [server]]) @@ -3615,16 +3779,16 @@ weechat.print_infobar (5, "message") Examples: # perl -weechat::log ("message", "#weechat", "freenode"); +weechat::log("message", "#weechat", "freenode"); # python -weechat.log ("message", "#weechat", "freenode") +weechat.log("message", "#weechat", "freenode") # ruby -Weechat.log ("message", "#weechat", "freenode") +Weechat.log("message", "#weechat", "freenode") -- lua -weechat.log ("message", "#weechat", "freenode") +weechat.log("message", "#weechat", "freenode") @@ -3635,25 +3799,25 @@ weechat.log ("message", "#weechat", "freenode") Perl prototype: - weechat::add_message_handler ( message, function ); + weechat::add_message_handler(message, function); Python prototype: - weechat.add_message_handler ( message, function ) + weechat.add_message_handler(message, function) Ruby prototype: - Weechat.add_message_handler ( message, function ) + Weechat.add_message_handler(message, function) Lua prototype: - weechat.add_message_handler ( message, function ) + weechat.add_message_handler(message, function) @@ -3686,18 +3850,18 @@ weechat.log ("message", "#weechat", "freenode") Examples: # perl -weechat::add_message_handler ("privmsg", my_function); +weechat::add_message_handler ("privmsg", "my_function"); sub my_function { - weechat::print ("server=$_[0]\n"); + weechat::print("server=$_[0]"); ($null, $channel, $message) = split ":",$_[1],3; ($mask, $null, $channel) = split " ", $channel; - weechat::print ("mask=$mask, channel=$channel, msg=$message\n"); + weechat::print("mask=$mask, channel=$channel, msg=$message"); return weechat::PLUGIN_RC_OK; } # python -weechat.add_message_handler ("privmsg", my_function) +weechat.add_message_handler ("privmsg", "my_function") def my_function(server, args): weechat.prnt("server="+server) null, channel, message = string.split(args, ":", 2) @@ -3706,11 +3870,11 @@ def my_function(server, args): 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 -Weechat.add_message_handler ("privmsg", "my_function") -- lua weechat.add_message_handler ("privmsg", "my_function") @@ -3721,9 +3885,8 @@ end - Note: function called when message is received has to return one - of following values (prefixed by weechat::" for Perl, "weechat." - for Python or "Weechat." for Ruby): + Note: function called when message is received has to return + one of following values: @@ -3764,33 +3927,33 @@ end Perl prototype: - weechat::add_command_handler ( command, function, + weechat::add_command_handler(command, function, [description, arguments, arguments_description, - completion_template] ); + completion_template]); Python prototype: - weechat.add_command_handler ( command, function, + weechat.add_command_handler(command, function, [description, arguments, arguments_description, - completion_template] ) + completion_template]) Ruby prototype: - Weechat.add_command_handler ( command, function, + Weechat.add_command_handler(command, function, [description, arguments, arguments_description, - completion_template] ) + completion_template]) Lua prototype: - weechat.add_command_handler ( command, function, + weechat.add_command_handler(command, function, [description, arguments, arguments_description, - completion_template] ) + completion_template]) @@ -3843,28 +4006,28 @@ end Examples: # perl -weechat::add_command_handler ("command", my_command); +weechat::add_command_handler("command", "my_command"); sub my_command { - weechat::print("server= $_[0], args: $_[1]\n"); + weechat::print("server= $_[0], args: $_[1]"); return weechat::PLUGIN_RC_OK; } # python -weechat.add_command_handler ("command", my_command) +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 -Weechat.add_command_handler ("command", "my_command") -- lua -weechat.add_command_handler ("command", "my_command") +weechat.add_command_handler("command", "my_command") def my_command(server, args) weechat.print("server="..server..", args="..args) return weechat.PLUGIN_RC_OK() @@ -3872,9 +4035,8 @@ end - Notes: function called when command is executed has to return one - of following values (prefixed by "weechat::" for Perl, "weechat." - for Python or "Weechat." for Ruby): + Notes: function called when command is executed has to return + one of following values: @@ -3891,35 +4053,134 @@ end +
+ add_timer_handler + + + Perl prototype: + + weechat::add_timer_handler(message, function); + + + + Python prototype: + + weechat.add_timer_handler(message, function) + + + + Ruby prototype: + + Weechat.add_timer_handler(message, function) + + + + Lua prototype: + + weechat.add_timer_handler(message, function) + + + + Add a timer handler which periodically calls a function. + + + Arguments: + + + + : interval (in seconds) between + two calls of function. + + + + + : function called + + + + + + Return value: 1 if success, 0 if an error occurred. + + + Examples: + +# perl +weechat::add_timer_handler(60, "my_timer"); +sub my_timer +{ + weechat::print("this is timer handler"); + return weechat::PLUGIN_RC_OK; +} + +# python +weechat.add_timer_handler(60, "my_timer") +def my_timer(server, args): + weechat.prnt("this is timer handler") + return weechat.PLUGIN_RC_OK + +# ruby +Weechat.add_timer_handler(60, "my_timer") +def my_timer(server, args) + Weechat.print("this is timer handler") + return Weechat::PLUGIN_RC_OK +end + +-- lua +weechat.add_timer_handler(60, "my_timer") +function my_timer(server, args) + weechat.print("this is timer handler) + return weechat.PLUGIN_RC_OK() +end + + + + Note: function called has to return one of following values: + + + + PLUGIN_RC_KO: function failed + + + + + PLUGIN_RC_OK: function successfully + completed + + + + +
+
remove_handler Perl prototype: - weechat::remove_handler ( name, function ); + weechat::remove_handler(name, function); Python prototype: - weechat.remove_handler ( name, function ) + weechat.remove_handler(name, function) Ruby prototype: - Weechat.remove_handler ( name, function ) + Weechat.remove_handler(name, function) Lua prototype: - weechat.remove_handler ( name, function ) + weechat.remove_handler(name, function) - Remove a handler. + Remove a message or command handler. Arguments: @@ -3943,16 +4204,77 @@ end Examples: # perl -weechat::remove_handler ("command", my_command); +weechat::remove_handler("command", "my_command"); + +# python +weechat.remove_handler("command", "my_command") + +# ruby +Weechat.remove_handler("command", "my_command") + +-- lua +weechat.remove_handler("command", "my_command") + + +
+ +
+ remove_timer_handler + + + Perl prototype: + + weechat::remove_timer_handler(function); + + + + Python prototype: + + weechat.remove_timer_handler(function) + + + + Ruby prototype: + + Weechat.remove_timer_handler(function) + + + + Lua prototype: + + weechat.remove_timer_handler(function) + + + + Remove a timer handler. + + + Arguments: + + + + : function + + + + + + Return value: 1 if success, 0 if an error occurred. + + + Examples: + +# perl +weechat::remove_timer_handler("my_timer"); # python -weechat.remove_handler ("command", my_command) +weechat.remove_timer_handler("my_timer") # ruby -Weechat.remove_handler ("command", my_command) +Weechat.remove_timer_handler("my_timer") -- lua -weechat.remove_handler ("command", "my_command") +weechat.remove_timer_handler("my_timer")
@@ -3963,25 +4285,25 @@ weechat.remove_handler ("command", "my_command") Perl prototype: - weechat::command ( command, [channel, [server]] ); + weechat::command(command, [channel, [server]]); Python prototype: - weechat.command ( command, [channel, [server]] ) + weechat.command(command, [channel, [server]]) Ruby prototype: - Weechat.command ( command, [channel, [server]] ) + Weechat.command(command, [channel, [server]]) Lua prototype: - weechat.command ( command, [channel, [server]] ) + weechat.command(command, [channel, [server]]) @@ -4016,24 +4338,24 @@ weechat.remove_handler ("command", "my_command") Examples: # perl -weechat::command ("hello everybody!"); -weechat::command ("/kick toto please leave this channel", "#weechat"); -weechat::command ("/nick newnick", "", "freenode"); +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") +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") +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") +weechat.command("hello everybody!") +weechat.command("/kick toto please leave this channel", "#weechat") +weechat.command("/nick newnick", "", "freenode") @@ -4044,25 +4366,25 @@ weechat.command ("/nick newnick", "", "freenode") Perl prototype: - weechat::get_info ( name, [server] ); + weechat::get_info(name, [server]); Python prototype: - weechat.get_info ( name, [server] ) + weechat.get_info(name, [server]) Ruby prototype: - Weechat.get_info ( name, [server] ) + Weechat.get_info(name, [server]) Lua prototype: - weechat.get_info ( name, [server] ) + weechat.get_info(name, [server]) @@ -4097,16 +4419,16 @@ $version = get_info("version"); $nick = get_info("nick", "freenode"); # python -version = weechat.get_info ("version") -nick = weechat.get_info ("nick", "freenode") +version = weechat.get_info("version") +nick = weechat.get_info("nick", "freenode") # ruby -version = Weechat.get_info ("version") -nick = Weechat.get_info ("nick", "freenode") +version = Weechat.get_info("version") +nick = Weechat.get_info("nick", "freenode") -- lua -version = weechat.get_info ("version") -nick = weechat.get_info ("nick", "freenode") +version = weechat.get_info("version") +nick = weechat.get_info("nick", "freenode") @@ -4117,25 +4439,25 @@ nick = weechat.get_info ("nick", "freenode") Perl prototype: - weechat::get_dcc_info ( ); + weechat::get_dcc_info(); Python prototype: - weechat.get_dcc_info ( ) + weechat.get_dcc_info() Ruby prototype: - Weechat.get_dcc_info ( ) + Weechat.get_dcc_info() Lua prototype: - weechat.get_dcc_info ( ) + weechat.get_dcc_info() @@ -4222,25 +4544,25 @@ end Perl prototype: - weechat::get_server_info ( ); + weechat::get_server_info(); Python prototype: - weechat.get_server_info ( ) + weechat.get_server_info() Ruby prototype: - Weechat.get_server_info ( ) + Weechat.get_server_info() Lua prototype: - weechat.get_server_info ( ) + weechat.get_server_info() @@ -4327,25 +4649,25 @@ end Perl prototype: - weechat::get_channel_info ( server ); + weechat::get_channel_info(server); Python prototype: - weechat.get_channel_info ( server ) + weechat.get_channel_info(server) Ruby prototype: - Weechat.get_channel_info ( server ) + Weechat.get_channel_info(server) Lua prototype: - weechat.get_channel_info ( server ) + weechat.get_channel_info(server) @@ -4432,25 +4754,25 @@ end Perl prototype: - weechat::get_nick_info ( server, channel ); + weechat::get_nick_info(server, channel); Python prototype: - weechat.get_nick_info ( server, channel ) + weechat.get_nick_info(server, channel) Ruby prototype: - Weechat.get_nick_info ( server, channel ) + Weechat.get_nick_info(server, channel) Lua prototype: - weechat.get_nick_info ( server, channel ) + weechat.get_nick_info(server, channel) @@ -4537,25 +4859,25 @@ end Perl prototype: - weechat::get_config ( option ); + weechat::get_config(option); Python prototype: - weechat.get_config ( option ) + weechat.get_config(option) Ruby prototype: - Weechat.get_config ( option ) + Weechat.get_config(option) Lua prototype: - weechat.get_config ( option ) + weechat.get_config(option) @@ -4578,20 +4900,20 @@ end Examples: # perl -$value1 = weechat::get_config ("look_nicklist"); -$value2 = weechat::get_config ("freenode.server_autojoin"); +$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") +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") +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") +value1 = weechat.get_config("look_nicklist") +value2 = weechat.get_config("freenode.server_autojoin") @@ -4602,25 +4924,25 @@ value2 = weechat.get_config ("freenode.server_autojoin") Perl prototype: - weechat::set_config ( option, value ); + weechat::set_config(option, value); Python prototype: - weechat.set_config ( option, value ) + weechat.set_config(option, value) Ruby prototype: - Weechat.set_config ( option, value ) + Weechat.set_config(option, value) Lua prototype: - weechat.set_config ( option, value ) + weechat.set_config(option, value) @@ -4649,20 +4971,20 @@ value2 = weechat.get_config ("freenode.server_autojoin") Examples: # perl -weechat::set_config ("look_nicklist", "off"); -weechat::set_config ("freenode.server_autojoin, "#weechat"); +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") +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") +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") +weechat.set_config("look_nicklist", "off") +weechat.set_config("freenode.server_autojoin, "#weechat") @@ -4673,25 +4995,25 @@ weechat.set_config ("freenode.server_autojoin, "#weechat") Perl prototype: - weechat::get_plugin_config ( option ); + weechat::get_plugin_config(option); Python prototype: - weechat.get_plugin_config ( option ) + weechat.get_plugin_config(option) Ruby prototype: - Weechat.get_plugin_config ( option ) + Weechat.get_plugin_config(option) Lua prototype: - weechat.get_plugin_config ( option ) + weechat.get_plugin_config(option) @@ -4717,16 +5039,16 @@ weechat.set_config ("freenode.server_autojoin, "#weechat") Examples : # perl -$value = weechat::get_plugin_config ("my_var"); +$value = weechat::get_plugin_config("my_var"); # python -value = weechat.get_plugin_config ("my_var") +value = weechat.get_plugin_config("my_var") # ruby -value = Weechat.get_plugin_config ("my_var") +value = Weechat.get_plugin_config("my_var") -- lua -value = weechat.get_plugin_config ("my_var") +value = weechat.get_plugin_config("my_var") @@ -4737,25 +5059,25 @@ value = weechat.get_plugin_config ("my_var") Perl prototype: - weechat::set_plugin_config ( option, value ); + weechat::set_plugin_config(option, value); Python prototype: - weechat.set_plugin_config ( option, value ) + weechat.set_plugin_config(option, value) Ruby prototype: - Weechat.set_plugin_config ( option, value ) + Weechat.set_plugin_config(option, value) Lua prototype: - weechat.set_plugin_config ( option, value ) + weechat.set_plugin_config(option, value) @@ -4787,16 +5109,16 @@ value = weechat.get_plugin_config ("my_var") Examples: # perl -weechat::set_plugin_config ("my_var", "value"); +weechat::set_plugin_config("my_var", "value"); # python -weechat.set_plugin_config ("my_var", "value") +weechat.set_plugin_config("my_var", "value") # ruby -Weechat.set_plugin_config ("my_var", "value") +Weechat.set_plugin_config("my_var", "value") -- lua -weechat.set_plugin_config ("my_var", "value") +weechat.set_plugin_config("my_var", "value") -- cgit v1.2.3