Skip to main content

miniirc_matrix

Available on PyPI.

A wrapper for miniirc (GitHub, GitLab) to allow bots or clients made in miniirc to join Matrix rooms with minimal code changes. Requires Python 3.8 or later.

How to use

To use miniirc_matrix, you already need to know how to use miniirc (GitHub, GitLab). Instead of creating a miniirc.IRC object, however, you need to use miniirc_matrix.Matrix.

  • ip is the address of the Matrix homeserver.
  • port is optional and will default to 443 if not specified and if ip doesn't have a port.
  • There is a token keyword argument that must contain the Matrix token.

Example: irc = miniirc_matrix.Matrix('matrix.org:443', token='my_token')

Channel names are currently room IDs and start with !. You may use a Matrix room alias (for example #matrix:matrix.org) in place of a room ID, however. Hopefully one day alias support will be added so that channel names can correspond to alias names.

Formatting is translated to and from Matrix's custom HTML format. Note that colours are not supported in incoming messages, although they mostly work in outgoing messages.

Obtaining a token

You must obtain a token to use miniirc_matrix. You can do this with miniirc_matrix.login(homeserver_address, username, password).

There is also miniirc_matrix.logout(homeserver_address, token) and miniirc_matrix.logout_all(homeserver_address, username, password) if you wish to invalidate your token.

Supported commands

The PRIVMSG (including CTCP ACTION/irc.me), NOTICE, TAGMSG, JOIN, and PART commands should work as expected.

Note that events sent before the client connects to Matrix are ignored. Your system must have an accurate clock for this to work properly.

Downloading media

Matrix has recently started to require authentication for media endpoints. By default, miniirc_matrix now translates media files into MXC URLs. It does, however, have a built-in HTTP proxy (disabled by default, see below).

Proxying requests (experimental)

Warning: I don't know how secure this is, it uses Python's http.server

If you want to convert media to a normal URL, for example for use with relay bots or code that expects normal links, you can provide a media_proxy_port argument to miniirc_matrix.Matrix.

miniirc_matrix.Matrix('example.com', token='my_token',
                      media_proxy_port=8080)

This will start a HTTP server on http://127.0.0.1:8080 to listen for ports. The server only listens on localhost.

To expose this to the public, you must use a reverse proxy, and should set up caching and some kind of rate limiting to prevent abuse. You can set the media_proxy_url keyword argument to the public proxy URL.

A HMAC is created based on a random key and URL to prevent using the proxy to fetch arbitrary attachment URLs. To make this value consistent across restarts, pass a bytes value to the media_proxy_key keyword argument.

Installation

You can install miniirc_matrix with pip install miniirc_matrix.

Metadata

Release files for miniirc-matrix 0.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for miniirc-matrix 0.0.13
File Size Uploaded Provenance Actions
miniirc_matrix-0.0.13.tar.gz 12.7 kB Without provenance Details for miniirc_matrix-0.0.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for miniirc-matrix 0.0.13
File Interpreter ABI Platform Actions
miniirc_matrix-0.0.13-py3-none-any.whl Python 3 none any Details for miniirc_matrix-0.0.13-py3-none-any.whl

Total release size: 25.6 kB

Release files / miniirc_matrix-0.0.13.tar.gz

Download URL miniirc_matrix-0.0.13.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
32ba0ccd2153a10816e9615c9170698b65d6ec6b60e89e025bdf20e29b47c6cc
BLAKE2b-256 checksum
How to use checksums
1b50f15f50b2a0770856000f70fc498828f021ac258ad865649b010b04d528e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / miniirc_matrix-0.0.13-py3-none-any.whl

Download URL miniirc_matrix-0.0.13-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84ea7a5e98b31e38aee51cb9a7911ae331136ffa1a90138b55aceb648ce6102b
BLAKE2b-256 checksum
How to use checksums
3ef8bbd63d206b324695249e0a459fa378ed6996483fa11f16b06f2444abd930
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Security for miniirc-matrix 0.0.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page