WeeChat 0.2.6 - User guide

Fast, light and extensible IRC client

Sébastien Helleu

This manual is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

2007-09-06 10:44:50

Abstract

This manual documents WeeChat IRC client, it is part of WeeChat.

Latest version of this document can be found on this page: http://weechat.flashtux.org/doc.php


Table of Contents

1. Introduction
Description
Pre-requisites
2. Installation
Binary packages
Source package
CVS sources
3. Usage
Running WeeChat
Key bindings
Command line
WeeChat / IRC commands
WeeChat commands
Key functions
IRC commands
Configuration file
FIFO pipe
4. Plugins
Plugins in WeeChat
Write a plugin
API functions
Compile plugin
Load plugin into WeeChat
Plugin example
Charset plugin
Settings
FAQ
Scripts plugins
Load / unload scripts
Syntax by language
WeeChat / scripts API
5. Authors / Support
Authors
Contributors
Get support

Chapter 1. Introduction

Table of Contents

Description
Pre-requisites

This chapter describes WeeChat and pre-requisites for its installation.

Description

WeeChat (Wee Enhanced Environment for Chat) is a free IRC client, fast and light, designed for many operating systems.

Main features are:

  • multi-servers connection (with SSL, IPv6, proxy)

  • many GUI: Curses, wxWidgets, Gtk and Qt

  • small, fast and light

  • customizable and extensible with plugins and scripts

  • compliant with RFCs 1459, 2810, 2811, 2812 and 2813

  • multi-platform (GNU/Linux, *BSD, MacOS X, Windows and other)

  • 100% GPL, free software

WeeChat homepage is here: http://weechat.flashtux.org

Pre-requisites

In order to install WeeChat, you need:

  • a running GNU/Linux system (with compiler tools for source package)

  • "root" privileges (to install WeeChat)

  • according to GUI, one of the following libraries:

    • Curses: ncurses library

    • Gtk: *** GUI not developed ***

    • WxWidgets: *** GUI not developed ***

    • Qt: *** GUI not developed ***

Chapter 2. Installation

This chapter explains how to install WeeChat.

Binary packages

Binary packages are available for these distributions:

  • Debian (or any Debian compatible distribution): apt-get install weechat

  • Mandriva/RedHat (or any RPM compatible distribution): rpm -i /chemin/weechat-x.y.z-1.i386.rpm

  • Gentoo : emerge weechat

For other distributions, please look at your manual for installation instructions.

Source package

All you have to do is to run in a console or a terminal:

$ ./configure
$ make

Then get root privileges and install WeeChat:

$ su
(enter root password)
# make install

CVS sources

Warning: CVS sources are for advanced users: it may not compile or not be stable. You're warned!

To get CVS sources, issue this command:

$ cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/weechat co weechat

Execute this script: ./autogen.sh

Then follow instructions for source package (see the section called “Source package”)

Chapter 3. Usage

This chapter explains how to run WeeChat, the default key bindings used, internal and IRC commands, setup file, and FIFO pipe use.

Running WeeChat

Command line arguments:

Parameter Description
-a, --no-connect Disable auto-connect to servers at startup
-c, --config Display config help (list of options)
-d, --dir <path> Set path as home for WeeChat (used for configuration files, logs, user plugins and scripts). Default value is "~/.weechat". Please note that directory is created if not found by WeeChat.
-f, --key-functions Display WeeChat internal functions for keys
-h, --help Display help
-i, --irc-commands Display IRC commands list
-k, --keys Display WeeChat default keys
-l, --license Display WeeChat license
-p, --no-plugin Disable plugins auto-load
-v, --version Display WeeChat version
-w, --weechat-commands Display WeeChat commands list

It is also possible to give URL for one or many IRC servers, as follow:

irc[6][s]://[pseudo[:mot_passe]@]irc.example.org[:port][/channel][,channel[...]

Example to join #weechat and #toto on "irc.freenode.net" server, default port (6667), with "nono" nick:

$ weechat-curses irc://nono@irc.freenode.net/#weechat,#toto

To start WeeChat, issue this command:

  • for Curses GUI: weechat-curses

  • for Gtk GUI: weechat-gtk

  • for wxWidgets GUI: weechat-wxwidgets

  • for Qt GUI: weechat-qt

When you run WeeChat for the first time, a default configuration file is created, with default options. The default configuration file is: "~/.weechat/weechat.rc"

You can edit this file at your convenience to configure WeeChat (ONLY if WeeChat is not running), or you can set parameters with "/set" command in WeeChat (see the section called “WeeChat commands”)

Key bindings

Key Action
Left arrow / Ctrl + B Go to previous char in command line
Right arrow / Ctrl + F Go to next char in command line
Ctrl + left arrow Go to previous word in command line
Ctrl + right arrow Go to next word in command line
Home / Ctrl + A Go to the beginning of command line
Ctrl + C then B Insert code for bold text.
Ctrl + C then C Insert code for colored text.
Ctrl + C then O Insert code for color reset.
Ctrl + C then R Insert code for reverse color.
Ctrl + C then U Insert code for underlined text.
End / Ctrl + E Go to the end of command line
Ctrl + K Delete from cursor until end of command line
Ctrl + L Redraw whole window
Ctrl + R Search for text in buffer history (two times: search exact text)
Ctrl + S then Ctrl + U Set unread marker on all buffers
Ctrl + T Transpose chars
Ctrl + U Delete from cursor until beginning of command line
Ctrl + W Delete previous word of command line
Ctrl + Y Paste clipboard content
Backspace / Ctrl + H Delete previous char in command line
Delete / Ctrl + D Delete next char in command line
Tab / Shift + Tab Complete command or nick (Tab again: find next completion)
Any char Insert char at cursor position in command line
Enter / Ctrl + J / Ctrl + M Execute command or send message (in search mode: stop search)
Up arrow / Down arrow Call again last commands/messages (in search mode: search up/down)
Ctrl + up arrow / Ctrl + down arrow Call again last commands/messages in global history (common for all buffers)
PageUp / PageDown Scroll up / down one page in buffer history
Alt + PageUp / Alt + PageDown Scroll up / down a few lines in buffer history
Alt + Home / Alt + End Scroll to top / bottom of buffer
F5 / Alt + left arrow Switch to previous buffer
F6 / Alt + right arrow Switch to next buffer
F7 Switch to previous window
F8 Switch to next window
F9 / F10 Scroll topic
F11 / F12 Scroll nicklist
Alt + F11 / Alt + F12 Go to the beginning / the end of nicklist
Alt + A Switch to next buffer with activity (with priority: highlight, message, other)
Alt + B Go to previous word in command line
Alt + D Delete next word in command line
Alt + F Go to next word in command line
Alt + H Clear hotlist (activity notification on other buffers)
Alt + I Remove last infobar message
Alt + J then Alt + D Display DCC buffer
Alt + J then Alt + L Switch to last buffer
Alt + J then Alt + P Switch to buffer previously displayed
Alt + J then Alt + R Switch to raw IRC data buffer
Alt + J then Alt + S Switch to server buffer
Alt + J then Alt + X Switch to first channel of next server (or server buffer if no channel is opened)
Alt + digit (0-9) Switch to buffer by number (0 = 10)
Alt + J then number (01-99) Switch to buffer by number
Alt + K Grab a key and insert its code in command line
Alt + N Scroll to next highlight
Alt + P Scroll to previous highlight
Alt + R Delete entire command line
Alt + S Switch servers on servers buffer (if option "look_one_server_buffer" is enabled)
Alt + U Scroll to first unread line in buffer
Alt + W then Alt + arrow Switch to window with direction

Command line

WeeChat command line (at the bottom of window) lets you send text on channels and execute WeeChat or IRC commands (see the section called “WeeChat / IRC commands”).

Commands begin with "/" char, followed by name of command. For example, to initiate a private chat with "toto":

/query toto

Text sent to a channel is any text that does not begin with "/" char. For example, to send text "hello" on current channel:

hello

However, it is possible to start with "/" char, by adding another. For example, to send text "/query toto" on current channel:

//query toto

If option for sending IRC colors ("irc_colors_send") is enabled, you can use color codes and attributes, as follow (press Ctrl-C then following letter, with optional value):

Code Description
^Cb bold text
^Ccxx text color "xx" (see colors table below)
^Ccxx,yy text color "xx" and background "yy" (see colors table below)
^Co disable color and attributes
^Cr reverse video (revert text color with background)
^Cu underlined text

Note: the same code (without number for ^Cc) may be used to stop the attribute.

Color codes for ^Cc are:

Code Color
00 white
01 black
02 dark blue
03 dark green
04 light red
05 dark red
06 magenta
07 orange
08 yellow
09 light green
10 cyan
11 light cyan
12 light blue
13 light magenta
14 gray
15 light gray (white)

Example: display of "hello everybody!" with "hello" in light blue bold, and "everybody" in light red underlined:

^Cc12^Cbhello^Cb^Cc04^Cu everybody^Cu^Cc!

WeeChat / IRC commands

This chapter lists all WeeChat and IRC commands.

WeeChat commands

alias [alias_name [command [arguments]]]

create an alias for a command

alias_name: name of alias
   command: command name (WeeChat or IRC command, many commands can be separated by semicolons)
 arguments: arguments for command

is replaced by all arguments.

Variables $nick, $channel and $server are replaced by current nick/channel/server.

buffer [action [args] | number | [[server] [channel]]]

manage buffers

 action: action to do:
   move: move buffer in the list (may be relative, for example -1)
  close: close buffer (optional arg is part message, for a channel)
   list: list open buffers (no parameter implies this list)
 notify: set notify level for buffer (0=never, 1=highlight, 2=1+msg, 3=2+join/part)
         (when executed on server buffer, this sets default notify level for whole server)
 scroll: scroll in history (may be relative, and may end by a letter: s=sec, m=min, h=hour, d=day, M=month, y=year); if there is only letter, then scroll to beginning of this item

 number: jump to buffer by number
server,
channel: jump to buffer by server and/or channel name

Examples:
        move buffer: /buffer move 5
       close buffer: /buffer close this is part msg
         set notify: /buffer notify 2
    scroll 1 day up: /buffer scroll 1d  ==  /buffer scroll -1d  ==  /buffer scroll -24h
scroll to beginning
        of this day: /buffer scroll d
 scroll 15 min down: /buffer scroll +15m
  scroll 20 msgs up: /buffer scroll -20
   jump to #weechat: /buffer #weechat

builtin command

launch WeeChat/IRC builtin command (do not look at plugins handlers or aliases)

command: command to execute (a '/' is automatically added if not found at beginning of command)


clear [-all | number [number ...]]

