Skip to main content

Redirect input/output of a command into a matrix room

Project description

Summary

Redirects standard input/output of a command into a Matrix room.

pipe2matrix --homeserver <homeserver url> --auth_token <auth token> --admin_id <userid> [--admin_id <userid>...] ( --room_name <room name> | --room_id <room id> ) [--wait] [--log <log file>] [--] ( - | command args... )

pipe2matrix is somewhat similar to netcat, but for matrix. On the matrix side, pipe2matrix will either join an existing room, or will create a new room and invite the given ("admin") user(s) to the new room. On the local side, pipe2matrix will either start a given program, or will use its own standard input/output. After that, pipe2matrix will send all output of the child program as messages into the matrix room, and will feed all messages in the room as input into the child program. Once the child program completes, pipe2matrix will exit too.

Command-line arguments

  • --homeserver <homeserver url> The URL of the Matrix server with the bot's user account.
  • --auth_token <auth token> The authentication token of the bot's user account. See https://t2bot.io/docs/access_tokens/ for the instructions on how to get the auth token.
  • --admin_id <userid> The id of the user that should be invited by the bot. The --admin_id flag can be repeated multiple times, and each mentioned user will be invited into the room. This flag is ignored if joining an existing room.
  • --room_name <room name> The name of the room that will be created. This is incompatible with the --room_id option.
  • --room_id <room id> The room id of the room to talk in. The bot will try to join the room if it is not already in it. This is incompatible with the --room_name option.
  • --wait If this flag is present, the bot will not run the command until at least one of the invited users have joined the room, or until all have declined the invitation (in which case the bot will quit without ever running the command). The flag is ignored if joining an existing room.
  • --log <log file> The file to send the log to. If not present, log messages are printed to stderr. Because this is an early development, there are a lot of log messages...
  • command The command to run. If command is a single dash "-", the bot will pass its own standard input/output to/from the matrix room.

Caveats

  • End-to-end encryption is currently unsupported. I am not sure how much the interface will have to change to support it: pipe2matrix will probably need a persistent storage for the encryption keys; it is possible that authentication will have to be done with username and password instead of auth token.

  • pipe2matrix uses a heuristic to break the continuous output stream into messages. Currently:

    • Each line of output is a separate message.
    • If there is no new output for 5 seconds, an unfinished line of output will also be sent as a message.
  • There is no way to control the bot itself: all input is redirected to the child command. For example, there is no way to kill the command via Matrix interface.

    One notable exception: if you log in as bot and leave the room, the bot will send EOF to the subprocess or to the bot's stdout.

Contact

If you do use pipe2matrix, I'd appreciate if you let me know! You can find me on Matrix:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pipe2matrix-0.0.3.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipe2matrix-0.0.3-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file pipe2matrix-0.0.3.tar.gz.

File metadata

  • Download URL: pipe2matrix-0.0.3.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pipe2matrix-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e72a3cc555b1bb49d0c3d540f258237fddd6635e8a5c1fe11d650065285fcc62
MD5 2560e3c9499ec9613fe9645deda16adb
BLAKE2b-256 917e9db571a5df7eeb5e8944c0636eb000390ba4393276151afbf11b1f8f76ae

See more details on using hashes here.

File details

Details for the file pipe2matrix-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pipe2matrix-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pipe2matrix-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 64108029264d9f17d0a947652f55787f86a00ab874a3f23a5824bfbcfe23c366
MD5 1b35dad1d937d5853e168c334ea9b7bd
BLAKE2b-256 e5df70c42eaa3235224cc3e3ecda65e0d96c3c2673425efc3e9545470095b119

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page