WeeChat DevCenter

plugins

Entries feed

Sunday, May 19 2024

API relay and remote connection

A brand new relay called "api" has been devleopped since 6 months : it's an HTTP REST API, which should in long term replace completey the "weechat" protocol.

The "api" relay provides the following key features:

  • easy client implementation: HTTP REST API, JSON input/output, use of ANSI color codes
  • automatic compression of responses (deflate, gzip, zstd and permessage-deflate for websocket)
  • data synchronization: real-time sync with websocket or polling with HTTP requests
  • no internal structures exposed: no use of pointers & complex structures like hdata
  • WeeChat itself can connect to another WeeChat using this protocol (also known as relay "remote")

Documentation: Relay API.

The new /remote command lets you connect to the "api" relay of another running WeeChat (it must expose the same API version).

To connect to a remote WeeChat, just add a relay on the remote (for TLS, which is recommended, replace api by tls.api):

/set relay.network.password "secr3t"
/relay add api 9000

On the client, supposing it's running on the same machine:

/remote add test http://localhost:9000 -password=secr3t
/remote connect test

Then all buffers of remote WeeChat are opened locally by relay and any text or command sent on these buffers are sent and executed on the remote WeeChat.

Input is also synchronized (from remote to local WeeChat only), so that remote buffers like /fset can be used locally, including keys like Alt+Enter to set input with a command to execute.
Only the local buffer mouse actions are not yet supported (ie you can not scroll the fset buffer with mouse).

Friday, January 7 2022

Zstandard compression in relay plugin

Zstandard compression has been added in weechat protocol of relay plugin (see important notes in the release notes).

It offers better and faster compression (on WeeChat side) and faster decompression (client side).

Example of a small message (53KB), default compression (20):

   WeeChat: obj: 2964/53611 bytes (zstd: 95%, 0,12ms)
   Client: decompressed (zstd): 53606 bytes, ratio: 95%, parsed in 0.67ms)
   WeeChat: obj: 3752/53611 bytes (zlib: 94%, 0,23ms), id: quiet
   Client: decompressed (zlib): 53606 bytes, ratio: 94%, parsed in 2.10ms)

Example of a big message (2.3MB), default compression (20):

   WeeChat: obj: 133280/2376095 bytes (zstd: 95%, 2,97ms), id: quiet
   Client: decompressed (zstd): 2376090 bytes, ratio: 95%, parsed in 15.03ms)
   WeeChat: obj: 345255/2376095 bytes (zlib: 86%, 12,72ms), id: quiet
   Client: decompressed (zlib): 2376090 bytes, ratio: 86%, parsed in 21.20ms)

So with the same compression level:

  • zstd is up to 4x faster on compression than zlib (WeeChat side)
  • zstd is up to 3x faster on decompression than zlib (client side)
  • compressed packets are up to 2.6x smaller with zstd than zlib.

Tuesday, July 2 2019

Python 3 by default

As scheduled in the Python 3 transition page, since July 1st 2019, the "python" plugin is now compiled with Python 3 by default.

The changes:

  • If Python 3 is found, the "python" plugin is compiled with Python 3.
  • If Python 3 is not found, the "python" plugin is not built at all (even if Python 2 is installed).

The CMake option "ENABLE_PYTHON3" has been renamed to "ENABLE_PYTHON2" (configure option "--enable-python2"). If this option is enabled, the "python" plugin is built with Python 2 (if found), with a fallback on Python 3.

The development packages for Debian and Ubuntu are now compiled with Python 3 (it should be available soon for Raspbian). The future stable versions (≥ 2.6) will be compiled with Python 3 as well.

Monday, June 26 2017

Fset plugin

A new plugin called "fset" (Fast Set) has been added: a built-in and highly customizable replacement for the script iset.pl, with tons of new features!

It has the same features as iset.pl:

  • list options in a dedicated buffer
  • filter options by file, section, name, value or changed options
  • all colors can be customized
  • bar with help on currently selected option
  • different color for values changed
  • display of inherited values
  • keys and input to toggle, add/sub, set, reset and unset options
  • mouse actions on buffer.

And it comes with many new features:

  • flexible format using evaluated expression and automatic size for columns
  • options can be displayed on multiple lines
  • integrated with /set command, using conditions (option fset.look.conditioncatchset)
  • advanced filtering: by type, by changed value (filter on name or value), and using an evaluated condition
  • sort of options (fset.look.sort)
  • append to value
  • mark of options, group actions
  • export of options in a file.

Screenshot (click for full size):

weechat_fset.png