clear window(s)

  -all: clear all buffers
number: clear buffer by number

connect [-all [-nojoin] | servername [servername ...] [-nojoin] | hostname [-port port] [-ipv6] [-ssl]]

connect to server(s)

      -all: connect to all servers
servername: internal server name to connect
   -nojoin: do not join any channel (even if autojoin is enabled on server)
  hostname: hostname to connect, creating temporary server
      port: port for server (integer, default is 6667)
      ipv6: use IPv6 protocol
       ssl: use SSL protocol

disconnect [-all | servername [servername ...]]

disconnect from server(s)

      -all: disconnect from all servers
servername: server name to disconnect

dcc action [nickname [file]]

starts DCC (file or chat) or close chat

  action: 'send' (file) or 'chat' or 'close' (chat)
nickname: nickname to send file or chat
    file: filename (on local host)

debug dump | buffer | windows

print debug messages

   dump: save memory dump in WeeChat log file (same dump is written when WeeChat crashes)
 buffer: dump buffer content with hexadecimal values in log file
windows: display windows tree

help [command]

display help about commands

command: name of a WeeChat or IRC command

history [clear | value]

show buffer command history

clear: clear history
value: number of history entries to show

ignore [mask [[type | command] [channel [server]]]]

ignore IRC messages and/or hosts

   mask: nick or host mask to ignore
   type: type of message to ignore (action, ctcp, dcc, pv)
command: IRC command
channel: name of channel for ignore
 server: name of server for ignore

For each argument, '*' means all.
Without argument, /ignore command lists all defined ignore.

key [key [function/command]] [unbind key] [functions] [call function ["args"]] [reset -yes]

bind/unbind keys

      key: display or bind this key to an internal function or a command (beginning by "/")
   unbind: unbind a key
functions: list internal functions for key bindings
     call: call a function by name (with optional arguments)
    reset: restore bindings to the default values and delete ALL personal bindings (use carefully!)

plugin [list [name]] | [listfull [name]] | [load filename] | [autoload] | [reload [name]] | [unload [name]]

list/load/unload plugins

    list: list loaded plugins
listfull: list loaded plugins with detailed info for each plugin
    load: load a plugin
autoload: autoload plugins in system or user directory
  reload: reload one plugin (if no name given, unload all plugins, then autoload plugins)
  unload: unload one or all plugins

Without argument, /plugin command lists loaded plugins.

reconnect [-all [-nojoin] | servername [servername ...] [-nojoin]]

reconnect to server(s)

      -all: reconnect to all servers
servername: server name to reconnect
   -nojoin: do not join any channel (even if autojoin is enabled on server)

save [file]

save config to disk

file: filename for writing config

