Scripts plugins Four plugins are provided with WeeChat to use script languages: Perl, Python, Ruby and Lua.
Load / unload scripts Scripts are loaded and unloaded with /perl, /python, /ruby and /lua commands (type /help in WeeChat for help about commands). Examples: Load a Perl script: /perl load /tmp/test.pl List all loaded Perl scripts: /perl Load a Python script: /python load /tmp/test.py List all loaded Python scripts: /python Load a Ruby script: /ruby load /tmp/test.rb List all loaded Ruby scripts: /ruby Load a Lua script: /lua load /tmp/test.lua List all loaded Lua scripts: /lua
Syntax by language
Perl In a WeeChat Perl script, all API functions and variables are prefixed by "weechat::". Example: weechat::register("test", "1.0", "end_test", "WeeChat perl script");
Python A WeeChat Python script has to start by importing weechat: import weechat All API functions and variables are prefixed by "weechat.". Example: weechat.register("test", "1.0", "end_test", "WeeChat python script")
Ruby In a WeeChat Ruby script, all code has to be in functions. So for main code, you have to define a "weechat_init" function, which is automatically called when script is loaded by WeeChat. Example: def weechat_init Weechat.register("test", "1.0", "end_test", "WeeChat ruby script") Weechat.add_command_handler("command", "my_command") return Weechat::PLUGIN_RC_OK end def my_command(server, args) Weechat.print("my command") return Weechat::PLUGIN_RC_OK end All API functions are prefixed by "Weechat." and variables by "Weechat::".
Lua In a WeeChat Lua script, all API functions are prefixed by "weechat.". Variables are prefixed by "weechat." and suffixed by "()". Example: function message_handler(server, args) weechat.print("I am a message handler") return weechat.PLUGIN_RC_OK() end
WeeChat / scripts API
register Perl prototype: weechat::register(name, version, end_function, description, [charset]); Python prototype: weechat.register(name, version, end_function, description, [charset]) Ruby prototype: Weechat.register(name, version, end_function, description, [charset]) Lua prototype: weechat.register(name, version, end_function, description, [charset]) This is first function to call in script. All WeeChat scripts have to call this function. Arguments: : unique name to identify script (each script must have unique name) : script version : function called when script is unloaded (optional parameter, empty string means nothing is called at the end) : short description of script : charset used by script, you should set this if script is not written with UTF-8 Return value: 1 if script was registered, 0 if an error occured. Examples: # perl weechat::register("test", "1.0", "end_test", "Test script!", "ISO-8859-1"); # python weechat.register("test", "1.0", "end_test", "Test script!", "ISO-8859-1") # ruby Weechat.register("test", "1.0", "end_test", "Test script!", "ISO-8859-1") -- lua weechat.register("test", "1.0", "end_test", "Test script!", "ISO-8859-1")
set_charset Perl prototype: weechat::set_charset(charset); Python prototype: weechat.set_charset(charset) Ruby prototype: Weechat.set_charset(charset) Lua prototype: weechat.set_charset(charset) Set new script charset. Arguments: : new script charset Return value: 1 if new charset was set, 0 if an error occured. Examples: # perl weechat::set_charset("ISO-8859-1"); # python weechat.set_charset("ISO-8859-1") # ruby Weechat.set_charset("ISO-8859-1") -- lua weechat.set_charset("ISO-8859-1")
print Perl prototype: weechat::print(message, [channel, [server]]) Python prototype: weechat.prnt(message, [channel, [server]]) Ruby prototype: Weechat.print(message, [channel, [server]]) Lua prototype: weechat.print(message, [channel, [server]]) Display a message on a WeeChat buffer, identified by server and channel. Arguments: : message : name of channel to find buffer for message display : internal name of server to find buffer for message display To display colored text, see . Return value: 1 if success, 0 if an error occurred. Examples: # 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")
print_server Perl prototype: weechat::print_server(message) Python prototype: weechat.print_server(message) Ruby prototype: Weechat.print_server(message) Lua prototype: weechat.print_server(message) Display a message on server buffer. Arguments: : message To display colored text, see . Return value: 1 if success, 0 if an error occurred. Examples: # 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")
log Perl prototype: weechat::log(message, [channel, [server]]); Python prototype: weechat.log(message, [channel, [server]]) Ruby prototype: Weechat.log(message, [channel, [server]]) Lua prototype: weechat.log(message, [channel, [server]]) Write a message in log file for a server or a channel. Arguments: : message : name of channel to find buffer for log : internal name of server to find buffer for log Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::log("message", "#weechat", "freenode"); # python weechat.log("message", "#weechat", "freenode") # ruby Weechat.log("message", "#weechat", "freenode") -- lua weechat.log("message", "#weechat", "freenode")
add_message_handler Perl prototype: weechat::add_message_handler(message, function); Python prototype: weechat.add_message_handler(message, function) Ruby prototype: Weechat.add_message_handler(message, function) Lua prototype: weechat.add_message_handler(message, function) Add an IRC message handler, called when an IRC message is received. Arguments: : name of IRC message. To know list of IRC messages, please consult RFCs 1459 and 2812. Moreover you can use a special name, prefixed by "weechat_" to catch special events (see ). : function called when message is received Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_message_handler ("privmsg", "my_function"); sub my_function { weechat::print("server=$_[0]"); ($null, $channel, $message) = split ":",$_[1],3; ($mask, $null, $channel) = split " ", $channel; weechat::print("mask=$mask, channel=$channel, msg=$message"); return weechat::PLUGIN_RC_OK; } # python weechat.add_message_handler ("privmsg", "my_function") def my_function(server, args): weechat.prnt("server="+server) null, channel, message = string.split(args, ":", 2) mask, null, channel = string.split(string.strip(channel), " ", 2) weechat.prnt("mask="+mask+", canal="+channel+", message="+message) return weechat.PLUGIN_RC_OK # ruby Weechat.add_message_handler("privmsg", "my_function") def my_function(server, args) Weechat.print("server=#{server}, args=#{args}") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_message_handler ("privmsg", "my_function") function my_function(server, args) weechat.print("server=" .. server .. ", args=" .. args) return weechat.PLUGIN_RC_OK() end Note: function called when message is received has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed PLUGIN_RC_OK_IGNORE_WEECHAT: message will not be sent to WeeChat PLUGIN_RC_OK_IGNORE_PLUGINS: message will not be sent to other plugins PLUGIN_RC_OK_IGNORE_ALL: message will not be sent to WeeChat neither other plugins PLUGIN_RC_OK_WITH_HIGHLIGHT: function successfully completed and make "highlight" on received message
add_command_handler Perl prototype: weechat::add_command_handler(command, function, [description, arguments, arguments_description, completion_template]); Python prototype: weechat.add_command_handler(command, function, [description, arguments, arguments_description, completion_template]) Ruby prototype: Weechat.add_command_handler(command, function, [description, arguments, arguments_description, completion_template]) Lua prototype: weechat.add_command_handler(command, function, [description, arguments, arguments_description, completion_template]) Add a WeeChat command handler, called when user uses command (for example /command). Arguments: : the new command name, which may be an existing command (be careful, replaced command will not be available until script is unloaded) : function called when command is executed : short description of command arguments (displayed by /help command) : long description of command arguments (displayed by /help command) : template for completion, like "abc|%w def|%i" which means "abc" or a WeeChat command for first argument, "def" or IRC command for second. (see ) Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_command_handler("command", "my_command"); sub my_command { weechat::print("server= $_[0], args: $_[1]"); return weechat::PLUGIN_RC_OK; } # python weechat.add_command_handler("command", "my_command") def my_command(server, args): weechat.prnt("server="+server+", args="+args) return weechat.PLUGIN_RC_OK # ruby Weechat.add_command_handler("command", "my_command") def my_command(server, args) Weechat.print("server=#{server}, args=#{args}") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_command_handler("command", "my_command") def my_command(server, args) weechat.print("server="..server..", args="..args) return weechat.PLUGIN_RC_OK() end Notes: function called when command is executed has to return one of following values: PLUGIN_RC_KO : function failed PLUGIN_RC_OK : function successfully completed
add_timer_handler Perl prototype: weechat::add_timer_handler(interval, function); Python prototype: weechat.add_timer_handler(interval, function) Ruby prototype: Weechat.add_timer_handler(interval, function) Lua prototype: weechat.add_timer_handler(interval, function) Add a timer handler which periodically calls a function. Arguments: : interval (in seconds) between two calls of function. : function called Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_timer_handler(60, "my_timer"); sub my_timer { weechat::print("this is timer handler"); return weechat::PLUGIN_RC_OK; } # python weechat.add_timer_handler(60, "my_timer") def my_timer(): weechat.prnt("this is timer handler") return weechat.PLUGIN_RC_OK # ruby Weechat.add_timer_handler(60, "my_timer") def my_timer() Weechat.print("this is timer handler") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_timer_handler(60, "my_timer") function my_timer() weechat.print("this is timer handler") return weechat.PLUGIN_RC_OK() end Note: function called has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed
add_keyboard_handler Perl prototype: weechat::add_keyboard_handler(function); Python prototype: weechat.add_keyboard_handler(function) Ruby prototype: Weechat.add_keyboard_handler(function) Lua prototype: weechat.add_keyboard_handler(function) Add a keyboard handler, called for any key pressed. Arguments: : function called Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_keyboard_handler("my_keyboard"); sub my_keyboard { my $key = shift; my $input_before = shift; my $input_after = shift; weechat::print("keyboard handler: key = '$key', " ."input before = '$input_before' " ."after = '$input_after'"); return weechat::PLUGIN_RC_OK; } # python weechat.add_keyboard_handler("my_keyboard") def my_keyboard(key, input_before, input_after): weechat.prnt("keyboard handler: key = '%s', " \ "input before = '%s' after = '%s'" %(key, input_before, input_after)) return weechat.PLUGIN_RC_OK # ruby Weechat.add_keyboard_handler("my_keyboard") def my_keyboard(key, input_before, input_after) Weechat.print("keyboard handler: key = '#{key}', " \ "input before = '#{input_before}' " \ "after = '#{input_after}'") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_keyboard_handler("my_keyboard") function my_keyboard(key, input_before, input_after) weechat.print("keyboard handler: key = '"..key.. "', input before = '"..input_before.. "' after = '"..input_after.."'") return weechat.PLUGIN_RC_OK() end Note: function called has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed
add_event_handler Perl prototype: weechat::add_event_handler(event, function); Python prototype: weechat.add_event_handler(event, function) Ruby prototype: Weechat.add_event_handler(event, function) Lua prototype: weechat.add_event_handler(event, function) Add an event handler, called when an event happens. Arguments: : event (see ) : function called Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_event_handler("buffer_open", "my_event"); sub my_event { weechat::print("buffer open"); return weechat::PLUGIN_RC_OK; } # python weechat.add_event_handler("buffer_open", "my_event") def my_event(): weechat.prnt("buffer open") return weechat.PLUGIN_RC_OK # ruby Weechat.add_event_handler("buffer_open", "my_event") def my_event() Weechat.print("buffer open") return Weechat::PLUGIN_RC_OK end -- lua weechat.add_event_handler("buffer_open", "my_event") function my_event() weechat.print("buffer open") return weechat.PLUGIN_RC_OK() end Note: function called has to return one of following values: PLUGIN_RC_KO: function failed PLUGIN_RC_OK: function successfully completed
remove_handler Perl prototype: weechat::remove_handler(name, function); Python prototype: weechat.remove_handler(name, function) Ruby prototype: Weechat.remove_handler(name, function) Lua prototype: weechat.remove_handler(name, function) Remove a message or command handler. Arguments: : name of IRC message or command : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_handler("command", "my_command"); # python weechat.remove_handler("command", "my_command") # ruby Weechat.remove_handler("command", "my_command") -- lua weechat.remove_handler("command", "my_command")
remove_timer_handler Perl prototype: weechat::remove_timer_handler(function); Python prototype: weechat.remove_timer_handler(function) Ruby prototype: Weechat.remove_timer_handler(function) Lua prototype: weechat.remove_timer_handler(function) Remove a timer handler. Arguments: : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_timer_handler("my_timer"); # python weechat.remove_timer_handler("my_timer") # ruby Weechat.remove_timer_handler("my_timer") -- lua weechat.remove_timer_handler("my_timer")
remove_keyboard_handler Perl prototype: weechat::remove_keyboard_handler(function); Python prototype: weechat.remove_keyboard_handler(function) Ruby prototype: Weechat.remove_keyboard_handler(function) Lua prototype: weechat.remove_keyboard_handler(function) Remove a keyboard handler. Arguments: : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_keyboard_handler("my_keyboard"); # python weechat.remove_keyboard_handler("my_keyboard") # ruby Weechat.remove_keyboard_handler("my_keyboard") -- lua weechat.remove_keyboard_handler("my_keyboard")
remove_event_handler Perl prototype: weechat::remove_event_handler(function); Python prototype: weechat.remove_event_handler(function) Ruby prototype: Weechat.remove_event_handler(function) Lua prototype: weechat.remove_event_handler(function) Remove an event handler. Arguments: : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_event_handler("my_event"); # python weechat.remove_event_handler("my_event") # ruby Weechat.remove_event_handler("my_event") -- lua weechat.remove_event_handler("my_event")
add_modifier Perl prototype: weechat::add_modifier(type, message, function); Python prototype: weechat.add_modifier(type, message, function) Ruby prototype: Weechat.add_modifier(type, message, function) Lua prototype: weechat.add_modifier(type, message, function) Add a message modifier. Arguments: : modifier type: Type Description irc_in called for incoming IRC messages irc_user called for each user message (or command) (before WeeChat parses message) irc_out called for outgoing messages, immediately before sending it to IRC server (this includes messages sent automatically by WeeChat to server) : name of IRC message (used only for types "irc_in" and "irc_out"). To know list of IRC messages, please consult RFCs 1459 and 2812. Moreover, special value "*" means all messages (no filter). : function called Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::add_modifier("irc_in", "privmsg", "mod_in"); weechat::add_modifier("irc_out", "privmsg", "mod_out"); sub mod_in { return "$_[1] [modifier IN]"; } sub mod_out { return "$_[1] [modifier OUT]"; } # python weechat.add_modifier("irc_in", "privmsg", "mod_in") weechat.add_modifier("irc_out", "privmsg", "mod_out") def mod_in(serveur, args): return args + " [modifier IN]" def mod_out(serveur, args): return args + " [modifier OUT]" # ruby Weechat.add_modifier("irc_in", "privmsg", "mod_in") Weechat.add_modifier("irc_out", "privmsg", "mod_out") def mod_in(server, args) return args + " [modifier IN]" end def mod_out(server, args) return args + " [modifier OUT]" end -- lua weechat.add_modifier("irc_in", "privmsg", "mod_in") weechat.add_modifier("irc_out", "privmsg", "mod_out") function mod_in(server, args) return args .. " [modifier IN]" end function mod_out(server, args) return args .. " [modifier OUT]" end
remove_modifier Perl prototype: weechat::remove_modifier(type, message, function); Python prototype: weechat.remove_modifier(type, message, function) Ruby prototype: Weechat.remove_modifier(type, message, function) Lua prototype: weechat.remove_modifier(type, message, function) Remove a message modifier. Arguments: : modifier type : message managed by modifier : function Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::remove_modifier("irc_in", "privmsg", "mod_in"); # python weechat.remove_modifier("irc_in", "privmsg", "mod_in") # ruby Weechat.remove_modifier("irc_in", "privmsg", "mod_in") -- lua weechat.remove_modifier("irc_in", "privmsg", "mod_in")
command Perl prototype: weechat::command(command, [channel, [server]]); Python prototype: weechat.command(command, [channel, [server]]) Ruby prototype: Weechat.command(command, [channel, [server]]) Lua prototype: weechat.command(command, [channel, [server]]) Execute a WeeChat command (or send a message to a channel). Arguments: : command : name of channel for executing command : internal name of server for executing command Return value: 1 if success, 0 if an error occurred. Examples: # perl weechat::command("hello everybody!"); weechat::command("/kick toto please leave this channel", "#weechat"); weechat::command("/nick newnick", "", "freenode"); # python weechat.command("hello everybody!") weechat.command("/kick toto please leave this channel", "#weechat") weechat.command("/nick newnick", "", "freenode") # ruby Weechat.command("hello everybody!") Weechat.command("/kick toto please leave this channel", "#weechat") Weechat.command("/nick newnick", "", "freenode") -- lua weechat.command("hello everybody!") weechat.command("/kick toto please leave this channel", "#weechat") weechat.command("/nick newnick", "", "freenode")
get_info Perl prototype: weechat::get_info(name, [server]); Python prototype: weechat.get_info(name, [server]) Ruby prototype: Weechat.get_info(name, [server]) Lua prototype: weechat.get_info(name, [server]) Return an info about WeeChat or a channel. Arguments: : name of info to read (see ) : internal name of server for reading info (if needed) Return value: information asked, empty string if an error occurred. Examples: # perl $version = get_info("version"); $nick = get_info("nick", "freenode"); # python version = weechat.get_info("version") nick = weechat.get_info("nick", "freenode") # ruby version = Weechat.get_info("version") nick = Weechat.get_info("nick", "freenode") -- lua version = weechat.get_info("version") nick = weechat.get_info("nick", "freenode")
get_dcc_info Perl prototype: weechat::get_dcc_info(); Python prototype: weechat.get_dcc_info() Ruby prototype: Weechat.get_dcc_info() Lua prototype: weechat.get_dcc_info() Return list of DCC currently active or finished. Return value: list of DCC (see ). Examples: # perl my @dccs = weechat::get_dcc_info(); if (@dccs) { foreach my $dcc (@dccs) { while (my ($key, $value) = each %$dcc) { weechat::print("$key = '$value'"); } } } else { weechat::print("no DCC"); } # python dccs = weechat.get_dcc_info() if dccs != None: if dccs == []: weechat.prnt("no DCC") else: for d in dccs: for b in d.keys(): weechat.prnt("%s = '%s'" %(b, d[b])) else: weechat.prnt("error while getting DCC") # ruby dccs = Weechat.get_dcc_info() if dccs != nil if dccs == [] Weechat.print("no DCC") else dccs.each do |m| m.each do |key, value| Weechat.print("#{key} = '#{value}'") end end end else Weechat.print("error while getting DCC") end -- lua dccs = weechat.get_dcc_info() if dccs ~= nil then if dccs then dcc, dccinfos = next (dccs, nil) while (dcc) do key, value = next (dccinfos, nil) while (key) do weechat.print(key.." = '"..value.."'") key, value = next (dccinfos, key) end dcc, dccinfos = next (dccs, dcc) end else weechat.print("no DCC") end else weechat.print("error while getting DCC") end
get_server_info Perl prototype: weechat::get_server_info(); Python prototype: weechat.get_server_info() Ruby prototype: Weechat.get_server_info() Lua prototype: weechat.get_server_info() Return list of IRC servers (connected or not). Return value: list of servers (see ). Examples: # perl my $servers = weechat::get_server_info(); if ($servers) { while (my ($srvname, $srvinfos) = each %$servers) { while ( my ($key, $value) = each %$srvinfos) { weechat::print("$srvname -> $key = '$value'"); } } } else { weechat::print("no server"); } # python servers = weechat.get_server_info() if servers != None: if servers == {}: weechat.prnt("no server") else: for s in servers: for i in servers[s]: weechat.prnt("%s -> %s = '%s'" % (s, i, str(servers[s][i]))) else: weechat.prnt("error while getting servers") # ruby servers = Weechat.get_server_info() if servers != nil if servers == [] Weechat.print("no server") else servers.each do |n, s| s.each do |key, value| Weechat.print("#{n} -> #{key} = '#{value}'") end end end else Weechat.print("error while getting servers") end -- lua servers = weechat.get_server_info() if servers ~= nil then if servers then srv, srvinfos = next (servers, nil) while (srv) do key, value = next (srvinfos, nil) while (key) do weechat.print(srv.." -> "..key.." = '"..value.."'") key, value = next (srvinfos, key) end srv, srvinfos = next (servers, srv) end else weechat.print("no server") end else weechat.print("error while getting servers") end
get_channel_info Perl prototype: weechat::get_channel_info(server); Python prototype: weechat.get_channel_info(server) Ruby prototype: Weechat.get_channel_info(server) Lua prototype: weechat.get_channel_info(server) Return list of IRC channels for a server. Return value: list of IRC channels for server (see ). Examples: # perl my $channels = weechat::get_channel_info(weechat::get_info("server")); if ($channels) { while (my ($channame, $chaninfos) = each %$channels) { while (my ($key, $value) = each %$chaninfos) { weechat::print("$channame -> $key = '$value'"); } } } else { weechat::print("no channel"); } # python chans = weechat.get_channel_info(weechat.get_info("server")) if chans != None: if chans == {}: weechat.prnt("no channel") else: for s in chans: for i in chans[s]: weechat.prnt("%s -> %s = '%s'" % (s, i, str(chans[s][i]))) else: weechat.prnt("error while getting channels") # ruby channels = Weechat.get_channel_info(Weechat.get_info("server")) if channels != nil if channels == {} Weechat.print("no channel") else channels.each do |n, c| c.each do |key, value| Weechat.print("#{n} -> #{key} = '#{value}'") end end end else Weechat.print("error while getting channels") end -- lua chans = weechat.get_channel_info(weechat.get_info("server")) if chans ~= nil then if chans then chan, chaninfos = next (chans, nil) while (chan) do key, value = next (chaninfos, nil) while (key) do weechat.print(chan.." -> "..key.." = '"..value.."'") key, value = next (chaninfos, key) end chan, chaninfos = next (chans, chan) end else weechat.print("no channel") end else weechat.print("error while getting channels") end
get_nick_info Perl prototype: weechat::get_nick_info(server, channel); Python prototype: weechat.get_nick_info(server, channel) Ruby prototype: Weechat.get_nick_info(server, channel) Lua prototype: weechat.get_nick_info(server, channel) Return list of nicks for a channel. Return value: list of nicks on channel (see ). Examples: # perl my $nicks = weechat::get_nick_info("freenode", "#weechat"); if ($nicks) { while (my ($nickname, $nickinfos) = each %$nicks) { while ( my ($key, $value) = each %$nickinfos) { weechat::print("$nickname -> $key = '$value'"); } } } else { weechat::print("no nick"); } # python nicks = weechat.get_nick_info("freenode", "#weechat") if nicks != None: if nicks == {}: weechat.prnt("no nick") else: for n in nicks: for f in nicks[n]: weechat.prnt("%s -> %s = '%s'" % (n, f, str(nicks[n][f]))) else: weechat.prnt("error while getting nicks") # ruby nicks = Weechat.get_nick_info("freenode", "#weechat") if nicks != nil if nicks == {} Weechat.print("no nick") else nicks.each do |nk, nattr| nattr.each do |key, value| Weechat.print("#{nk} -> #{key} = '#{value}'") end end end else Weechat.print("error while getting nicks") end -- lua nicks = weechat.get_nick_info("freenode", "#weechat") if nicks ~= nil then if nicks then nick, nickinfos = next (nicks, nil) while (nick) do key, value = next (nickinfos, nil) while (key) do weechat.print(nick.." -> "..key.." = '"..value.."'") key, value = next (nickinfos, key) end nick, nickinfos = next (nicks, nick) end else weechat.print("no nick") end else weechat.print("error while getting nicks") end
get_config Perl prototype: weechat::get_config(option); Python prototype: weechat.get_config(option) Ruby prototype: Weechat.get_config(option) Lua prototype: weechat.get_config(option) Return value of a WeeChat config option. Arguments: : name of option to read Return value: option value, empty string if not found. Examples: # perl $value1 = weechat::get_config("look_nicklist"); $value2 = weechat::get_config("freenode.server_autojoin"); # python value1 = weechat.get_config("look_nicklist") value2 = weechat.get_config("freenode.server_autojoin") # ruby value1 = Weechat.get_config("look_nicklist") value2 = Weechat.get_config("freenode.server_autojoin") -- lua value1 = weechat.get_config("look_nicklist") value2 = weechat.get_config("freenode.server_autojoin")
set_config Perl prototype: weechat::set_config(option, value); Python prototype: weechat.set_config(option, value) Ruby prototype: Weechat.set_config(option, value) Lua prototype: weechat.set_config(option, value) Update value of a WeeChat config option. Arguments: : name of option to update : new value for option Return value: 1 if option was successfully updated, 0 if an error occurred. Examples: # perl weechat::set_config("look_nicklist", "off"); weechat::set_config("freenode.server_autojoin", "#weechat"); # python weechat.set_config("look_nicklist", "off") weechat.set_config("freenode.server_autojoin", "#weechat") # ruby Weechat.set_config("look_nicklist", "off") Weechat.set_config("freenode.server_autojoin", "#weechat") -- lua weechat.set_config("look_nicklist", "off") weechat.set_config("freenode.server_autojoin", "#weechat")
get_plugin_config Perl prototype: weechat::get_plugin_config(option); Python prototype: weechat.get_plugin_config(option) Ruby prototype: Weechat.get_plugin_config(option) Lua prototype: weechat.get_plugin_config(option) Return value of a plugin option. Option is read from file "~/.weechat/plugins.rc" and is like: "plugin.option=value" (note: plugin name is automatically added). Arguments: : name of option to read Return value: value of option, empty string if not found. Examples : # perl $value = weechat::get_plugin_config("my_var"); # python value = weechat.get_plugin_config("my_var") # ruby value = Weechat.get_plugin_config("my_var") -- lua value = weechat.get_plugin_config("my_var")
set_plugin_config Perl prototype: weechat::set_plugin_config(option, value); Python prototype: weechat.set_plugin_config(option, value) Ruby prototype: Weechat.set_plugin_config(option, value) Lua prototype: weechat.set_plugin_config(option, value) Update value of a plugin option. Option is written in file "~/.weechat/plugins.rc" and is like: "plugin.option=value" (note: plugin name is automatically added). Arguments: : name of option to update : new value for option Return value: 1 if option was successfully updated, 0 if an error occurred. Examples: # perl weechat::set_plugin_config("my_var", "value"); # python weechat.set_plugin_config("my_var", "value") # ruby Weechat.set_plugin_config("my_var", "value") -- lua weechat.set_plugin_config("my_var", "value")
get_irc_color Perl prototype: weechat::get_irc_color(color); Python prototype: weechat.get_irc_color(color) Ruby prototype: Weechat.get_irc_color(color) Lua prototype: weechat.get_irc_color(color) Return IRC color index with name. Return value: IRC color index, -1 if color is not found (see ). Examples: # perl my $color_blue = weechat::get_irc_color("blue"); # python color_blue = weechat.get_irc_color("blue") # ruby color_blue = Weechat.get_irc_color("blue") -- lua color_blue = weechat.get_irc_color("blue")
input_color Perl prototype: weechat::input_color(color); Python prototype: weechat.input_color(color) Ruby prototype: Weechat.input_color(color) Lua prototype: weechat.input_color(color) Add color in input buffer. Return value: none. Examples: # perl weechat::input_color(weechat::get_irc_color("blue"), 10, 5); # python weechat.input_color(weechat.get_irc_color("blue"), 10, 5) # ruby Weechat.input_color(Weechat.get_irc_color("blue"), 10, 5) -- lua weechat.input_color(weechat.get_irc_color("blue"), 10, 5)
get_window_info Perl prototype: weechat::get_window_info(); Python prototype: weechat.get_window_info() Ruby prototype: Weechat.get_window_info() Lua prototype: weechat.get_window_info() Return list of WeeChat windows. Return value: list of WeeChat windows (see ). Examples: # perl my @wf = weechat::get_window_info(); if (@wf) { weechat::print("**** windows infos ****"); foreach my $w (@wf) { while ( my ($key, $value) = each %$w) { weechat::print(" > $key => $value"); } weechat::print("----------------------"); } } else { weechat::print("**** no window info ****"); } # python wf = weechat.get_window_info() if wf != None and wf != []: weechat.prnt ("**** windows infos ****") for w in wf: for i in w: weechat.prnt (" > %s => %s" % (i, w[i])) weechat.prnt ("----------------------") else: weechat.prnt ("**** no window info ****") # ruby wf = Weechat.get_window_info() if wf != nil and wf != [] Weechat.print("**** windows infos ****") wf.each do |w| w.each do |key, value| Weechat.print(" > #{key} => #{value}") end Weechat.print("----------------------") end else Weechat.print("**** no window info ****") end -- lua wf = weechat.get_window_info() if wf then weechat.print ("**** windows infos ****") w, winfos = next (wf, nil) while (w) do key, value = next (winfos, nil) while (key) do weechat.print(" > " .. key .. " => " .. value) key, value = next (winfos, key) end weechat.print ("----------------------") w, winfos = next (wf, w) end else weechat.print("**** no window info ****") end
get_buffer_info Perl prototype: weechat::get_buffer_info(); Python prototype: weechat.get_buffer_info() Ruby prototype: Weechat.get_buffer_info() Lua prototype: weechat.get_buffer_info() Return list of WeeChat buffers. Return value: list of WeeChat buffers (see ). Examples: # perl my $bf = weechat::get_buffer_info(); if ($bf) { while ( my ($nobuf, $binfos) = each %$bf) { while ( my ($key, $value) = each %$binfos) { weechat::print(" > $key => $value"); } weechat::print("----------------------"); } } else { weechat::print("**** no buffer info ****"); } # python bf = weechat.get_buffer_info() if bf != None and bf != {}: for b in bf: weechat.prnt ("**** info for buffer no %d ****" % b) for c in bf[b]: weechat.prnt (" > %s => %s" % (c, bf[b][c])) weechat.prnt ("----------------------") else: weechat.prnt ("**** no buffer info ****") # ruby bf = Weechat.get_buffer_info() if bf != nil and bf != {} bf.each do |n, c| Weechat.print("**** info for buffer no #{n} ****") c.each do |key, value| Weechat.print(" > #{key} => #{value}") end Weechat.print("----------------------") end else Weechat.print("**** no buffer info ****") end -- lua bf = weechat.get_buffer_info() if bf then b, binfos = next (bf, nil) while (b) do weechat.print("**** info for buffer no " .. b .. " ****") key, value = next (binfos, nil) while (key) do weechat.print(" > " .. key .. " => " .. value) key, value = next (binfos, key) end weechat.print ("----------------------") b, infos = next (bf, b) end else weechat.print("**** no buffer info ****") end
get_buffer_data Perl prototype: weechat::get_buffer_data(server, channel); Python prototype: weechat.get_buffer_data(server, channel) Ruby prototype: Weechat.get_buffer_data(server, channel) Lua prototype: weechat.get_buffer_data(server, channel) Return content of buffer. Return value: list of lines for buffer (see ). Examples: # perl my $server = weechat::get_info("server"); my $channel = weechat::get_info("channel"); my @bc = weechat::get_buffer_data($server, $channel); if (@bc) { weechat::print("**** buffer data for '$channel'\@'$server' ****"); foreach my $l (@bc) { while ( my ($key, $value) = each %$l) { weechat::print(" > $key => $value"); } weechat::print("----------------------"); } } else { weechat::print("**** no buffer data ****"); } # python server = weechat.get_info("server") channel = weechat.get_info("channel") bc = weechat.get_buffer_data(server, channel) if bc != None and bc != []: weechat.prnt ("**** buffer data for '%s'@'%s' ****" % (channel, server)) for l in bc: for i in l: weechat.prnt (" > %s => %s" % (i, l[i])) weechat.prnt ("----------------------") else: weechat.prnt ("**** no buffer data ****") # ruby server = Weechat.get_info("server") channel = Weechat.get_info("channel") bc = Weechat.get_buffer_data(server, channel) if bc != nil and bc != [] Weechat.print("**** buffer data for '#{channel}'@'#{server}' ****") bc.each do |l| l.each do |key, value| Weechat.print(" > #{key} => #{value}") end Weechat.print("----------------------") end else Weechat.print("**** no buffer data ****") end -- lua server = weechat.get_info("server") channel = weechat.get_info("channel") bc = weechat.get_buffer_data(server, channel) if bc then b, bdatas = next (bc, nil) weechat.print("**** buffer data for '" .. channel .. "'@'" .. server .. "' ****") while (b) do key, value = next (bdatas, nil) while (key) do weechat.print(" > " .. key .. " => " .. value) key, value = next (bdatas, key) end weechat.print ("----------------------") b, bdatas = next (bc, b) end else weechat.print("**** no buffer data ****") end