Saturday, March 14 2015

New plugin Javascript

A new plugin called "javascript" has been added to WeeChat. You can now load and execute Javascript scripts in WeeChat!

This plugin uses Google's v8 engine.

WeeChat now supports Python, Perl, Ruby, Lua, Tcl, Guile and Javascript!

To load/unload JS scripts, you can use the /script or /javascript command.

An example of script is available here: https://weechat.org/files/temp/scripts/example.js.

Saturday, March 15 2014

Exec plugin

A new plugin called "exec" has been added, with command /exec.

The command /exec can execute external commands and display output in WeeChat.

It is similar to /shell (script shell.py), with major improvements:

  • run many commands at once,
  • send signals to commands,
  • send data on stdin of a command,
  • line numbers in output,
  • ANSI color support,
  • command timeout.

Other features coming soon: pipe output to WeeChat command or hsignal (to use in a trigger).

Monday, February 10 2014

Trigger plugin

A new plugin called "trigger" has been added.

This plugin can hook many things:

  • signal
  • hsignal
  • modifier
  • print
  • command
  • command_run
  • timer
  • config
  • focus

When the callback is called, trigger can:

  • check some conditions (to execute the trigger or not), which are evaluated (see /help eval)
  • replace some text using regular expression(s)
  • execute command(s)
  • have a custom return code.

Example of things you can do with trigger:

  • notification, for example beep on highlight/private message (it can replace script beep.pl or other scripts)
  • hide passwords in commands/messages (it will replace rmodifier plugin)
  • change content of messages displayed
  • change things displayed (nicklist, ...) when terminal becomes small
  • regularly save config files (with a timer)
  • ...

Help is available with /help trigger.

Some examples of triggers can be found on GitHub WeeChat wiki.

Thursday, January 9 2014

CRC32 and IPv6 in xfer plugin

CRC32 and IPv6 are now supported in xfer plugin!

For CRC32, a new option has been added:

  • xfer.file.auto_check_crc32 (boolean, off by default): when enabled, if the filename has a CRC32 (8 hexadecimal chars with delimiters around), the CRC32 of file content is checked and the result is displayed in xfer buffer (with error in core buffer if the CRC32 is wrong).

For IPv6, everything is automatic; it works for DCC file and chat.

Note for C plugin developers: the function "weechat_network_connect_to" has been modified to be used with IPv6. See the plugin API reference for more info.

A big thanks to Andrew Potter for the patches!

Enjoy!

Sunday, February 10 2013

WebSocket in relay plugin

Websocket has been added in relay plugin, for IRC and WeeChat protocols.

It is an experimental and partial implementation of RFC 6455: fragmentation and control frames are not yet supported.

The relay plugin automatically detects WebSocket handshake and if everything is OK (origin allowed and required headers received), an answer to handshake is sent and then socket is ready to send/receive WebSocket frames.

Text and binary data are supported, so IRC (text/text) and WeeChat (text/binary) protocols are supported.

Screenshot (click for full size):

relay_websocket.png

Tuesday, February 5 2013

Test script for relay protocol

A test script called testproto.py has been added in QWeeChat to test the relay protocol with WeeChat. This script runs in terminal and does not require Qt.

Script is located in path src/qweechat/weechat/testproto.py of QWeeChat repository.

Screenshot (click for full size):

testproto.png

Monday, December 24 2012

Backlog for irc protocol in relay

Backlog has been added for irc protocol in relay plugin.

The relay plugin now supports server capability "server-time", to include the messages time as tag (not in the message itself).

5 new options have been added:

  • relay.irc.backlog_max_minutes
  • relay.irc.backlog_max_number
  • relay.irc.backlog_since_last_disconnect
  • relay.irc.backlog_tags
  • relay.irc.backlog_time_format

Enjoy, and merry Christmas!

Tuesday, August 14 2012

Scripts manager

A new scripts manager has been added, the plugin is called "script" and provides the /script command.

This plugin will replace two scripts: weeget.py (the current scripts manager) and script.pl (providing a /script command to load/unload/reload scripts for any language).

The new /script command is similar to command /weeget with some minor differences (see /help script for more info).

The plugin provides a buffer with list of scripts in repository, which makes installation or removal of scripts very fast: just press alt+i on this buffer, and the script is installed! Not satisfied with the script? Key alt+r and the script is gone!

The buffer allows you to search string in scripts (description, tags, ...) and to sort scripts with many keys. Columns displayed can be fully customized (order, columns displayed), as well as colors.

For list of options, just do: /set script.*

List of scripts (click for full size):