server [list [servername]] | [listfull [servername]] | [add servername hostname [-port port] [-temp] [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [copy servername newservername] | [rename servername newservername] | [keep servername] | [del servername]

list, add or remove servers

      list: list servers (no parameter implies this list)
  listfull: list servers with detailed info for each server
       add: create a new server
servername: server name, for internal and display use
  hostname: name or IP address of server
      port: port for server (integer, default is 6667)
      temp: create temporary server (not saved in config file)
      auto: automatically connect to server when WeeChat starts
    noauto: do not connect to server when WeeChat starts (default)
      ipv6: use IPv6 protocol
       ssl: use SSL protocol
  password: password for server
     nick1: first nick for server
     nick2: alternate nick for server
     nick3: second alternate nick for server
  username: user name
  realname: real name of user
      copy: duplicate a server
    rename: rename a server
      keep: keep server in config file (for temporary servers only)
       del: delete a server
   deloutq: delete messages out queue for all servers (all messages WeeChat is currently sending)

set [option [ = value]]

set config options

option: name of an option (if name is full and no value is given, then help is displayed on option)
 value: value for option

Option may be: servername.server_xxx where "servername" is an internal server name and "xxx" an option for this server.

setp [option [ = value]]

set plugin config options

option: name of a plugin option
 value: value for option

Option is format: plugin.option, example: perl.myscript.item1

unalias alias_name

remove an alias

alias_name: name of alias to remove

unignore [number | [mask [[type | command] [channel [server]]]]]

unignore IRC messages and/or hosts

 number: # of ignore to unignore (number is displayed by list of ignore)
   mask: nick or host mask to unignore
   type: type of message to unignore (action, ctcp, dcc, pv)
command: IRC command
channel: name of channel for unignore
 server: name of server for unignore

For each argument, '*' means all.
Without argument, /unignore command lists all defined ignore.

upgrade [path_to_binary]

upgrade WeeChat without disconnecting from servers

path_to_binary: path to WeeChat binary (default is current binary)

This command run again a WeeChat binary, so it should have been compiled or installed with a package manager before running this command.

uptime [-o]

show WeeChat uptime

-o: send uptime on current channel as an IRC message

window [list | -1 | +1 | b# | up | down | left | right | splith [pct] | splitv [pct] | resize pct | merge [all]]

manage windows

  list: list open windows (no parameter implies this list)
    -1: jump to previous window
    +1: jump to next window
    b#: jump to next window displaying buffer number #
    up: switch to window above current one
  down: switch to window below current one
  left: switch to window on the left
 right: switch to window on the right
splith: split current window horizontally
splitv: split current window vertically
resize: resize window size, new size is <pct> pourcentage of parent window
 merge: merge window with another (all = keep only one window)

For splith and splitv, pct is a pourcentage which represents size of new window, computed with current window as size reference. For example 25 means create a new window with size = current_size / 4

Key functions

Function Description
return terminate line
tab complete word
tab_previous find previous completion for word
backspace delete previous char
delete delete next char
delete_end_line delete until end of line
delete_beginning_line delete until beginning of line
delete_line delete entire line
delete_previous_word delete previous word
delete_next_word delete next word
clipboard_paste paste current clipboard content
transpose_chars transpose chars
home go to beginning of line
end go to end of line
left move one char left
previous_word move to previous word
right move one char right
next_word move to next word
up call previous command in history
up_global call previous command in global history
down call next command in history
down_global call next command in global history
page_up scroll one page up
page_down scroll one page down
scroll_up scroll a few lines up
scroll_down scroll a few lines down
scroll_top scroll to top of buffer
scroll_bottom scroll to bottom of buffer
scroll_topic_left scroll left topic
scroll_topic_right scroll right topic
nick_beginning display beginning of nicklist
nick_end display end of nicklist
nick_page_up scroll nicklist one page up
nick_page_down scroll nicklist one page down
jump_smart jump to buffer with activity
jump_dcc jump to DCC buffer
jump_raw_data jump to raw IRC data buffer
jump_last_buffer jump to last buffer
jump_previous_buffer jump to previous buffer
jump_server jump to server buffer
jump_next_server jump to next server
switch_server switch active server on servers buffer
scroll_previous_highlight scroll to previous highlight in buffer
scroll_next_highlight scroll to next highlight in buffer
scroll_unread scroll to first unread line in buffer
set_unread set unread marker on all buffers
hotlist_clear clear hotlist
infobar_clear clear infobar
refresh refresh screen
grab_key grab a key
insert insert a string in command line
search_text search text in buffer history

IRC commands

admin [target]

find information about the administrator of the server

target: server

ame message

send a CTCP action to all channels of all connected servers

message: message to send

amsg text

send message to all channels of all connected servers

text: text to send

away [-all] [message]

toggle away status

   -all: toggle away status on all connected servers
message: message for away (if no message is given, away status is removed)

ban [channel] [nickname [nickname ...]]

bans nicks or hosts

 channel: channel for ban
nickname: user or host to ban

ctcp receiver type [arguments]

send a CTCP message (Client-To-Client Protocol)

 receiver: nick or channel to send CTCP to
     type: CTCP type (examples: "version", "ping", ..)
arguments: arguments for CTCP

cycle [channel[,channel]] [part_message]

leave and rejoin a channel

     channel: channel name for cycle
part_message: part message (displayed to other users)

dehalfop [nickname [nickname]]

removes half channel operator status from nickname(s)

deop [nickname [nickname]]

removes channel operator status from nickname(s)

devoice [nickname [nickname]]

removes voice from nickname(s)

die

shutdown the server

halfop [nickname [nickname]]

gives half channel operator status to nickname(s)

info [target]

get information describing the server

target: server name

invite nickname channel

invite a nick on a channel

nickname: nick to invite
 channel: channel to invite

ison nickname [nickname ...]

check if a nickname is currently on IRC

nickname: nickname

join channel[,channel] [key[,key]]

join a channel

channel: channel name to join
    key: key to join the channel

kick [channel] nickname [comment]

forcibly remove a user from a channel

 channel: channel where user is
nickname: nickname to kick
 comment: comment for kick

kickban [channel] nickname [comment]

kicks and bans a nick from a channel

 channel: channel where user is
nickname: nickname to kick and ban
 comment: comment for kick

kill nickname comment

close client-server connection

nickname: nickname
 comment: comment for kill

links [[server] server_mask]

list all servernames which are known by the server answering the query

     server: this server should answer the query
server_mask: list of servers must match this mask

list [channel[,channel] [server]]

list channels and their topic

channel: channel to list (a regexp is allowed)
server: server name

lusers [mask [target]]

get statistics about the size of the IRC network

  mask: servers matching the mask only
target: server for forwarding request

me message

send a CTCP action to the current channel

message: message to send

mode { channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask] } | { nickname {[+|-]|i|w|s|o} }

change channel or user mode

channel modes:
  channel: channel name to modify
  o: give/take channel operator privileges
  p: private channel flag
  s: secret channel flag
  i: invite-only channel flag
  t: topic settable by channel operator only flag
  n: no messages to channel from clients on the outside
  m: moderated channel
  l: set the user limit to channel
  b: set a ban mask to keep users out
  e: set exception mask
  v: give/take the ability to speak on a moderated channel
  k: set a channel key (password)
user modes:
  nickname: nickname to modify
  i: mark a user as invisible
  s: mark a user for receive server notices
  w: user receives wallops
  o: operator flag

motd [target]

get the "Message Of The Day"

target: server name

msg receiver[,receiver] text

send message to a nick or channel

receiver: nick or channel (may be mask, '*' = current channel)
text: text to send

names [channel[,channel]]

list nicknames on channels

channel: channel name

nick [-all] nickname

change current nickname

    -all: set new nickname for all connected servers
nickname: new nickname

notice nickname text

send notice message to user

nickname: user to send notice to
    text: text to send

op nickname [nickname]

gives channel operator status to nickname(s)

oper user password

get operator privileges

user/password: used to get privileges on current IRC server

part [channel[,channel]] [part_message]

leave a channel

     channel: channel name to leave
part_message: part message (displayed to other users)

ping server1 [server2]

ping server

server1: server to ping
server2: forward ping to this server

pong daemon [daemon2]

answer to a ping message

 daemon: daemon who has responded to Ping message
daemon2: forward message to this daemon

query nickname [text]

send a private message to a nick

nickname: nickname for private conversation
    text: text to send

quit [quit_message]

close all connections and quit

quit_message: quit message (displayed to other users)

quote data

send raw data to server without parsing

data: raw data to send

rehash

tell the server to reload its config file

restart

tell the server to restart itself

service nickname reserved distribution type reserved info

register a new service

distribution: visibility of service
        type: reserved for future usage

servlist [mask [type]]

list services currently connected to the network

mask: list only services matching this mask
type: list only services of this type

squery service text

deliver a message to a service

service: name of service
text: text to send

squit server comment

disconnect server links

server: server name
comment: comment for quit

stats [query [server]]

query statistics about server

 query: c/h/i/k/l/m/o/y/u (see RFC1459)
server: server name

summon user [target [channel]]

give users who are on a host running an IRC server a message asking them to please join IRC

   user: username
target: server name
channel: channel name

time [target]

query local time from server

target: query time from specified server

topic [channel] [topic]

get/set channel topic

channel: channel name
topic: new topic for channel (if topic is "-delete" then topic is deleted)

trace [target]

find the route to specific server

target: server

unban [channel] nickname [nickname ...]

unbans nicks or hosts

 channel: channel for unban
nickname: user or host to unban

userhost nickname [nickname ...]

return a list of information about nicknames

nickname: nickname

users [target]

list of users logged into the server

target: server

version [server | nickname]

gives the version info of nick or server (current or specified)

  server: server name
nickname: nickname

voice [nickname [nickname]]

gives voice to nickname(s)

wallops text

send a message to all currently connected users who have set the 'w' user mode for themselves

text to send

who [mask ["o"]]

generate a query which returns a list of information

mask: only information which match this mask
   o: only operators are returned according to the mask supplied

whois [server] nickname[,nickname]

query information about user(s)

  server: server name
nickname: nickname (may be a mask)

whowas nickname [,nickname [,nickname ...]] [count [target]]

ask for information about a nickname which no longer exists

nickname: nickname to search
   count: number of replies to return (full search if negative number)
  target: reply should match this mask

Configuration file

List of options for config file:

Option Type Values Default Description
look_save_on_exit boolean 'on' or 'off' 'on' Save config file on exit
look_set_title boolean 'on' or 'off' 'on' Set title for window (terminal for Curses GUI) with name and version
look_startup_logo boolean 'on' or 'off' 'on' Display WeeChat logo at startup
look_startup_version boolean 'on' or 'off' 'on' Display WeeChat version at startup
look_weechat_slogan string any string 'the geekest IRC client!' WeeChat slogan (if empty, slogan is not used)
look_one_server_buffer boolean 'on' or 'off' 'off' Use same buffer for all servers
look_open_near_server boolean 'on' or 'off' 'off' Open new channels/privates near server
look_scroll_amount integer between 1 and 2147483647 3 How many lines to scroll by with scroll_up and scroll_down
look_buffer_timestamp string any string '[%H:%M:%S]' Timestamp for buffers
look_color_nicks_number integer between 1 and 10 10 Number of colors to use for nicks colors
look_color_actions boolean 'on' or 'off' 'on' Display actions with different colors
look_nicklist boolean 'on' or 'off' 'on' Display nicklist window (for channel windows)
look_nicklist_position string 'left', 'right', 'top', 'bottom' 'right' Nicklist position (top, left, right (default), bottom)
look_nicklist_min_size integer between 0 and 100 0 Min size for nicklist (width or height, depending on look_nicklist_position (0 = no min size))
look_nicklist_max_size integer between 0 and 100 0 Max size for nicklist (width or height, depending on look_nicklist_position (0 = no max size; if min = max and > 0, then size is fixed))
look_nicklist_separator boolean 'on' or 'off' 'on' Separator between chat and nicklist
look_no_nickname string any string '-cmd-' Text to display instead of nick when not connected
look_nickmode boolean 'on' or 'off' 'on' Display nick mode ((half)op/voice) before each nick
look_nickmode_empty boolean 'on' or 'off' 'off' Display space if nick mode is not (half)op/voice
look_nick_prefix string any string '' Text to display before nick in chat window
look_nick_suffix string any string ' |' Text to display after nick in chat window
look_align_nick string 'none', 'left', 'right' 'right' Nick alignment (fixed size for nicks in chat window (none, left, right))
look_align_other boolean 'on' or 'off' 'on' Alignment for other messages (not beginning with a nick)
look_align_size integer between 8 and 64 14 Size for aligning nick and other messages
look_align_size_max integer between 8 and 64 20 Max size for aligning nick and other messages (should be >= to look_align_size)
look_align_text_offset integer between -1 and 64 -1 Offset for aligning lines of messages (except first lines), default is -1 (align after nick), a null or positive value is offset after beginning of line
look_nick_completor string any string ':' The string inserted after nick completion
look_nick_completion_ignore string any string '[]-^' Chars ignored for nick completion
look_nick_completion_smart boolean 'on' or 'off' 'on' Smart completion for nicks (completes with last speakers first)
look_nick_complete_first boolean 'on' or 'off' 'off' Complete only with first nick found
look_infobar boolean 'on' or 'off' 'on' Enable info bar
look_infobar_timestamp string any string '%B, %A %d %Y' Timestamp for time in infobar
look_infobar_seconds boolean 'on' or 'off' 'on' Display seconds in infobar time
look_infobar_delay_highlight integer between 0 and 2147483647 7 Delay (in seconds) for highlight messages in infobar (0 = disable highlight notifications in infobar)
look_hotlist_names_count integer between 0 and 32 3 Max number of names in hotlist (0 = no name displayed, only buffer numbers)
look_hotlist_names_level integer between 1 and 15 12 Level for displaying names in hotlist (combination of: 1=join/part, 2=message, 4=private, 8=highlight, for example: 12=private+highlight)
look_hotlist_names_length integer between 0 and 32 0 Max length of names in hotlist (0 = no limit)
look_hotlist_sort string 'group_time_asc', 'group_time_desc', 'group_number_asc', 'group_number_desc', 'number_asc', 'number_desc' 'group_time_asc' Hotlist sort type (group_time_asc (default), group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc)
look_day_change boolean 'on' or 'off' 'on' Display special message when day changes
look_day_change_timestamp string any string '%a, %d %b %Y' Timestamp for date displayed when day changed
look_read_marker char any char ' ' Use a marker on servers/channels to show first unread line
look_input_format string any string '[%n(%m)] ' Format for input prompt ('%c' is replaced by channel or server, '%n' by nick and '%m' by nick modes)
look_paste_max_lines integer between 0 and 2147483647 3 Max number of lines for paste without asking user (0 = disable this feature)
col_real_white boolean 'on' or 'off' 'off' If set, uses real white color, disabled by default for terms with white background (if you never use white background, you should turn on this option to see real white instead of default term foreground color)
col_separator color Curses or Gtk color 'blue' Color for window separators (when splited)
col_title color Curses or Gtk color 'default' Color for title bar
col_title_more color Curses or Gtk color 'lightmagenta' Color for '+' when scrolling topic
col_title_bg color Curses or Gtk color 'blue' Background for title bar
col_chat color Curses or Gtk color 'default' Color for chat text
col_chat_time color Curses or Gtk color 'default' Color for time in chat window
col_chat_time_sep color Curses or Gtk color 'brown' Color for time separator (chat window)
col_chat_prefix1 color Curses or Gtk color 'lightcyan' Color for 1st and 3rd char of prefix
col_chat_prefix2 color Curses or Gtk color 'white' Color for middle char of prefix
col_chat_server color Curses or Gtk color 'brown' Color for server name
col_chat_join color Curses or Gtk color 'lightgreen' Color for join arrow (prefix)
col_chat_part color Curses or Gtk color 'lightred' Color for part/quit arrow (prefix)
col_chat_nick color Curses or Gtk color 'lightcyan' Color for nicks in actions (chat window)
col_chat_host color Curses or Gtk color 'cyan' Color for hostnames (chat window)
col_chat_channel color Curses or Gtk color 'white' Color for channel names in actions (chat window)
col_chat_dark color Curses or Gtk color 'green' Color for dark separators (chat window)
col_chat_highlight color Curses or Gtk color 'yellow' Color for highlighted nick (chat window)
col_chat_bg color Curses or Gtk color 'default' Background for chat window
col_chat_read_marker color Curses or Gtk color 'yellow' Color for unread data marker
col_chat_read_marker_bg color Curses or Gtk color 'magenta' Background for unread data marker
col_status color Curses or Gtk color 'default' Color for status bar
col_status_delimiters color Curses or Gtk color 'cyan' Color for status bar delimiters
col_status_channel color Curses or Gtk color 'white' Color for current channel in status bar
col_status_data_msg color Curses or Gtk color 'yellow' Color for window with new messages (status bar)
col_status_private color Curses or Gtk color 'lightmagenta' Color for window with private message (status bar)
col_status_highlight color Curses or Gtk color 'lightred' Color for window with highlight (status bar)
col_status_data_other color Curses or Gtk color 'default' Color for window with new data (not messages) (status bar)
col_status_more color Curses or Gtk color 'white' Color for window with new data (status bar)
col_status_bg color Curses or Gtk color 'blue' Background for status window
col_infobar color Curses or Gtk color 'black' Color for info bar text
col_infobar_delimiters color Curses or Gtk color 'blue' Color for infobar delimiters
col_infobar_highlight color Curses or Gtk color 'white' Color for info bar highlight notification
col_infobar_bg color Curses or Gtk color 'cyan' Background for info bar window
col_input color Curses or Gtk color 'default' Color for input text
col_input_server color Curses or Gtk color 'brown' Color for input text (server name)
col_input_channel color Curses or Gtk color 'white' Color for input text (channel name)
col_input_nick color Curses or Gtk color 'lightcyan' Color for input text (nick name)
col_input_delimiters color Curses or Gtk color 'cyan' Color for input text (delimiters)
col_input_text_not_found color Curses or Gtk color 'red' Color for text not found
col_input_actions color Curses or Gtk color 'lightgreen' Color for actions in input window
col_input_bg color Curses or Gtk color 'default' Background for input window
col_nick color Curses or Gtk color 'default' Color for nicknames
col_nick_away color Curses or Gtk color 'cyan' Color for away nicknames
col_nick_chanowner color Curses or Gtk color 'lightgreen' Color for chan owner symbol (specific to unrealircd)
col_nick_chanadmin color Curses or Gtk color 'lightgreen' Color for chan admin symbol (specific to unrealircd)
col_nick_op color Curses or Gtk color 'lightgreen' Color for operator symbol
col_nick_halfop color Curses or Gtk color 'lightmagenta' Color for half-operator symbol
col_nick_voice color Curses or Gtk color 'yellow' Color for voice symbol
col_nick_user color Curses or Gtk color 'blue' Color for user symbol
col_nick_more color Curses or Gtk color 'lightmagenta' Color for '+' when scrolling nicks
col_nick_sep color Curses or Gtk color 'blue' Color for nick separator
col_nick_self color Curses or Gtk color 'white' Color for local nick
col_nick_color1 color Curses or Gtk color 'cyan' Color for nick
col_nick_color2 color Curses or Gtk color 'magenta' Color for nick
col_nick_color3 color Curses or Gtk color 'green' Color for nick
col_nick_color4 color Curses or Gtk color 'brown' Color for nick
col_nick_color5 color Curses or Gtk color 'lightblue' Color for nick
col_nick_color6 color Curses or Gtk color 'default' Color for nick
col_nick_color7 color Curses or Gtk color 'lightcyan' Color for nick
col_nick_color8 color Curses or Gtk color 'lightmagenta' Color for nick
col_nick_color9 color Curses or Gtk color 'lightgreen' Color for nick
col_nick_color10 color Curses or Gtk color 'blue' Color for nick
col_nick_private color Curses or Gtk color 'default' Color for other nick in private window
col_nick_bg color Curses or Gtk color 'default' Background for nicknames
col_chat_dcc_selected color Curses or Gtk color 'white' Color for selected DCC (chat window)
col_dcc_waiting color Curses or Gtk color 'lightcyan' Color for "waiting" dcc status
col_dcc_connecting color Curses or Gtk color 'yellow' Color for "connecting" dcc status
col_dcc_active color Curses or Gtk color 'lightblue' Color for "active" dcc status
col_dcc_done color Curses or Gtk color 'lightgreen' Color for "done" dcc status
col_dcc_failed color Curses or Gtk color 'lightred' Color for "failed" dcc status
col_dcc_aborted color Curses or Gtk color 'lightred' Color for "aborted" dcc status
history_max_lines integer between 0 and 2147483647 4096 Maximum number of lines in history for one server/channel/private window (0 = unlimited)
history_max_commands integer between 0 and 2147483647 100 Maximum number of user commands in history (0 = unlimited)
history_display_default integer between 0 and 2147483647 5 Maximum number of commands to display by default in history listing (0 = unlimited)
log_auto_server boolean 'on' or 'off' 'off' Automatically log server messages
log_auto_channel boolean 'on' or 'off' 'off' Automatically log channel chats
log_auto_private boolean 'on' or 'off' 'off' Automatically log private chats
log_plugin_msg boolean 'on' or 'off' 'off' Log messages from plugins (scripts)
log_path string any string '%h/logs/' Path for WeeChat log files ('%h' will be replaced by WeeChat home, ~/.weechat by default)
log_timestamp string any string '%Y %b %d %H:%M:%S' Timestamp for log (see man strftime for date/time specifiers)
log_hide_nickserv_pwd boolean 'on' or 'off' 'on' Hide password displayed by nickserv
irc_display_away string 'off', 'local', 'channel' 'off' Display message when (un)marking as away
irc_show_away_once boolean 'on' or 'off' 'on' Show remote away message only once in private
irc_default_msg_part string any string 'WeeChat %v' Default part message (leaving channel) ('%v' will be replaced by WeeChat version in string)
irc_default_msg_quit string any string 'WeeChat %v' Default quit message ('%v' will be replaced by WeeChat version in string)
irc_notice_as_pv boolean 'on' or 'off' 'off' Display notices as private messages
irc_away_check integer between 0 and 2147483647 0 Interval between two checks for away (in minutes, 0 = never check)
irc_away_check_max_nicks integer between 0 and 2147483647 0 Do not check away nicks on channels with high number of nicks (0 = unlimited)
irc_lag_check integer between 30 and 2147483647 60 Interval between two checks for lag (in seconds)
irc_lag_min_show integer between 0 and 2147483647 1 Minimum lag to show (in seconds)
irc_lag_disconnect integer between 0 and 2147483647 5 Disconnect after important lag (in minutes, 0 = never disconnect)
irc_anti_flood integer between 0 and 5 2 Anti-flood: # seconds between two user messages (0 = no anti-flood)
irc_fifo_pipe boolean 'on' or 'off' 'off' Create a FIFO pipe for remote control
irc_highlight string any string '' Comma separated list of words to highlight (case insensitive comparison, words may begin or end with "*" for partial match)
irc_colors_receive boolean 'on' or 'off' 'on' When off, colors codes are ignored in incoming messages
irc_colors_send boolean 'on' or 'off' 'on' Allow user to send colors with special codes (^Cb=bold, ^Ccxx=color, ^Ccxx,yy=color+background, ^Cu=underline, ^Cr=reverse)
irc_send_unknown_commands boolean 'on' or 'off' 'off' Send unknown commands to IRC server
dcc_auto_accept_files boolean 'on' or 'off' 'off' Automatically accept incoming dcc files
dcc_auto_accept_chats boolean 'on' or 'off' 'off' Automatically accept dcc chats (use carefully!)
dcc_timeout integer between 5 and 2147483647 300 Timeout for dcc request (in seconds)
dcc_blocksize integer between 1024 and 102400 65536 Block size for dcc packets in bytes (default: 65536)
dcc_fast_send boolean 'on' or 'off' 'on' Does not wait for ACK when sending file
dcc_port_range string any string '' Restricts outgoing dcc to use only ports in the given range (useful for NAT) (syntax: a single port, ie. 5000 or a port range, ie. 5000-5015, empty value means any port)
dcc_own_ip string any string '' IP or DNS address used for outgoing dcc (if empty, local interface IP is used)
dcc_download_path string any string '%h/dcc' Path for writing incoming files with dcc (default: user home)
dcc_upload_path string any string '~' Path for reading files when sending thru dcc (when no path is specified)
dcc_convert_spaces boolean 'on' or 'off' 'on' Convert spaces to underscores when sending files
dcc_auto_rename boolean 'on' or 'off' 'on' Rename incoming files if already exists (add '.1', '.2', ...)
dcc_auto_resume boolean 'on' or 'off' 'on' Automatically resume dcc transfer if connection with remote host is loosed
proxy_use boolean 'on' or 'off' 'off' Use a proxy server to connect to irc server
proxy_type string 'http', 'socks4', 'socks5' 'http' Proxy type (http (default), socks4, socks5)
proxy_ipv6 boolean 'on' or 'off' 'off' Connect to proxy in ipv6
proxy_address string any string '' Proxy server address (IP or hostname)
proxy_port integer between 0 and 65535 3128 Port for connecting to proxy server
proxy_username string any string '' Username for proxy server
proxy_password string any string '' Password for proxy server
plugins_path string any string '%h/plugins' Path for searching plugins ('%h' will be replaced by WeeChat home, ~/.weechat by default)
plugins_autoload string any string '*' Comma separated list of plugins to load automatically at startup, "*" means all plugins found (names may be partial, for example "perl" is ok for "libperl.so")
plugins_extension string any string '.so' Standard plugins extension in filename, used for autoload (if empty, then all files are loaded when autoload is "*")
server_name string any string '' Name associated to IRC server (for display only)
server_autoconnect boolean 'on' or 'off' 'on' Automatically connect to server when WeeChat is starting
server_autoreconnect boolean 'on' or 'off' 'on' Automatically reconnect to server when disconnected
server_autoreconnect_delay integer between 0 and 65535 30 Delay (in seconds) before trying again to reconnect to server
server_address string any string '' IP address or hostname of IRC server
server_port integer between 0 and 65535 6667 Port for connecting to server
server_ipv6 boolean 'on' or 'off' 'off' Use IPv6 protocol for server communication
server_ssl boolean 'on' or 'off' 'off' Use SSL for server communication
server_password string any string '' Password for IRC server
server_nick1 string any string '' Nickname to use on IRC server
server_nick2 string any string '' Alternate nickname to use on IRC server (if nickname is already used)
server_nick3 string any string '' 2nd alternate nickname to use on IRC server (if alternate nickname is already used)
server_username string any string '' User name to use on IRC server
server_realname string any string '' Real name to use on IRC server
server_hostname string any string '' Custom hostname/IP for server (optional, if empty local hostname is used)
server_command string any string '' Command(s) to run when connected to server (many commands should be separated by ';', use '\;' for a semicolon, special variables $nick, $channel and $server are replaced by their value)
server_command_delay integer between 0 and 3600 0 Delay (in seconds) after command was executed (example: give some time for authentication)
server_autojoin string any string '' Comma separated list of channels to join when connected to server (example: "#chan1,#chan2,#chan3 key1,key2")
server_autorejoin boolean 'on' or 'off' 'on' Automatically rejoin channels when kicked
server_notify_levels string any string '' Comma separated list of notify levels for channels of this server (format: #channel:1,..), a channel name '*' is reserved for server default notify level

Colors for Curses GUI are:

Keyword Color
default default color (transparent for background)
black black
red dark red
lightred light red
green dark green
lightgreen light green
brown brown
yellow yellow
blue dark blue
lightblue light blue
magenta dark magenta
lightmagenta light magenta
cyan dark cyan
lightcyan light cyan
white white

FIFO pipe

You can remote control WeeChat, by sending commands or text to a FIFO pipe (you have to enable option "irc_fifo_pipe", it is disabled by default).

The FIFO pipe is located in "~/.weechat/" and is called "weechat_fifo_xxxxx" (where xxxxx is the process ID (PID) of running WeeChat). So if many WeeChat are running, you have many FIFO pipes, one for each session.

The syntax for the FIFO pipe commands/text is:

server,channel *text or command here

where server and channel are optional, but if channel is here, server should be too.

Some examples:

  • nick change on freenode to "mynick|out" :

    $ echo 'freenode */nick mynick|out' >~/.weechat/weechat_fifo_12345

  • display text on #weechat channel:

    $ echo 'freenode,#weechat *hello everybody!' >~/.weechat/weechat_fifo_12345

  • display text on current channel (buffer displayed by WeeChat):

    $ echo '*hello!' >~/.weechat/weechat_fifo_12345

    Warning: this is dangerous and you should not do that except if you know what you do!

  • send two commands to unload/reload Perl scripts (you have to separate them with "\n"):

    $ echo -e "freenode */perl unload\nfreenode */perl autoload" >~/.weechat/weechat_fifo_12345

You can write a script to send command to all running WeeChat at same time, for example:

#!/bin/sh
if [ $# -eq 1 ]; then
    for fifo in ~/.weechat/weechat_fifo_*
    do
        echo -e "$1" >$fifo
    done
fi

If the script is called "auto_weechat_command", you can run it with:

$ ./auto_weechat_command "freenode,#weechat *hello"

Chapter 4. Plugins

This chapter describes WeeChat plugins interface (API) and the default scripts plugins (Perl, Python, Ruby, Lua), provided with WeeChat.

Plugins in WeeChat

A plugin is a C program which can call WeeChat functions defined in an interface.

This C program does not need WeeChat sources to compile and can be dynamically loaded into WeeChat with command /plugin.

The plugin has to be a dynamic library, for dynamic loading by operating system. Under GNU/Linux, the file has ".so" extension, ".dll" under Windows.

Write a plugin

The plugin has to include "weechat-plugin.h" file (available in WeeChat source code). This file defines structures and types used to communicate with WeeChat.

The plugin must have some variables and functions (mandatory, without them the plugin can't load):

Variable Description
char plugin_name[] plugin name
char plugin_version[] plugin version
char plugin_description[] short description of plugin

Function Description
int weechat_plugin_init (t_weechat_plugin *plugin) function called when plugin is loaded, must return PLUGIN_RC_OK if successful, PLUGIN_RC_KO if error (if error, plugin will NOT be loaded)
void weechat_plugin_end (t_weechat_plugin *plugin) function called when plugin is unloaded

API functions

set_charset

Prototype: void set_charset (t_weechat_plugin *plugin, char *charset)

Set new plugin charset.

Arguments:

  • plugin: pointer to plugin structure

  • charset: new charset to use

Example:

plugin->set_charset (plugin, "ISO-8859-1");

iconv_to_internal

Prototype: void iconv_to_internal (t_weechat_plugin *plugin, char *charset, char *string)

Convert string to WeeChat internal charset (UTF-8).

Arguments:

  • plugin: pointer to plugin structure

  • charset: charset to convert

  • string: string to convert

Return value: converted string.

Note: result has to be free by a call to "free" after use.

Example:

char *str = plugin->iconv_to_internal (plugin, "ISO-8859-1", "iso string: é à");

iconv_from_internal

Prototype: void iconv_from_internal (t_weechat_plugin *plugin, char *charset, char *string)

Convert string from internal WeeChat charset (UTF-8) to another.

Arguments:

  • plugin: pointer to plugin structure

  • charset: target charset

  • string: string to convert

Return value: converted string.

Note: result has to be free by a call to "free" after use.

Example:

char *str = plugin->iconv_from_internal (plugin, "ISO-8859-1", "utf-8 string: é à");

ascii_strcasecmp

Prototype: int ascii_strcasecmp (t_weechat_plugin *plugin, char *string1, char *string2)

Locale and case independent string comparison.

Arguments:

  • plugin: pointer to plugin structure

  • string1: first string for comparison

  • string2: second string for comparison

Return value: difference between two strings: negative if string1 < string2, zero if string1 == string2, positive if string1 > string2

Example:

if (plugin->ascii_strcasecmp (plugin, "abc", "def") != 0) ...

ascii_strncasecmp

Prototype: int ascii_strncasecmp (t_weechat_plugin *plugin, char *string1, char *string2, int max)

Locale and case independent string comparison, for "max" chars.

Arguments:

  • plugin: pointer to plugin struct

  • string1: first string for comparison

  • string2: second string for comparison

  • max: max number of chars for comparison

Return value: difference between two strings: negative if string1 < string2, zero if string1 == string2, positive if string1 > string2

Example:

if (plugin->ascii_strncasecmp (plugin, "abc", "def", 2) != 0) ...

explode_string

Prototype: char **explode_string (t_weechat_plugin *plugin, char *string, char *separators, int num_items_max, int *num_items)

Explode a string according to one or more delimiter(s).

Arguments:

  • plugin: pointer to plugin struct

  • string: string to explode

  • separators: delimiters used for explosion

  • num_items_max: maximum number of items created (0 = no limit)

  • num_items: pointer to int which will contain number of items created

Return value: array of strings, NULL if problem.

Note: result has to be free by a call to "free_exloded_string" after use.

Example:

char **argv;
int argc;
argv = plugin->explode_string (plugin, string, " ", 0, &argc);
...
if (argv != NULL)
    plugin->free_exploded_string (plugin, argv);

free_exploded_string

Prototype: char **free_exploded_string (t_weechat_plugin *plugin, char **string)

Free memory used by a string explosion.

Arguments:

  • plugin: pointer to plugin structure

  • string: string exploded by "explode_string" function

Return value: none.

Example:

char *argv;
int argc;
argv = plugin->explode_string (plugin, string, " ", 0, &argc);
...
if (argv != NULL)
    plugin->free_exploded_string (plugin, argv);

mkdir_home

Prototype: int mkdir_home (t_weechat_plugin *plugin, char *directory)

Create a directory in WeeChat home.

Arguments:

  • plugin: pointer to plugin structure

  • directory: directory to create

Return value: 1 if directory was successfully created, 0 if an error occurred.

Example:

if (!plugin->mkdir_home (plugin, "temp"))
    plugin->print_server(plugin, "Failed to create 'temp' directory in WeeChat home.");

exec_on_files

Prototype: void exec_on_files (t_weechat_plugin *plugin, char *directory, int (*callback)(t_weechat_plugin *, char *))

Execute a function on all files of a directory.

Arguments:

  • plugin: pointer to plugin structure

  • directory: directory for searching files

  • callback: function called for each file found

Return value: none.

Example:

int callback (t_weechat_plugin *plugin, char *file)
{
    plugin->print_server (plugin, "file: %s", file);
    return 1;
}
...
plugin->exec_on_files (plugin, "/tmp", &callback);

print

Prototype: void print (t_weechat_plugin *plugin, char *server, char *channel, char *message, ...)

Display a message on a WeeChat buffer, identified by server and channel (both may be NULL for current buffer).

Arguments:

  • plugin: pointer to plugin structure

  • server: internal name of server to find buffer for message display (may be NULL)

  • channel: name of channel to find buffer for message display (may be NULL)

  • message: message

To display colored text, there are following codes:

Code Description
0x02 bold text
0x03 + "xx" text color "xx" (see the section called “get_irc_color” for colors)
0x03 + "xx,yy" text color "xx" and background "yy" (see the section called “get_irc_color” for colors)
0x0F disable color and attributes
0x12 reverse video (revert text color with background)
0x1F underlined text

Note: the same code (without number for 0x03) may be used to stop the attribute.

Return value: none.

Examples:

plugin->print (plugin, NULL, NULL, "hello");
plugin->print (plugin, NULL, "#weechat", "hello");
plugin->print (plugin, "freenode", "#weechat", "hello");
plugin->print (plugin, NULL, NULL,
               "test: \x02 bold \x0F\x03%02d blue \x03%02d green",
               plugin->get_irc_color (plugin, "blue"),
               plugin->get_irc_color (plugin, "green"));

print_server

Prototype: void print_server (t_weechat_plugin *plugin, char *message, ...)

Display a message on current server buffer.

Arguments:

  • plugin: pointer to plugin structure

  • message: message

To display colored text, see the section called “print”.

Return value: none.

Example:

plugin->print_server (plugin, "hello");

print_infobar

Prototype: void print_infobar (t_weechat_plugin *plugin, int time, char *message, ...)

Display a message in infobar for a specified time.

Arguments:

  • plugin: pointer to plugin structure

  • time: time (in seconds) for displaying message (0 = never erased)

Return value: none.

Example:

plugin->print_infobar (plugin, 5, "hello");

infobar_remove

Prototype: void infobar_remove (t_weechat_plugin *plugin, int count)

Remove one or more messages in infobar stack.

Arguments:

  • plugin: pointer to plugin structure

  • count: number of messages to remove (if argument is <= 0, then all messages are removed)

Return value: none.

Example:

plugin->infobar_remove (1);

log

Prototype: void log (t_weechat_plugin *plugin, char *server, char *channel, char *message, ...)

Write a message in log file for a server or a channel.

Arguments:

  • plugin: pointer to plugin structure

  • server: internal name of server to find buffer for log (may be NULL)

  • channel: name of channel to find buffer for log (may be NULL)

  • message: message

Return value: none.

Example:

plugin->log (plugin, "freenode", "#weechat", "test");

msg_handler_add

Prototype: t_plugin_handler *msg_handler_add (t_weechat_plugin *plugin, char *message, t_plugin_handler_func *function, char *handler_args, void *handler_pointer)

Add an IRC message handler, called when an IRC message is received.

Arguments:

  • plugin: pointer to plugin structure

  • message: name of IRC message ("*" for all messages). 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, as written in table below:

    Name Description
    weechat_pv private message received
    weechat_highlight message with highlight (on a channel or pv)
    weechat_ctcp CTCP message received (VERSION, PING, ..)
    weechat_dcc DCC message received (chat or file)

  • function: function called when message is received

    It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer)

    Argument argc is set to 3, following values are set in argv array:

    • argv[0] = server name

    • argv[1] = IRC message

    • argv[2] = command arguments

  • handler_args: arguments given to function when called

  • handler_pointer: pointer given to function when called

Return value: pointer to new message handler.

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

Example:

int msg_kick (t_weechat_plugin *plugin, int argc, char **argv,
              char *handler_args, void *handler_pointer)
{
    plugin->print (plugin, argv[0], NULL, "KICK received");
    return PLUGIN_RC_OK;
}
...
t_plugin_handler *msg_handler;
msg_handler = plugin->msg_handler_add (plugin, "KICK",
                                       &msg_kick, NULL, NULL);

cmd_handler_add

Prototype: t_plugin_handler *cmd_handler_add (t_weechat_plugin *plugin, char *command, char *description, char *arguments, char *arguments_description, char *completion_template, t_plugin_handler_func *fonction, char *handler_args, void *handler_pointer)

Add a WeeChat command handler, called when user uses command (for example /command).

Arguments:

  • plugin: pointer to plugin structure

  • command: the new command name, which may be an existing command (be careful, replaced command will not be available until plugin is unloaded)

  • description: short command description (displayed by /help command)

  • arguments: short description of command arguments (displayed by /help command)

  • arguments_description: long description of command arguments (displayed by /help command)

  • completion_template: template for completion, like "abc|%w def|%i" which means "abc" or a WeeChat command for first argument, "def" or IRC command for second. An empty string lets WeeChat complete any argument with a nick from current channel, NULL or "-" disable completion for all command arguments.

    Following codes can be used:

    Code Description
    %- no completion for argument
    %* repeat last completion for all following arguments (this code has to be at the end of completion template, preceded by "|")
    %a alias
    %A alias and commands (WeeChat, IRC and plugins)
    %c current channel
    %C all channels (including queries)
    %f file name
    %h plugins commands
    %i IRC commands (sent)
    %I IRC commands (received)
    %k key functions
    %m nick on current server
    %M nicks on current server (on all open channels)
    %n nicks of current channel
    %N nicks and hostnames of current channel
    %o setup options
    %O plugin options
    %p default "part" message
    %q default "quit" message
    %s current server name
    %S all servers names
    %t topic of current channel
    %v setup option value
    %V plugin option value
    %w WeeChat commands

  • function: function called when command is executed

    It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer)

    Argument argc is set to 3, following values are set in argc array:

    • argv[0] = server name

    • argv[1] = command

    • argv[2] = command arguments

  • handler_args: arguments given to function when called

  • handler_pointer: pointer given to function when called

Return value: pointer to new command handler.

Note: function called when command is executed has to return one of following values:

  • PLUGIN_RC_KO: function failed

  • PLUGIN_RC_OK: function successfully completed

Example:

int cmd_test (t_weechat_plugin *plugin, int argc, char **argv,
              char *handler_args, void *handler_pointer)
{
    plugin->print (plugin, argv[0], NULL,
                   "test command, nick: %s",
                   (argv[2]) ? argv[2] : "none");
    return PLUGIN_RC_OK;
}
...
t_plugin_handler *cmd_handler;
cmd_handler = plugin->cmd_handler_add (plugin, "test", "Test command",
                                       "[nick]", "nick: nick of channel",
                                       "%n", &cmd_test, NULL, NULL);

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:

  • plugin: pointer to plugin structure

  • interval: interval (in seconds) between two calls of function.

  • function: function called

    It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer)

    Argument argc is set to 0, and argv is set to NULL.

  • handler_args: arguments given to function when called

  • handler_pointer: pointer given to function when called

Return value: pointer to new timer 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, int argc, char **argv,
              char *handler_args, void *handler_pointer)
{
    plugin->print (plugin, NULL, NULL, "my timer");
    return PLUGIN_RC_OK;
}
...
t_plugin_handler *timer_handler;
timer_handler = plugin->timer_handler_add (plugin, 60, &my_timer);

keyboard_handler_add

Prototype: t_plugin_handler *keyboard_handler_add (t_weechat_plugin *plugin, t_plugin_handler_func *function, char *handler_args, void *handler_pointer)

Add a keyboard handler, called for any key pressed.

Arguments:

  • plugin: pointer to plugin structure

  • function: function called

    It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer)

    Argument argc is set to 3, following values are set in argc array:

    • argv[0] = key pressed (name of internal function or '*' followed by a key code)

    • argv[1] = command line before key action

    • argv[2] = command line after key action

  • handler_args: arguments given to function when called

  • handler_pointer: 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_keyb (t_weechat_plugin *plugin, int argc, char **argv,
             char *handler_args, void *handler_pointer)
{
    if (argc == 2)
    {
        plugin->print (plugin, NULL, NULL, "key pressed: %s", argv[0]);
        if (argv[1] && (argv[1][0] == '1'))
            plugin->print (plugin, NULL, NULL, "input text changed");
        else
            plugin->print (plugin, NULL, NULL, "input text not changed");
    }
    return PLUGIN_RC_OK;
}
...
t_plugin_handler *keyb_handler;
keyb_handler = plugin->keyboard_handler_add (plugin, &my_keyb);

