Syntax by language

Perl
Python
Ruby
Lua

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