Script plugin: list of scripts

Detail of a script (click for full size): Script plugin: detail of a script

Enjoy!

Friday, July 27 2012

SSL in Relay plugin

SSL support has been added in Relay plugin, for irc and weechat protocols.

A new option has been added to set the certificate and private key to use:

  • relay.network.ssl_cert_key: path to file with certificate and private key (default: ~/.weechat/ssl/relay.pem)

The file can be created with following commands:

$ mkdir -p ~/.weechat/ssl
$ cd ~/.weechat/ssl
$ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out relay.pem

In WeeChat :

/relay sslcertkey

And add relays with SSL, for example:

/relay add ssl.irc.freenode 8001
/relay add ssl.weechat 9001

And now WeeChat will serve clients on these ports using SSL, enjoy!

Tuesday, January 3 2012

Support of Python 3

WeeChat can now compile with Python 3.x (successfully tested with Python 3.1 and 3.2).
This is still experimental and recommended Python for WeeChat remains version 2.7.

Some scripts (including weeget.py) have been updated for Python 3.x, they have tag "py3k-ok" on the scripts page: https://weechat.org/scripts/stable/tag/py3k-ok/

Python versions supported by WeeChat:

  • 2.5: many scripts require at least 2.6 - NOT recommended
  • 2.6: all scripts should work fine
  • 2.7: recommended version (all scripts are guaranteed to work with this version)
  • 3.x: experimental, should be used only for tests

Note that "python" plugin in WeeChat can support only one version, so it can be a 2.x or 3.x, not both at same time.

Updated on 2019-07-01: Python 3 is now compiled by default and therefore the recommended version, see the post: Python 3 by default.

Thursday, October 27 2011

New plugin Guile

A new plugin called "guile" has been added to WeeChat. You can now load and execute Scheme scripts in WeeChat!

WeeChat now supports Python, Perl, Ruby, Lua, Tcl and Guile!

To load/unload scheme scripts, command is /guile with same syntax as other script languages:

/guile load /path/to/example.scm
/guile reload example
/guile unload example

An example of script:

;; example.scm
(weechat:register "example" "FlashCode" "0.1" "GPL3" "Scheme script" "" "")
(weechat:print "" "Hey, I'm a scheme script for WeeChat!")

Friday, April 15 2011

Options for aspell spellers

An "option" section has been added to aspell.conf file, to set options for aspell speller.

A commonly used option is "ignore-case" to ignore case in speller. To enable it, just do:

/set aspell.option.ignore-case "true"

For a list of aspell options, do in your shell:

aspell config

Wednesday, October 6 2010

New plugin rmodifier

A new plugin called "rmodifier" (for "Regex modifier") has been added.

It's designed to change some strings using regex, for example to hide passwords in commands (input displayed on screen) or in history. By default, password in following commands are hidden by this plugin:

  • /msg nickserv identify ****** (input and history)
  • /msg nickserv ghost ****** (input and history)
  • /oper nick ****** (input and history)
  • /set file.section.password ****** (history only)

Of course you can add your own regex, just look at /help rmodifier.

Updated on 2014-08-15: the plugin rmodifier has been replaced by trigger, introduced in version 1.0.

Monday, March 22 2010

Custom completion for aliases

It is now possible to have custom completion for aliases, for example to complete with another command completion, or with your own completion.

Examples:

  • create alias /forcejoin with completion of /sajoin: /alias -completion %%sajoin forcejoin /quote forcejoin
  • create alias /mybuf with custom completion: /alias -completion #weechat|#weechat-fr mybuf /buffer

You can change completion if alias is already created:

/set alias.completion.forcejoin "%%sajoin"

You can use empty string to prevent any completion for command (default is to complete using target command):

/set alias.completion.forcejoin ""

And you can remove a completion:

/unset alias.completion.forcejoin

Completion is automatically removed when you remove an alias with /unalias.

Monday, February 1 2010

Date in log filenames

It is now possible to use date formaters in log filenames (in mask options).

For example to have log by year and month in separate directories, you can do :

/set logger.file.mask "%Y/%m/$plugin.$name.weechatlog"

You'll have a tree like that:

~/.weechat/
    |- logs/
        |- 2009/
            |- 12/
                |  irc.server.freenode.weechatlog
                |  irc.freenode.#weechat.weechatlog
        |- 2010/
            |- 01/
                |  irc.server.freenode.weechatlog
                |  irc.freenode.#weechat.weechatlog

Monday, December 7 2009

SSL certificates