event_handler_add

Prototype: t_plugin_handler *event_handler_add (t_weechat_plugin *plugin, char *event, t_plugin_handler_func *function, char *handler_args, void *handler_pointer)

Add an event handler, called when an event happens.

Arguments:

  • plugin: pointer to plugin structure

  • event : event (see table below)

  • function: function called

    It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *handler_args, void *handler_pointer)

    Arguments depend on event (see table below).

  • handler_args: arguments given to function when called

  • handler_pointer: pointer given to function when called

List of events:

Event Description Arguments
buffer_open a buffer was open argc = 1, argv = { buffer number }
buffer_close a buffer was closed argc = 1, argv = { buffer number }
buffer_move a buffer was moved argc = 2, argv = { new buffer number, old number }

Return value: pointer to new event 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_event (t_weechat_plugin *plugin, int argc, char **argv,
              char *handler_args, void *handler_pointer)
{
    plugin->print (plugin, NULL, NULL, "my_event");
    return PLUGIN_RC_OK;
}
...
t_plugin_handler *event_handler;
event_handler = plugin->event_handler_add (plugin, "buffer_open",
                                           &my_event);

handler_remove

Prototype: void handler_remove (t_weechat_plugin *plugin, t_plugin_handler *handler)

Remove a command or message handler.

