4fddc50d6d9f3d82220a4e3264d792d54fc940cf
weechat-matrix-rs/

build-test-release #weechat-matrix license

What is weechat-matrix?

Weechat is an extensible chat client.

Matrix is an open network for secure, decentralized communication.

weechat-matrix-rs is a Rust plugin for Weechat that lets Weechat communicate over the Matrix protocol. This is a Rust rewrite of the weechat-matrix Python script.

Project status

This project is a work in progress and doesn't do much yet. It can connect to a Matrix server and send messages.

If you are interested in helping out take a look at the issue tracker.

Build

Install Rust and the native build dependencies first. On Debian or Ubuntu a typical build environment needs:

sudo apt install build-essential clang libclang-dev libsqlite3-dev pkg-config

Other distributions use different package names, but the important native pieces are a C/C++ compiler, clang/libclang, and SQLite development headers. The weechat-sys dependency has a bundled WeeChat plugin header (weechat-plugin.h) fallback. If you want to build against the exact WeeChat API installed on your system, install the matching development package (weechat-dev on Debian/Ubuntu) or point WEECHAT_PLUGIN_FILE at the full path to that header:

export WEECHAT_PLUGIN_FILE=/usr/include/weechat/weechat-plugin.h

If bindgen reports that stddef.h, libclang, or libLLVM is missing, check that the clang command-line tools, C/C++ compiler headers, and matching libclang package are installed. On minimal distributions the library package alone may not provide the compiler include paths that bindgen needs.

After the dependencies are installed the plugin can be compiled with:

cargo build --release

If you are developing on weechat-matrix-rs, use debug builds which are faster at the expense of plugin performance:

cargo build

On Linux this creates a libmatrix.so file in the target/release/ (target/debug for dev builds) folder. Rename it to matrix.so and copy it to your WeeChat plugin directory.

make install uses WeeChat's XDG data directory by default:

make install

This installs the release build to:

${XDG_DATA_HOME:-$HOME/.local/share}/weechat/plugins/matrix.so

Use PROFILE=debug for a debug build:

make install PROFILE=debug

On older WeeChat setups the plugin directory may instead live under $WEECHAT_HOME/plugins, commonly ~/.weechat/plugins/. Create the directory if needed and copy the renamed plugin there.

On macOS the built library extension is usually .dylib. WeeChat may need this extension enabled before it loads the plugin:

/set weechat.plugin.extension ".so,.dll,.dylib"

Rename target/release/libmatrix.dylib to matrix.dylib before copying it to your WeeChat plugin directory.

Debian / Ubuntu package

A .deb package can be built using cargo-deb. This requires Rust installed (via rustup, the recommended method).

First ensure cargo-deb is available:

cargo install cargo-deb

Then build the package with:

make deb

The resulting .deb package is placed in target/debian/. Install it with:

sudo dpkg -i target/debian/weechat-matrix_*.deb

Loading the plugin

Restart WeeChat after installing the plugin, or load it manually:

/plugin load matrix

Check that it is loaded with:

/plugin list

If WeeChat cannot find the plugin, check that the file is named matrix.so (matrix.dylib on macOS), that it is in a directory from WeeChat's plugin search path, and that .so/.dylib is enabled in weechat.plugin.extension.

Configuration

Configuration is completed primarily through the Weechat interface. First start WeeChat, make sure the plugin is loaded, and then issue the following commands (replace the placeholders in brackets [] with your own details):

  1. Add a server (make sure the url includes the scheme e.g. 'https://matrix.org'):

    /matrix server add [server-name] [server-url]
    
  2. Set your username and password:

    /set matrix-rust.server.[server-name].username [username]
    /set matrix-rust.server.[server-name].password [password]
    
  3. Now try to connect. The first connection can take a few minutes while the client syncs the account:

    /matrix connect [server-name]
    
  4. Automatically connect to the server:

    /set matrix-rust.server.[server-name].autoconnect on
    
  5. If everything works, save the configuration:

    /save
    

To hide join/leave noise from users who have not been active recently, add a WeeChat filter for Matrix smart-filter tags:

   /filter add matrix_smart * matrix_smart_filter *

The inactivity delay defaults to five minutes and can be changed with:

   /set matrix-rust.look.smart_filter_delay 300000

Helpful Commands

/help matrix will print information about the /matrix command.

/matrix help [command] will print information for subcommands, such as /matrix help server.

Room buffers accept normal message input after /matrix connect [server-name] has completed.

/matrix media download <mxc-uri> [file] downloads Matrix media through the logged-in client, including homeservers that require authenticated media. It refuses to overwrite an existing file. When [file] is omitted, the media id is saved with the configured prefix, which defaults to matrix-media-:

   /set matrix-rust.media.download_prefix matrix-media-

The prefix may include a directory and supports ~, $XDG_STATE_HOME, and ${XDG_STATE_HOME}. Parent directories are created automatically:

   /set matrix-rust.media.download_prefix "$XDG_STATE_HOME/weechat-matrix/media/matrix-media-"

About

Rust 97.6%Markdown 2.4%

12 contributorsDamir JelićDenis KasakJakub PanekDarafei PraliaskouskiValentin BrandlSandro SantilliPooya MoradiSanderAustin RayFredrik LankergoulovBogdan Dobrelya

Clone

SSH
git clone ssh://git@gitbay.org/librebro/weechat-matrix-rs.git
HTTPS
git clone https://gitbay.org/librebro/weechat-matrix-rs.git