New options have been added to check SSL certificates when connecting to IRC servers, thanks to kolter's patch:

  • weechat.network.gnutls_ca_file: path to file with certificate authorities (by default: "%h/ssl/CAs.pem")
  • irc.server.xxx.ssl_cert: ssl certificate file used to automatically identify your nick (CertFP on oftc for example, see below)
  • irc.server.xxx.ssl_dhkey_size: replaces old option weechat.network.gnutls_dh_prime_bitsmax_lines, new default value is 2048 (safer than old default value which was 512)
  • irc.server.xxx.ssl_verify: check that the ssl connection is fully trusted (on by default)

Please note that ssl_verify is on by default, so verification is now stricter, and may fail even if it was ok with previous versions of WeeChat.

First example: connect to oftc and check certificate:

  • import certificate:
    • mkdir ~/.weechat/ssl
    • wget -O ~/.weechat/ssl/CAs.pem http://www.spi-inc.org/ca/spi-cacert.crt
  • in weechat:
    • /connect oftc

Note: it is possible to concatenate many CAs in file CAs.pem.

Second example: connect to oftc using CertFP (certificate to auto identify your nick):

  • create certificate:
    • openssl req -nodes -newkey rsa:2048 -keyout nick.key -x509 -days 365 -out nick.cer
    • cat nick.cer nick.key > ~/.weechat/ssl/nick.pem
  • in weechat:
    • /set irc.server.oftc.ssl_cert "%h/ssl/nick.pem"
    • /connect oftc
    • /msg nickserv cert add

For more information, please look at https://www.oftc.net/NickServ/CertFP.

Friday, March 6 2009

New hook "process"

New hook type "process" has been added to WeeChat. You can use it in C plugins, and all scripts languages (perl, python, ruby, lua and tcl).

It runs a command with fork, and send you result (return code, stdout and stderr) via a callback, when command has ended, or if WeeChat output buffer is full (then it will be partial result of command). There is optional timeout (in milliseconds), to kill process if it's still running after given time.

The script shell.py has been updated to use that new hook.

Wednesday, November 26 2008

New plugin DC

A new plugin has been added: DC. It is used to transfer files using DC file-sharing protocol.

It's available as a separate plugin, and must be compiled and installed with WeeChat development version.
Documentation and screenshots are available on this wiki page: http://wiki.flashtux.org/wiki/WeeChat/dc

Friday, October 31 2008

New logger features

Logger plugin has been improved with many new features:

  • command /logger (to see log status for open buffers, and set/disable log level on a buffer)
  • custom level by buffer (or group of buffers)
  • custom log filename mask by buffer (or group of buffers).

Set one directory by IRC server and a file by channel inside:

Do that: /set logger.mask.irc irc/$server/$channel.weechatlog

You'll have a tree like that:

~/.weechat/
    |- logs/
        |- irc/
            |--- freenode/
            |       freenode.weechatlog
            |       #weechat.weechatlog
            |       #mychan.weechatlog
            |--- oftc/
            |       oftc.weechatlog
            |       #chan1.weechatlog
            |       #chan2.weechatlog

Log all messages on IRC buffers but not join/part/quit messages:

  • for all IRC buffers: /set logger.level.irc 3
  • for a server and its channels: /set logger.level.irc.freenode 3
  • for a specific channel: /set logger.level.irc.freenode.#weechat 3

Saturday, October 18 2008

Aspell plugin is born again

New aspell plugin is available!

Plugin as now its own configuration file, called aspell.conf. Options can be set with /set command. List of options with default value:

  • aspell.look.color = lightred
  • aspell.check.commands = "ame,amsg,away,command,cycle,kick,kickban,me,msg,notice,part,query,quit,topic"
  • aspell.check.default_dict = ""
  • aspell.check.word_min_length = 2

You can enable aspell for all buffers with default dictionary (or list of dictionaries), with command: /set aspell.check.default_dict "en,fr"

To enable a specific language on a buffer, use: /aspell enable fr
If you speak both english and german (often english, less german), use: /aspell enable en,de

Monday, October 6 2008

New plugin Tcl

A new plugin Tcl has been added (thanks to Dmitry Kobylin). Some minor changes will be done about compiling (with autotools and cmake), but plugin should be ok today as-is.

Script samples using new API, including Tcl language, will be published soon.

Tuesday, May 6 2008

Xfer plugin

A new "xfer" plugin has been added. It replaces old IRC DCC code.
This plugin is called by IRC plugin to initiate direct chat and file transfer (still by /dcc command). In future, it may be used by other plugins. Moreover, new protocols can be easily added to xfer plugin, if other plugins need that.