Arguments:

  • plugin: pointer to plugin structure

  • handler: handler to remove

Return value: none.

Example:

plugin->handler_remove (plugin, my_handler);

handler_remove_all

Prototype: void handler_remove_all (t_weechat_plugin *plugin)

Remove all handlers for a plugin.

Arguments:

  • plugin: pointer to plugin structure

Return value: none.

Example:

plugin->handler_remove_all (plugin);

modifier_add

Prototype: t_plugin_modifier *modifier_add (t_weechat_plugin *plugin, char *type, char *message, t_plugin_modifier_func *function, char *modifier_args, void *modifier_pointer)

Add a message modifier.

Arguments:

  • plugin: pointer to plugin structure

  • type: 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)

  • message: 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: function called

    It uses following prototype: int my_function (t_weechat_plugin *plugin, int argc, char **argv, char *modifier_args, void *modifier_pointer)

    Argument argc is set to 2, following values are set in argv array:

    • argv[0] = server name

    • argv[1] = message

  • modifier_args: arguments given to function when called

  • modifier_pointer: pointer given to function when called

Return value: pointer to new message modifier.

Note: function has to return modified string, or NULL if no changes are made to message. If function returns empty string, then message is dropped and will not be read at all by WeeChat (be careful when dropping messages!). Returned string must have been allocated by malloc() and will be freed (with call to free()) automatically by WeeChat after use.

Example:

char *adder (t_weechat_plugin *plugin, int argc, char **argv,
             char *modifier_args, void *modifier_pointer)
{
    char *string;
    string = (char *)malloc (strlen (argv[1]) + 16);
    strcpy (string, argv[1]);
    strcat (string, "test");
    return string;
}
...
t_plugin_modifier *modifier;
modifier = plugin->modifier_add (plugin, "irc_in", "privmsg",
                                 &adder, NULL, NULL);

modifier_remove

Prototype: void modifier_remove (t_weechat_plugin *plugin, t_plugin_modifier *modifier)

Remove a message modifier.

Arguments:

  • plugin: pointer to plugin structure

  • modifier: modifier to remove

Return value: none.

Example:

plugin->modifier_remove (plugin, my_modifier);

modifier_remove_all

Prototype: void modifier_remove_all (t_weechat_plugin *plugin)

Remove all modifiers for a plugin.

Arguments:

  • plugin: pointer to plugin structure

Return value: none.

Example:

plugin->modifier_remove_all (plugin);

exec_command

Prototype: void exec_command (t_weechat_plugin *plugin, char *server, char *channel, char *command)

Execute a WeeChat command (or send a message to a channel).

Arguments:

  • plugin: pointer to plugin structure

  • server: internal name of server for executing command (may be NULL)

  • channel: name of channel for executing command (may be NULL)

  • command: command

Return value: none.

Examples:

plugin->exec_command (plugin, NULL, NULL, "/help nick");
plugin->exec_command (plugin, "freenode", "#weechat", "hello");

get_info

Prototype: char *get_info (t_weechat_plugin *plugin, char *info, char *server)

Return an info about WeeChat or a channel.

Arguments:

  • plugin: pointer to plugin structure

  • info : name of info to read:

    Info Description
    version WeeChat's version
    nick nick
    channel name of channel (NULL for a server or private)
    server name of server
    type buffer type: 0=standard, 1=DCC, 2=raw IRC data
    away "away" flag
    inactivity number of seconds since last key was pressed
    input content of command line for current window
    input_mask content of color mask for command line
    input_pos cursor position in command line
    weechat_dir WeeChat home directory (by default: ~/.weechat/)
    weechat_libdir WeeChat system lib directory
    weechat_sharedir WeeChat system share directory

  • server: internal name of server for reading info (if needed)

Return value: information asked, NULL if not found.

Note: result has to be free by a call to "free" function after use.

Examples:

char *version = plugin->get_info (plugin, "version", NULL);
char *nick = plugin->get_info (plugin, "nick", "freenode");
char *inactivity = plugin->get_info (plugin, "inactivity", NULL);

plugin->print (plugin, NULL, NULL,
               "WeeChat version %s, you are %s on freenode "
               "(inactive for %s seconds)",
               version, nick, inactivity);

if (version)
    free (version);
if (nick)
    free (nick);
if (inactivity)
    free (inactivity);

get_dcc_info

Prototype: t_plugin_info_dcc *get_dcc_info (t_weechat_plugin *plugin)

Return list of DCC currently active or finished.

Arguments:

  • plugin: pointer to plugin structure

Return value: linked list of DCC.

Type Field Description
char * server IRC server
char * channel IRC channel
int type DCC type: 0 = chat received, 1 = chat sent, 2 = file received, 3 = file sent
int* status DCC status: 0 = waiting, 1 = connecting, 2 = active, 3 = finished, 4 = failed, 5 = interrupted by user
time_t start_time date/time of DCC creation
time_t start_transfer date/time of DCC transfer start
unsigned long addr IP address of remote user
int port port used for DCC
char * nick remote nick
char * filename file name
char * local_filename local file name
int filename_suffix suffix if renaming file
unsigned long size file size
unsigned long pos position in file
unsigned long start_resume start position after interruption
unsigned long bytes_per_sec number of bytes per second since transfer start
t_plugin_dcc_info * prev_dcc pointer to previous DCC info
t_plugin_dcc_info * next_dcc pointer to next DCC info

Note: result has to be free by a call to "free_dcc_info" function after use.

Examples:

t_plugin_dcc_info *dcc_info = plugin->get_dcc_info (plugin);
for (ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
{
    plugin->print_server (plugin, "DCC type=%d, with: %s",
                          ptr_dcc->type, ptr_dcc->nick);
}
if (dcc_info)
    plugin->free_dcc_info (plugin, dcc_info);

free_dcc_info

Prototype: void free_dcc_info (t_weechat_plugin *plugin, t_plugin_dcc_info *dcc_info)

Free memory used by a DCC list.

Arguments:

  • plugin: pointer to plugin structure

  • dcc_info: pointer to DCC list returned by "get_dcc_info" function

Return value: none.

Example:

plugin->free_dcc_info (plugin, dcc_info);

get_server_info

Prototype: t_plugin_server_info *get_server_info (t_weechat_plugin *plugin)

Return list of IRC servers (connected or not).

Arguments:

  • plugin: pointer to plugin structure

Return value: linked list of IRC servers.

Type Field Description
char * name server internal name
int autoconnect 1 if autoconnect at start-up, 0 otherwise
int autoreconnect 1 if autoreconnect when disconnected, 0 otherwise
int autoreconnect_delay delay before trying again connection
int command_line 1 if server was on command line (so it is temporary), 0 otherwise
char * address server address (host or IP)
int port port
int ipv6 IPv6 connection
int ssl SSL connection
char * password server password
char * nick1 first nickname
char * nick2 alternate nickname
char * nick3 second alternate nickname
char * username user name
char * real name real name
char * command command run once connected
int command_delay delay after execution of command
char * autojoin channels joined automatically
int autorejoin 1 if channels are rejoined when kicked, 0 otherwise
char * notify_levels channels notify levels
char * charset_decode_iso channels charsets for decoding ISO
char * charset_decode_utf channels charsets for decoding UTF
char * charset_encode channels charsets for encoding messages
int is_connected 1 if connected to server, 0 otherwise
int ssl_connected 1 if connected with SSL, 0 otherwise
char * nick current nickname
int is_away 1 if away, 0 otherwise
time_t away_time time when user is marking as away
int lag lag (in milliseconds)
t_plugin_server_info * prev_server pointer to previous server info
t_plugin_server_info * next_server pointer to next server info

Note: result has to be free by a call to "free_server_info" function after use.

Example:

t_plugin_server_info *server_info, *ptr_server_info;
server_info = plugin->get_server_info (plugin);
if (server_info)
{
    for (ptr_server_info = server_info; ptr_server_info;
         ptr_server_info = ptr_server_info->next_server)
    {
        plugin->print (plugin, NULL, NULL,
                       "server: %s, address: %s, port: %d %s",
                       ptr_server_info->name,
                       ptr_server_info->address,
                       ptr_server_info->port,
                       (ptr_server_info->is_connected) ? "(connected)" : "");
    }
    plugin->free_server_info (plugin, server_info);
}

free_server_info

Prototype: void free_server_info (t_weechat_plugin *plugin, t_plugin_server_info *server_info)

Free memory used by server info list.

Arguments:

  • plugin: pointer to plugin structure

  • server_info: pointer to server list returned by "get_server_info" function

Return value: none.

Example:

plugin->free_server_info (plugin, server_info);

get_channel_info

Prototype: t_plugin_channel_info *get_channel_info (t_weechat_plugin *plugin, char *server)

Return list of IRC channels for a server.

Arguments:

  • plugin: pointer to plugin structure

  • server: internal server name

Return value: linked list of IRC channels for server.

Type Field Description
int type 0 for a channel, 1 for a private
char * name name of channel
char * topic topic of channel
char * modes channel modes
int limit user limit
char * key channel key
int nicks_count number of nicks on channel
t_plugin_channel_info * prev_channel pointer to previous channel info
t_plugin_channel_info * next_channel pointer to next channel info

Note: result has to be free by a call to "free_channel_info" function after use.

Example:

t_plugin_channel_info *channel_info, *ptr_chan_info;
channel_info = plugin->get_channel_info (plugin, "freenode");
if (channel_info)
{
    for (ptr_chan_info = channel_info; ptr_chan_info;
         ptr_chan_info = ptr_chan_info->next_channel)
    {
        plugin->print (plugin, NULL, NULL,
                       "  %s (type %d)",
                       ptr_chan_info->name,
                       ptr_chan_info->type);
    }
    plugin->free_channel_info (plugin, channel_info);
}

free_channel_info

Prototype: void free_channel_info (t_weechat_plugin *plugin, t_plugin_channel_info *channel_info)

Free memory used by channel info list.

Arguments:

  • plugin: pointer to plugin structure

  • channel_info: pointer to channel info list returned by "get_channel_info" function

Return value: none.

Example:

plugin->free_channel_info (plugin, channel_info);

get_nick_info

Prototype: t_plugin_nick_info *get_nick_info (t_weechat_plugin *plugin, char *server, char *channel)

Return list of nicks for a channel.

Arguments:

  • plugin: pointer to plugin structure

  • server: internal server name

  • channel: channel name

Return value: linked list of nicks on channel.

Type Field Description
char * nick nick name
char * host hostname
int flags nick flags, binary "or" between values (1 = channel owner, 2 = channel admin, 4 = op, 8 = halfop, 16 = voice, 32 = away)
t_plugin_nick_info * prev_nick pointer to previous nick info
t_plugin_nick_info * next_nick pointer to next nick info

Note: result has to be free by a call to "free_nick_info" function after use.

Example:

t_plugin_nick_info *nick_info, *ptr_nick_info;
nick_info = plugin->get_nick_info (plugin, "freenode", "#weechat");
if (nick_info)
{
    for (ptr_nick_info = nick_info; ptr_nick_info;
         ptr_nick_info = ptr_nick_info->next_nick)
    {
        plugin->print (plugin, NULL, NULL,
                       "  %s (flags: %d)",
                       ptr_nick_info->nick,
                       ptr_nick_info->flags);
    }
    plugin->free_nick_info (plugin, nick_info);
}

free_nick_info

Prototype: void free_nick_info (t_weechat_plugin *plugin, t_plugin_nick_info *nick_info)

Free memory used by nick info list.

Arguments:

  • plugin: pointer to plugin structure

  • nick_info: pointer to nick info list returned by "get_nick_info" function

Return value: none.

Example:

plugin->free_nick_info (plugin, nick_info);

get_config

Prototype: char *get_config (t_weechat_plugin *plugin, char *option)

Return value of a WeeChat config option.

Arguments:

  • plugin: pointer to plugin structure

  • option: name of option to read

Return value: option value, NULL if not found.

Note: result has to be free by a call to "free" function after use.

Examples:

char *value1 = plugin->get_config (plugin, "look_set_title");
char *value2 = plugin->get_config (plugin, "freenode.server_autojoin");

set_config

Prototype: int set_config (t_weechat_plugin *plugin, char *option, char *value)

Update value of a WeeChat config option.

Arguments:

  • plugin: pointer to plugin structure

  • option: name of option to update

  • value: new value for option

Return value: 1 if option was successfully updated, 0 if an error occurred.

Example:

plugin->set_config (plugin, "look_nicklist", "off");

get_plugin_config

Prototype: char *get_plugin_config (t_weechat_plugin *plugin, char *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:

  • plugin: pointer to plugin structure

  • option: name of option to read

Return value: option value, NULL if not found.

Note: result has to be free by a call to "free" function after use.

Example:

char *value = plugin->get_plugin_config (plugin, "my_var");

set_plugin_config

Prototype: int set_plugin_config (t_weechat_plugin *plugin, char *option, char *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:

  • plugin: pointer to plugin structure

  • option: name of option to update

  • value: new value for option

Return value: 1 if option was successfully updated, 0 if an error occurred.

Example:

plugin->set_plugin_config (plugin, "my_var", "value");

get_irc_color

Prototype: int get_irc_color (t_weechat_plugin *plugin, char *color_name)

Get IRC color index with name.

Arguments:

  • plugin: pointer to plugin structure

  • color_name: color name Allowed colors are:

    Color name Value
    white 0
    black 1
    blue 2
    green 3
    lightred 4
    red 5
    magenta 6
    brown 7
    yellow 8
    lightgreen 9
    cyan 10
    lightcyan 11
    lightblue 12
    lightmagenta 13
    gray 14
    lightgray 15

Return value: IRC color index, -1 if color is not found.

Example:

int color_blue = plugin->get_irc_color (plugin, "blue"); /* return 2 */

input_color

Prototype: void input_color (t_weechat_plugin *plugin, int color, int start, int length)

Add color in input buffer.

Arguments:

  • plugin: pointer to plugin structure

  • color: color for text (if < 0, then input buffer is refresh, and there's no change in input buffer content)

  • start: start position for color (if < 0, then mask is reinitialized)

  • length: length for color (if <= 0, then mask is reinitialized)

Return value: none.

Example:

plugin->input_color (plugin, plugin->get_irc_color (plugin, "blue"), 10, 5);

get_window_info

Prototype: t_plugin_window_info *get_window_info (t_weechat_plugin *plugin)

Return list of WeeChat windows.

Arguments:

  • plugin: pointer to plugin structure

Return value: linked list of WeeChat windows.

Type Field Description
int win_x horizontal position of window
int win_y vertical position of window
int win_width width of window
int win_height height of window
int win_width_pct width % (compared to parent window)
int win_height_pct height % (compared to parent window)
int num_buffer number of displayed buffer
t_plugin_window_info * prev_window pointer to previous window info
t_plugin_window_info * next_window pointer to next window info

Note: result has to be free by a call to "free_window_info" function after use.

Example:

t_plugin_window_info *window_info, *ptr_window;

window_info = plugin->get_window_info (plugin);
if (window_info)
{
    for (ptr_window = window_info; ptr_window; ptr_window = ptr_window->next_window)
    {
        plugin->print (plugin, NULL, NULL, "--- window info ---");
        plugin->print (plugin, NULL, NULL, "(%d,%d), size: %dx%d, %%size: %d%%x%d%%",
                       ptr_window->win_x, ptr_window->win_y,
                       ptr_window->win_width, ptr_window->win_height,
                       ptr_window->win_width_pct, ptr_window->win_height_pct);
        plugin->print (plugin, NULL, NULL, "num_buffer: %d", ptr_window->num_buffer);
    }
    plugin->free_window_info (plugin, window_info);
}
else
    plugin->print (plugin, NULL, NULL, "no window info!");

free_window_info

Prototype: void free_window_info (t_weechat_plugin *plugin, t_plugin_window_info *window_info)

Free memory used by window info list.

Arguments:

  • plugin: pointer to plugin structure

  • window_info: pointer to window info list returned by "get_window_info" function

Return value: none.

Example:

plugin->free_window_info (plugin, window_info);

get_buffer_info

Prototype: t_plugin_buffer_info *get_buffer_info (t_weechat_plugin *plugin)

Return list of WeeChat buffers.

Arguments:

  • plugin: pointer to plugin structure

Return value: linked list of WeeChat buffers.

Type Field Description
int type buffer type: 0=standard, 1=DCC, 2=raw IRC data
int number buffer number
int num_displayed number of windows displaying buffer
char * server_name server name for buffer (may be NULL)
char * channel_name channel name for buffer (may be NULL)
int notify_level notify level for buffer
char * log_filename log filename (NULL means not logging)
t_plugin_buffer_info * prev_buffer pointer to previous buffer info
t_plugin_buffer_info * next_buffer pointer to next buffer info

Note: result has to be free by a call to "free_buffer_info" function after use.

Example:

t_plugin_buffer_info *buffer_info, *ptr_buffer;

buffer_info = plugin->get_buffer_info (plugin);
if (buffer_info)
{
    for (ptr_buffer = buffer_info; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
    {
        plugin->print (plugin, NULL, NULL, "--- buffer info ---");
        plugin->print (plugin, NULL, NULL, "type: %d", ptr_buffer->type);
        plugin->print (plugin, NULL, NULL, "number: %d", ptr_buffer->number);
        plugin->print (plugin, NULL, NULL, "num_displayed: %d", ptr_buffer->num_displayed);
        plugin->print (plugin, NULL, NULL, "server: %s", ptr_buffer->server_name);
        plugin->print (plugin, NULL, NULL, "channel: %s", ptr_buffer->channel_name);
        plugin->print (plugin, NULL, NULL, "notify level: %d", ptr_buffer->notify_level);
        plugin->print (plugin, NULL, NULL, "log filename: %s", ptr_buffer->log_filename);
    }
    plugin->free_buffer_info (plugin, buffer_info);
}
else
    plugin->print (plugin, NULL, NULL, "no buffer info!");

free_buffer_info

Prototype: void free_buffer_info (t_weechat_plugin *plugin, t_plugin_buffer_info *buffer_info)

Free memory used by buffer info list.

Arguments:

  • plugin: pointer to plugin structure

  • buffer_info: pointer to buffer info list returned by "get_buffer_info" function

Return value: none.

Example:

plugin->free_buffer_info (plugin, buffer_info);

get_buffer_data

Prototype: t_plugin_buffer_data *get_buffer_info (t_weechat_plugin *plugin, char *server, char *channel)

Return content of buffer.

Arguments:

  • plugin: pointer to plugin structure

  • server: internal name of server

  • channel: channel name

Return value: buffer content (linked list of lines).

Type Field Description
time_t date date and time
char * nick nick
char * data line content (color codes are removed)
t_plugin_buffer_line * prev_line pointer to previous line
t_plugin_buffer_line * next_line pointer to next line

Note: result has to be free by a call to "free_buffer_data" function after use.

Example:

t_plugin_buffer_line *buffer_line, *ptr_line;
char text_time[256];

buffer_line = plugin->get_buffer_data (plugin);
if (buffer_line)
{
    for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line)
    {
        strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date)));
        plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s",
                       text_time, ptr_line->nick, ptr_line->data);
    }
    plugin->free_buffer_data (plugin, buffer_line);
}

free_buffer_data

Prototype: void free_buffer_data (t_weechat_plugin *plugin, t_plugin_buffer_line *buffer_line)

Free memory used by buffer line list.

Arguments:

  • plugin: pointer to plugin structure

  • buffer_line: pointer to buffer line list returned by "get_buffer_data" function

Return value: none.

Example:

plugin->free_buffer_data (plugin, buffer_line);

Compile plugin

Compile does not need WeeChat sources, only file "weechat-plugin.h".

To compile a plugin which has one file "toto.c" (under GNU/Linux):

$ gcc -fPIC -Wall -c toto.c
$ gcc -shared -fPIC -o libtoto.so toto.o

Load plugin into WeeChat

Copy "libtoto.so" file into system plugins directory (for example "/usr/local/lib/weechat/plugins") or into user's plugins directory (for example "/home/xxxxx/.weechat/plugins").

Under WeeChat:

/plugin load toto

Plugin example

Full example of plugin, which adds a /double command, which displays two times arguments on current channel (ok that's not very useful, but that's just an example!):

#include <stdlib.h>

#include "weechat-plugin.h"

char plugin_name[]        = "Double";
char plugin_version[]     = "0.1";
char plugin_description[] = "Test plugin for WeeChat";

/* "/double" command manager */

int double_cmd (t_weechat_plugin *plugin, int argc, char **argv,
                char *handler_args, void *handler_pointer)
{
    if (argv[2] && (argv[2][0] != '/'))
    {
        plugin->exec_command (plugin, NULL, NULL, argv[2]);
        plugin->exec_command (plugin, NULL, NULL, argv[2]);
    }
    return PLUGIN_RC_OK;
}

int weechat_plugin_init (t_weechat_plugin *plugin)
{
    plugin->cmd_handler_add (plugin, "double",
                             "Display two times a message",
                             "msg",
                             "msg: message to display two times",
                             NULL,
                             &double_cmd,
                             NULL, NULL);
    return PLUGIN_RC_OK;
}

void weechat_plugin_end (t_weechat_plugin *plugin)
{
    /* nothing done here */
}

Charset plugin

Charset plugin lets you encode or decode data using charsets, with 3 levels: global, by server, or by channel. This plugin is optional, but recommended: if it's not loaded, WeeChat can only read/write UTF-8 data.

Charset plugin should be autoloaded by WeeChat at startup. To be sure plugin is loaded, try: "/charset". If command is not found, then load plugin with command:

/plugin load charset

If plugin is not found, then you should compile again WeeChat with plugins and Charset support.

When Charset plugin starts, it displays terminal and internal charsets. Terminal charset depends on your locale, and internal is UTF-8. For example :

-P- Charset plugin starting, terminal charset: ISO-8859-15 (WeeChat internal: UTF-8)

Settings

  • To set global decode and encode charsets, use "/setp" command. For example:

    /setp charset.global.decode = ISO-8859-15
    /setp charset.global.encode = ISO-8859-15
    

    If global decode charset is not set (for example during first load of Charset plugin), it will be automatically set to terminal charset (if it's different from UTF-8), or by default to "ISO-8859-1". Default encode value is empty, so it sends by default with internal charset (UTF-8).

  • To set server charset, use "/charset" command on server buffer. If you give only charset, then it will set "decode" and "encode" values. For example:

    /charset ISO-8859-15

    It's equivalent to:

    /charset decode ISO-8859-15
    /charset encode ISO-8859-15
    

  • To set channel (or private) charset, use same commands as server, but on channel (or private) buffer.

FAQ

If you have problems with chars or accents using Charset plugin:

  • check that weechat-curses is linked to libncursesw (warning: needed on most distributions but not all) :

    ldd /path/to/weechat-curses

  • check charset line (on server buffer), you should see ISO-XXXXXX or UTF-8 for terminal charset. If you see ANSI_X3.4-1968 or other values, probably your locale is wrong.

  • setup global decode value, for example:

    /setp charset.global.decode = ISO-8859-15

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:

  • name: unique name to identify script (each script must have unique name)

  • version: script version

  • end_function: function called when script is unloaded (optional parameter, empty string means nothing is called at the end)

  • description: short description of script

  • charset: 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:

  • charset: 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: message

  • channel: name of channel to find buffer for message display

  • server: internal name of server to find buffer for message display

To display colored text, see the section called “print”.

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: message

To display colored text, see the section called “print”.

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")

print_infobar

Perl prototype: weechat::print_infobar(time, message);

Python prototype: weechat.print_infobar(time, message)

Ruby prototype: Weechat.print_infobar(time, message)

Lua prototype: weechat.print_infobar(time, message)

Display a message in infobar for a specified time.

Arguments:

  • time: time (in seconds) for displaying message (0 = never erased)

  • message: message

Return value: 1 if success, 0 if an error occurred.

Examples:

# perl
weechat::print_infobar(5, "message");

# python
weechat.print_infobar(5, "message")

# ruby
Weechat.print_infobar(5, "message")

-- lua
weechat.print_infobar(5, "message")

remove_infobar

Perl prototype: weechat::remove_infobar([count]);

Python prototype: weechat.remove_infobar([count])

Ruby prototype: Weechat.remove_infobar([count])

Lua prototype: weechat.remove_infobar([count])

Remove one or more messages in infobar stack.

Arguments:

  • count: number of messages to remove (if argument not given or <= 0, then all messages are removed)

Return value: 1 if success, 0 if an error occurred.

Examples:

# perl
weechat::remove_infobar(1);

# python
weechat.remove_infobar(1)

# ruby
Weechat.remove_infobar(1)

-- lua
weechat.remove_infobar(1)

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: message

  • channel: name of channel to find buffer for log

  • server: 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:

  • message: 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 the section called “msg_handler_add”).

  • function: 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:

  • command: the new command name, which may be an existing command (be careful, replaced command will not be available until script is unloaded)

  • function: function called when command is executed

  • arguments: short description of command arguments (displayed by /help command)

  • arguments_description: long description of command arguments (displayed by /help command)

  • completion_template: 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 the section called “cmd_handler_add”)

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: interval (in seconds) between two calls of function.

  • 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: 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:

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: name of IRC message or command

  • function: 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: 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: 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: 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:

  • type: 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)

  • message: 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: 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:

  • type: modifier type

  • message: message managed by modifier

  • function: 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: command

  • channel: name of channel for executing command

  • server: 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:

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 the section called “get_dcc_info”).

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 the section called “get_server_info”).

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 the section called “get_channel_info”).

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 the section called “get_nick_info”).

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:

  • option: 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:

  • option: name of option to update

  • value: 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:

  • option: 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:

  • option: name of option to update

  • value: 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 the section called “get_irc_color”).

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 the section called “get_window_info”).

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 the section called “get_buffer_info”).

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 the section called “get_buffer_data”).

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

Chapter 5. Authors / Support

Table of Contents

Authors
Contributors
Get support

This chapter lists authors and contributors for WeeChat, and shows ways to get support.

Authors

WeeChat is developed by:

Contributors

Following people contributed to WeeChat:

  • Jiri Golembiovsky - czech translation, patches

  • Rudolf Polzer - patches

  • Jim Ramsay - patches

  • Odin - SuSE RPM

  • Pistos - patches

  • Gwenn - patches

  • voroskoi - hungarian translation

  • Frank Zacharias - german translation

  • Pavel Shevchuk - russian translation

Get support

Before asking for support, be sure you've read documentation and FAQ provided with WeeChat (documentation is this document, if you don't read all lines until this sentence, you can start again!)