8go / matrix-commander Goto Github PK
View Code? Open in Web Editor NEWsimple but convenient CLI-based Matrix client app for sending and receiving
License: GNU General Public License v3.0
simple but convenient CLI-based Matrix client app for sending and receiving
License: GNU General Public License v3.0
Been trying to make this work on Raspberry Pi 3 for several hours.
Currently running
python matrix-commander.py
results in this:
Traceback (most recent call last):
File "/home/pi/matrix-commander/matrix-commander.py", line 690, in
from nio import (
File "/home/pi/.local/lib/python3.9/site-packages/nio/init.py", line 2, in
from .client import *
File "/home/pi/.local/lib/python3.9/site-packages/nio/client/init.py", line 3, in
from .base_client import Client, ClientConfig
File "/home/pi/.local/lib/python3.9/site-packages/nio/client/base_client.py", line 35, in
from ..crypto import ENCRYPTION_ENABLED
File "/home/pi/.local/lib/python3.9/site-packages/nio/crypto/init.py", line 41, in
from .olm_machine import Olm
File "/home/pi/.local/lib/python3.9/site-packages/nio/crypto/olm_machine.py", line 54, in
from .sas import Sas
File "/home/pi/.local/lib/python3.9/site-packages/nio/crypto/sas.py", line 49, in
class Sas(olm.Sas):
AttributeError: module 'olm' has no attribute 'Sas'
EDIT: Got it working by deleting pip cache and reinstalling everything.
I'm looking for a way to make calls using command line or Python script.
Is it possible to make calls using matrix-commander?
Hi,
it would be great to be able to install simply via pip install matrix-commander
:)
Anyone interested in contributing this feature via a PR? ❤️
Installing dependencies would be much easier if a requirements.txt
file was provided. Then anyone could just create a virtualenv and run pip install -r requirements.txt
and be ready to go :).
matrix-nio 0.18.6 has requirement aiofiles<0.7.0,>=0.6.0, however in requirements.txt aiofiles has to be version 0.4 or 0.5.
Either it's needed to put some version restrictions on matrix-nio, or it's needed to make sure aiofiles 0.6 will work.
matrix-commander$ pip install -r requirements.txt
Collecting aiofiles<0.5.0,>=0.4.0
Using cached aiofiles-0.4.0-py3-none-any.whl (9.2 kB)
Collecting matrix-nio[e2e]>=0.14.1
Downloading matrix_nio-0.15.2-py3-none-any.whl (173 kB)
|████████████████████████████████| 173 kB 5.2 MB/s
Collecting aiohttp
Downloading aiohttp-3.7.3-cp38-cp38-manylinux2014_x86_64.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 7.4 MB/s
Collecting async-timeout<4.0,>=3.0
Using cached async_timeout-3.0.1-py3-none-any.whl (8.2 kB)
Collecting atomicwrites<2.0.0,>=1.3.0
Downloading atomicwrites-1.4.0-py2.py3-none-any.whl (6.8 kB)
Collecting attrs>=17.3.0
Downloading attrs-20.3.0-py2.py3-none-any.whl (49 kB)
|████████████████████████████████| 49 kB 4.4 MB/s
Collecting cachetools<5.0.0,>=4.0.0
Downloading cachetools-4.2.0-py3-none-any.whl (12 kB)
Collecting chardet<4.0,>=2.0
Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting future<0.19.0,>=0.18.2
Using cached future-0.18.2.tar.gz (829 kB)
Collecting h11<0.10.0,>=0.9.0
Using cached h11-0.9.0-py2.py3-none-any.whl (53 kB)
Collecting h2<4.0.0,>=3.2.0
Using cached h2-3.2.0-py2.py3-none-any.whl (65 kB)
Collecting hpack<4,>=3.0
Using cached hpack-3.0.0-py2.py3-none-any.whl (38 kB)
Collecting hyperframe<6,>=5.2.0
Using cached hyperframe-5.2.0-py2.py3-none-any.whl (12 kB)
Collecting jsonschema<4.0.0,>=3.2.0
Using cached jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
Requirement already satisfied: setuptools in /home/siena/bin/anaconda3/envs/py38env/lib/python3.8/site-packages (from jsonschema<4.0.0,>=3.2.0->matrix-nio[e2e]>=0.14.1->-r requirements.txt (line 7)) (51.0.0.post20201207)
Collecting logbook<2.0.0,>=1.5.3
Using cached Logbook-1.5.3.tar.gz (85 kB)
Collecting multidict<7.0,>=4.5
Downloading multidict-5.1.0-cp38-cp38-manylinux2014_x86_64.whl (159 kB)
|████████████████████████████████| 159 kB 5.3 MB/s
Collecting peewee<4.0.0,>=3.13.2
Downloading peewee-3.14.0.tar.gz (873 kB)
|████████████████████████████████| 873 kB 4.9 MB/s
Collecting pycryptodome<4.0.0,>=3.9.7
Downloading pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl (13.7 MB)
|████████████████████████████████| 13.7 MB 8.4 MB/s
Collecting pyrsistent>=0.14.0
Downloading pyrsistent-0.17.3.tar.gz (106 kB)
|████████████████████████████████| 106 kB 8.0 MB/s
Collecting python-olm<4.0.0,>=3.1.3
Using cached python-olm-3.1.3.tar.gz (27 kB)
Collecting cffi>=1.0.0
Using cached cffi-1.14.4-cp38-cp38-manylinux1_x86_64.whl (411 kB)
Collecting six>=1.11.0
Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting typing-extensions>=3.6.5
Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting unpaddedbase64<2.0.0,>=1.1.0
Using cached unpaddedbase64-1.1.0-py2.py3-none-any.whl (3.3 kB)
Collecting yarl<2.0,>=1.0
Downloading yarl-1.6.3-cp38-cp38-manylinux2014_x86_64.whl (324 kB)
|████████████████████████████████| 324 kB 6.8 MB/s
Collecting idna>=2.0
Downloading idna-3.0-py2.py3-none-any.whl (58 kB)
|████████████████████████████████| 58 kB 4.7 MB/s
Collecting argparse
Downloading argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Collecting asyncio
Downloading asyncio-3.4.3-py3-none-any.whl (101 kB)
|████████████████████████████████| 101 kB 5.7 MB/s
Collecting datetime
Downloading DateTime-4.3-py2.py3-none-any.whl (60 kB)
|████████████████████████████████| 60 kB 4.8 MB/s
Collecting markdown
Downloading Markdown-3.3.3-py3-none-any.whl (96 kB)
|████████████████████████████████| 96 kB 4.2 MB/s
Collecting notify2
Downloading notify2-0.3.1-py2.py3-none-any.whl (8.0 kB)
Collecting Pillow
Downloading Pillow-8.1.0-cp38-cp38-manylinux1_x86_64.whl (2.2 MB)
|████████████████████████████████| 2.2 MB 6.8 MB/s
Collecting python_magic
Downloading python_magic-0.4.18-py2.py3-none-any.whl (8.6 kB)
Collecting uuid
Downloading uuid-1.30.tar.gz (5.8 kB)
Collecting pycparser
Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Collecting pytz
Downloading pytz-2020.5-py2.py3-none-any.whl (510 kB)
|████████████████████████████████| 510 kB 7.7 MB/s
Collecting zope.interface
Downloading zope.interface-5.2.0-cp38-cp38-manylinux2010_x86_64.whl (244 kB)
|████████████████████████████████| 244 kB 6.5 MB/s
Building wheels for collected packages: future, logbook, peewee, pyrsistent, python-olm, uuid
Building wheel for future (setup.py) ... done
Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491059 sha256=76679b2f53206c03b761b36af5fb418ef06c3a8ec5e4aa3aab7887ee08b7b1be
Stored in directory: /home/siena/.cache/pip/wheels/8e/70/28/3d6ccd6e315f65f245da085482a2e1c7d14b90b30f239e2cf4
Building wheel for logbook (setup.py) ... done
Created wheel for logbook: filename=Logbook-1.5.3-cp38-cp38-linux_x86_64.whl size=66378 sha256=65c69a9b36bf99a83a6b9a51e1208082da44c922dc0271537a12e010e1bfdd29
Stored in directory: /home/siena/.cache/pip/wheels/25/9a/c0/03bf368ac5f673e9c0bde58837146b004424b25555ca3aedfb
Building wheel for peewee (setup.py) ... done
Created wheel for peewee: filename=peewee-3.14.0-py3-none-any.whl size=128142 sha256=54d73d0edafa5c87c52ea97667c9873ac63c9a66ce4e6d75e6054d8766ecdfce
Stored in directory: /home/siena/.cache/pip/wheels/f9/0c/4f/37984c77779105edbafffd114ac40820bfa4f1f1bf9ff6ed57
Building wheel for pyrsistent (setup.py) ... done
Created wheel for pyrsistent: filename=pyrsistent-0.17.3-cp38-cp38-linux_x86_64.whl size=126087 sha256=4e37bdd619298fcb183580f5f0c3b4786a9771188d053fbe51de3af54c67087f
Stored in directory: /home/siena/.cache/pip/wheels/3d/22/08/7042eb6309c650c7b53615d5df5cc61f1ea9680e7edd3a08d2
Building wheel for python-olm (setup.py) ... done
Created wheel for python-olm: filename=python_olm-3.1.3-cp38-cp38-linux_x86_64.whl size=160910 sha256=9ed2a082eaaf13554f1e975a4819ffae051b75daa5792d5fbf612b5570669803
Stored in directory: /home/siena/.cache/pip/wheels/1c/a0/53/ea4c79f60693fcef0951216bb94ee25545632e686403fbb438
Building wheel for uuid (setup.py) ... done
Created wheel for uuid: filename=uuid-1.30-py3-none-any.whl size=6501 sha256=4f57c5c65e4d923d04a1b6b883d0c9d77f1054ba0d09387332e5dfdeb0886096
Stored in directory: /home/siena/.cache/pip/wheels/1b/6c/cb/f9aae2bc97333c3d6e060826c1ee9e44e46306a178e5783505
Successfully built future logbook peewee pyrsistent python-olm uuid
Installing collected packages: multidict, idna, yarl, typing-extensions, six, pyrsistent, pycparser, hyperframe, hpack, chardet, attrs, async-timeout, unpaddedbase64, pycryptodome, logbook, jsonschema, h2, h11, future, cffi, aiohttp, aiofiles, zope.interface, pytz, python-olm, peewee, matrix-nio, cachetools, atomicwrites, uuid, python-magic, Pillow, notify2, markdown, datetime, asyncio, argparse
Successfully installed Pillow-8.1.0 aiofiles-0.4.0 aiohttp-3.7.3 argparse-1.4.0 async-timeout-3.0.1 asyncio-3.4.3 atomicwrites-1.4.0 attrs-20.3.0 cachetools-4.2.0 cffi-1.14.4 chardet-3.0.4 datetime-4.3 future-0.18.2 h11-0.9.0 h2-3.2.0 hpack-3.0.0 hyperframe-5.2.0 idna-3.0 jsonschema-3.2.0 logbook-1.5.3 markdown-3.3.3 matrix-nio-0.15.2 multidict-5.1.0 notify2-0.3.1 peewee-3.14.0 pycparser-2.20 pycryptodome-3.9.9 pyrsistent-0.17.3 python-magic-0.4.18 python-olm-3.1.3 pytz-2020.5 six-1.15.0 typing-extensions-3.7.4.3 unpaddedbase64-1.1.0 uuid-1.30 yarl-1.6.3 zope.interface-5.2.0
After installing all requirements it does not work:
matrix-commander$ ./matrix-commander.py
Traceback (most recent call last):
File "./matrix-commander.py", line 508, in <module>
import notify2
File "/home/siena/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/notify2.py", line 39, in <module>
import dbus
ModuleNotFoundError: No module named 'dbus'
Element sees when I do stuff with matrix-commander
and asks "New login. Was this you?" I say yeah and then Element says "Verify other session. Waiting for you to accept on your other session…" and spins a ball forever.
If the certificate is self-signed, or the homeserver does not have a domain (think the typical self-hosted Synapse in a private network) then certificate checking will fail. AsyncClient accepts ssl=False to disable the checks on the certificate, so matrix-commander could have a flag that disables them.
Does anyone use matrix-commander, if so, how? Ideally this would be for all rooms, not just a single room
Hi @8go ,
So sorry if it's a dumb question but can't seem to find the obvious on how to send Emojis in a room.
Tried with the usual 😃 but all I'm getting is the text and not the emoji equivalent.
Kind regards and TIA!
Bumps into TypeError: 'NoneType' object is not subscriptable
Happy to follow any advice on how to debug this or collect more info!
Below is the full log:
❯ ./result/bin/matrix-commander -d -d --credentials credentials.json --room-create commander-test
2021-05-01 17:07:29,240: DEBUG: matrix-commander: Debug is turned on. debug count=2
2021-05-01 17:07:29,240: DEBUG: matrix-commander: Encryption is always enabled. It cannot be turned off.
2021-05-01 17:07:29,240: DEBUG: matrix-commander: All arguments are valid. All checks passed.
2021-05-01 17:07:29,240: DEBUG: matrix-commander: Trying to create a PID file to store process id 1325900.
2021-05-01 17:07:29,240: DEBUG: matrix-commander: Successfully created PID file "/home/j/.run/matrix-commander.8c83b82a-637d-4a2a-9211-1ed4b2cc8d2d.pid" to store process id 1325900.
2021-05-01 17:07:29,240: DEBUG: asyncio: Using selector: EpollSelector
2021-05-01 17:07:29,241: DEBUG: matrix-commander: Credentials file existed. So this is the one we suggest to use. file: credentials.json
2021-05-01 17:07:29,241: DEBUG: matrix-commander: Found an existing store in directory "store" (local or arguments). It will be used.
2021-05-01 17:07:29,241: DEBUG: matrix-commander: Credentials file does exist.
2021-05-01 17:07:29,241: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "storeversion" ("id" INTEGER NOT NULL PRIMARY KEY, "version" INTEGER NOT NULL)', [])
2021-05-01 17:07:29,242: DEBUG: peewee: ('SELECT "t1"."id", "t1"."version" FROM "storeversion" AS "t1" LIMIT ? OFFSET ?', [1, 0])
2021-05-01 17:07:29,242: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "accounts" ("id" INTEGER NOT NULL PRIMARY KEY, "account" BLOB NOT NULL, "user_id" TEXT NOT NULL, "device_id" TEXT NOT NULL, "shared" INTEGER NOT NULL, UNIQUE(user_id,device_id))', [])
2021-05-01 17:07:29,243: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "devicekeys" ("id" INTEGER NOT NULL PRIMARY KEY, "device_id" TEXT NOT NULL, "user_id" TEXT NOT NULL, "display_name" TEXT NOT NULL, "deleted" INTEGER NOT NULL, "account_id" INTEGER NOT NULL, FOREIGN KEY ("account_id") REFERENCES "accounts" ("id") ON DELETE CASCADE, UNIQUE(account_id,user_id,device_id))', [])
2021-05-01 17:07:29,243: DEBUG: peewee: ('CREATE INDEX IF NOT EXISTS "devicekeys_account_id" ON "devicekeys" ("account_id")', [])
2021-05-01 17:07:29,243: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "encryptedrooms" ("id" INTEGER NOT NULL PRIMARY KEY, "room_id" TEXT NOT NULL, "account_id" INTEGER NOT NULL, FOREIGN KEY ("account_id") REFERENCES "accounts" ("id") ON DELETE CASCADE, UNIQUE(room_id,account_id))', [])
2021-05-01 17:07:29,243: DEBUG: peewee: ('CREATE INDEX IF NOT EXISTS "encryptedrooms_account_id" ON "encryptedrooms" ("account_id")', [])
2021-05-01 17:07:29,244: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "megolminboundsessions" ("session_id" TEXT NOT NULL PRIMARY KEY, "sender_key" TEXT NOT NULL, "account_id" INTEGER NOT NULL, "fp_key" TEXT NOT NULL, "room_id" TEXT NOT NULL, "session" BLOB NOT NULL, FOREIGN KEY ("account_id") REFERENCES "accounts" ("id") ON DELETE CASCADE)', [])
2021-05-01 17:07:29,244: DEBUG: peewee: ('CREATE INDEX IF NOT EXISTS "megolminboundsessions_account_id" ON "megolminboundsessions" ("account_id")', [])
2021-05-01 17:07:29,244: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "forwardedchains" ("id" INTEGER NOT NULL PRIMARY KEY, "sender_key" TEXT NOT NULL, "session_id" TEXT NOT NULL, FOREIGN KEY ("session_id") REFERENCES "megolminboundsessions" ("session_id") ON DELETE CASCADE, UNIQUE(sender_key,session_id))', [])
2021-05-01 17:07:29,244: DEBUG: peewee: ('CREATE INDEX IF NOT EXISTS "forwardedchains_session_id" ON "forwardedchains" ("session_id")', [])
2021-05-01 17:07:29,244: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "keys" ("id" INTEGER NOT NULL PRIMARY KEY, "key_type" TEXT NOT NULL, "key" TEXT NOT NULL, "device_id" INTEGER NOT NULL, FOREIGN KEY ("device_id") REFERENCES "devicekeys" ("id"), UNIQUE(device_id,key_type))', [])
2021-05-01 17:07:29,245: DEBUG: peewee: ('CREATE INDEX IF NOT EXISTS "keys_device_id" ON "keys" ("device_id")', [])
2021-05-01 17:07:29,245: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "olmsessions" ("session_id" TEXT NOT NULL PRIMARY KEY, "creation_time" TEXT NOT NULL, "last_usage_date" TEXT NOT NULL, "sender_key" TEXT NOT NULL, "account_id" INTEGER NOT NULL, "session" BLOB NOT NULL, FOREIGN KEY ("account_id") REFERENCES "accounts" ("id") ON DELETE CASCADE)', [])
2021-05-01 17:07:29,245: DEBUG: peewee: ('CREATE INDEX IF NOT EXISTS "olmsessions_account_id" ON "olmsessions" ("account_id")', [])
2021-05-01 17:07:29,245: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "outgoingkeyrequests" ("id" INTEGER NOT NULL PRIMARY KEY, "request_id" TEXT NOT NULL, "session_id" TEXT NOT NULL, "room_id" TEXT NOT NULL, "algorithm" TEXT NOT NULL, "account_id" INTEGER NOT NULL, FOREIGN KEY ("account_id") REFERENCES "accounts" ("id") ON DELETE CASCADE, UNIQUE(request_id,account_id))', [])
2021-05-01 17:07:29,246: DEBUG: peewee: ('CREATE INDEX IF NOT EXISTS "outgoingkeyrequests_account_id" ON "outgoingkeyrequests" ("account_id")', [])
2021-05-01 17:07:29,246: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "storeversion" ("id" INTEGER NOT NULL PRIMARY KEY, "version" INTEGER NOT NULL)', [])
2021-05-01 17:07:29,246: DEBUG: peewee: ('CREATE TABLE IF NOT EXISTS "synctokens" ("id" INTEGER NOT NULL PRIMARY KEY, "token" TEXT NOT NULL, "account_id" INTEGER NOT NULL, FOREIGN KEY ("account_id") REFERENCES "accounts" ("id") ON DELETE CASCADE, UNIQUE(account_id))', [])
2021-05-01 17:07:29,246: DEBUG: peewee: ('CREATE INDEX IF NOT EXISTS "synctokens_account_id" ON "synctokens" ("account_id")', [])
2021-05-01 17:07:29,247: DEBUG: peewee: ('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['thanos', 'matrix-commander', 1, 0])
2021-05-01 17:07:29,248: DEBUG: peewee: ('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['thanos', 'matrix-commander', 1, 0])
2021-05-01 17:07:29,249: DEBUG: peewee: ('SELECT "t1"."session_id", "t1"."creation_time", "t1"."last_usage_date", "t1"."sender_key", "t1"."account_id", "t1"."session" FROM "olmsessions" AS "t1" WHERE ("t1"."account_id" = ?)', [1])
2021-05-01 17:07:29,253: DEBUG: peewee: ('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['thanos', 'matrix-commander', 1, 0])
2021-05-01 17:07:29,253: DEBUG: peewee: ('SELECT "t1"."session_id", "t1"."sender_key", "t1"."account_id", "t1"."fp_key", "t1"."room_id", "t1"."session" FROM "megolminboundsessions" AS "t1" WHERE ("t1"."account_id" = ?)', [1])
2021-05-01 17:07:29,254: DEBUG: peewee: ('SELECT "t1"."id", "t1"."sender_key", "t1"."session_id" FROM "forwardedchains" AS "t1" WHERE ("t1"."session_id" = ?)', ['H94TfC7de42Nz1q8ocTi4MNksrBV5YztwvZa7lMHmdo'])
2021-05-01 17:07:29,255: DEBUG: peewee: ('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['thanos', 'matrix-commander', 1, 0])
2021-05-01 17:07:29,255: DEBUG: peewee: ('SELECT "t1"."id", "t1"."device_id", "t1"."user_id", "t1"."display_name", "t1"."deleted", "t1"."account_id" FROM "devicekeys" AS "t1" WHERE ("t1"."account_id" = ?)', [1])
2021-05-01 17:07:29,256: DEBUG: peewee: ('SELECT "t1"."id", "t1"."key_type", "t1"."key", "t1"."device_id" FROM "keys" AS "t1" WHERE ("t1"."device_id" = ?)', [1])
2021-05-01 17:07:29,256: DEBUG: peewee: ('SELECT "t1"."id", "t1"."key_type", "t1"."key", "t1"."device_id" FROM "keys" AS "t1" WHERE ("t1"."device_id" = ?)', [2])
2021-05-01 17:07:29,257: DEBUG: peewee: ('SELECT "t1"."id", "t1"."key_type", "t1"."key", "t1"."device_id" FROM "keys" AS "t1" WHERE ("t1"."device_id" = ?)', [3])
2021-05-01 17:07:29,258: DEBUG: peewee: ('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['thanos', 'matrix-commander', 1, 0])
2021-05-01 17:07:29,258: DEBUG: peewee: ('SELECT "t1"."id", "t1"."request_id", "t1"."session_id", "t1"."room_id", "t1"."algorithm", "t1"."account_id" FROM "outgoingkeyrequests" AS "t1" WHERE ("t1"."account_id" = ?)', [1])
2021-05-01 17:07:29,259: DEBUG: peewee: ('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['thanos', 'matrix-commander', 1, 0])
2021-05-01 17:07:29,260: DEBUG: peewee: ('SELECT "t1"."id", "t1"."room_id", "t1"."account_id" FROM "encryptedrooms" AS "t1" WHERE ("t1"."account_id" = ?)', [1])
2021-05-01 17:07:29,260: DEBUG: peewee: ('SELECT "t1"."id", "t1"."account", "t1"."user_id", "t1"."device_id", "t1"."shared" FROM "accounts" AS "t1" WHERE (("t1"."user_id" = ?) AND ("t1"."device_id" = ?)) LIMIT ? OFFSET ?', ['thanos', 'matrix-commander', 1, 0])
2021-05-01 17:07:29,261: DEBUG: peewee: ('SELECT "t1"."id", "t1"."token", "t1"."account_id" FROM "synctokens" AS "t1" WHERE ("t1"."account_id" = ?) LIMIT ? OFFSET ?', [1, 1, 0])
2021-05-01 17:07:29,261: DEBUG: matrix-commander: Logged in using stored credentials from credentials file "credentials.json".
2021-05-01 17:07:29,261: DEBUG: matrix-commander: Logged_in() = True
2021-05-01 17:07:29,261: ERROR: matrix-commander: Room creation failed. Sorry.
2021-05-01 17:07:29,262: DEBUG: matrix-commander: Here is the traceback.
Traceback (most recent call last):
File "./result/bin/matrix-commander", line 1665, in create_rooms
name = names[index]
TypeError: 'NoneType' object is not subscriptable
2021-05-01 17:07:29,262: DEBUG: matrix-commander: Room action(s) were performed or attempted. We close the client and quit
2021-05-01 17:07:29,262: DEBUG: matrix-commander: The program matrix-commander terminated successfully.
2021-05-01 17:07:29,262: DEBUG: matrix-commander: Cleanup: cleaning up.
messages take 30 seconds until they get sent
Hello !!
Thanks for this api !! I use it for a nice bot in Rust :)
Just a question: since your recent changes, I have notice that the log level is set to INFO & ERROR by default.
Before, I only had only ERROR by default.
I can just add "--log-level ERROR" to have only error ?
Thanks !!
Edits, replies and reactions are not supported. Other message relations are in the works, with varying support depending on the client (threads, generalized relations). Rather than opening an issue for each feature, and wait for this codebase to be updated, it's quicker for me to template-ize a real-world example into a script that emits json, to be piped into matrix-commander.
If credentials.json exists, but not store, I get a rather ugly traceback:
$ matrix-commander --listen
Could not find existing store directory anywhere. A new one will be created. It
will need to be verified. The store directory will be created in the directory
"store". Optionally, consider moving the persistent storage directory files
inside "store" into the directory "/home/tobias/.local/share/matrix-
commander/store" for a more consistent experience.
2021-07-30 12:48:32,436: ERROR: matrix-commander: The program matrix-commander failed. Sorry. Here is the traceback.
2021-07-30 12:48:32,438: ERROR: matrix-commander: Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/peewee.py", line 3080, in connect
self._state.set_connection(self._connect())
File "/usr/lib/python3.9/site-packages/peewee.py", line 3416, in _connect
conn = sqlite3.connect(self.database, timeout=self._timeout,
sqlite3.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/matrix-commander", line 2982, in main_listen
client, credentials = login_using_credentials_file(
File "/usr/bin/matrix-commander", line 2561, in login_using_credentials_file
client.restore_login(
File "/usr/lib/python3.9/site-packages/nio/client/base_client.py", line 407, in restore_login
self.load_store()
File "/usr/lib/python3.9/site-packages/nio/client/base_client.py", line 374, in load_store
self.store = self.config.store(
File "<string>", line 8, in __init__
File "/usr/lib/python3.9/site-packages/nio/store/database.py", line 640, in __post_init__
super().__post_init__()
File "/usr/lib/python3.9/site-packages/nio/store/database.py", line 115, in __post_init__
self.database.connect()
File "/usr/lib/python3.9/site-packages/peewee.py", line 3083, in connect
self._initialize_connection(self._state.conn)
File "/usr/lib/python3.9/site-packages/peewee.py", line 2917, in __exit__
reraise(new_type, new_type(exc_value, *exc_args), traceback)
File "/usr/lib/python3.9/site-packages/peewee.py", line 190, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3.9/site-packages/peewee.py", line 3080, in connect
self._state.set_connection(self._connect())
File "/usr/lib/python3.9/site-packages/peewee.py", line 3416, in _connect
conn = sqlite3.connect(self.database, timeout=self._timeout,
peewee.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/matrix-commander", line 4028, in <module>
asyncio.get_event_loop().run_until_complete(main_listen())
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/usr/bin/matrix-commander", line 3006, in main_listen
if client:
UnboundLocalError: local variable 'client' referenced before assignment
Hello,
after successfully sending a message I was returned with this message
matrix-commander.py:4041: DeprecationWarning: There is no current event loop
asyncio.get_event_loop().run_until_complete(main_send())
running with "debug" it seems it is returned rather early in the process:
2021-10-05 21:37:13,667: DEBUG: matrix-commander: Log level is set for module matrix-commander. log_level=DEBUG
2021-10-05 21:37:13,667: DEBUG: matrix-commander: Encryption is always enabled. It cannot be turned off.
2021-10-05 21:37:13,667: DEBUG: matrix-commander: All arguments are valid. All checks passed.
2021-10-05 21:37:13,667: DEBUG: matrix-commander: Trying to create a PID file to store process id.
2021-10-05 21:37:13,667: DEBUG: matrix-commander: Successfully created PID file to store process id.
matrix-commander.py:4041: DeprecationWarning: There is no current event loop
asyncio.get_event_loop().run_until_complete(main_send())
2021-10-05 21:37:13,668: DEBUG: matrix-commander: Credentials file existed. So this is the one we suggest to use.
2021-10-05 21:37:13,668: DEBUG: matrix-commander: Found an existing store in directory "store" (local or arguments). It will be used.
2021-10-05 21:37:13,668: DEBUG: matrix-commander: Credentials file does exist.
2021-10-05 21:37:13,688: DEBUG: matrix-commander: Logged in using stored credentials from credentials file.
2021-10-05 21:37:13,688: DEBUG: matrix-commander: Logged_in() = True
2021-10-05 21:37:13,688: DEBUG: matrix-commander: Room(s) were provided via command line.
[cut]
2021-10-05 21:37:14,170: DEBUG: matrix-commander: Messages were sent. We close the client and quit
2021-10-05 21:37:14,170: DEBUG: matrix-commander: The program matrix-commander.py left the event loop.
2021-10-05 21:37:14,170: DEBUG: matrix-commander: Cleanup: cleaning up.
environment was updated from python 3.8.12 to 3.10.0 today, and as far as i understand it is to be expected to get the aforementioned warning
not sure if it is something that really needs to be "handled", just thought to report it
regards,
m
I want to ask questions about this project, but am uncertain of where to.
Consequently, I believe that GitHub Discussions would be useful, because it allows questions to be asked without unnecessary triage and closure (as issues necessitate) like a forum does, and provides obvious demonstration of resolution. An example is https://github.com/orgs/community/discussions/5435#discussion-3553097:~:text=Any%20previously%20pending%20job%20or,docs.github.com/en/actions/reference/workflow%2Dsyntax%2Dfor%2Dgithub%2Dactions%23concurrency:
I am thankful for any consideration.
Dear Developers,
thank you for this nice command line utility. I have an encrypted 1on1 Chat that I would like to archive. Verification and room login has been successful. But the events received from the server are of the type "MegolmEvent", which is not handled. Any clues? I attached a sample of the event.
Message received for room XXX [XXXXX:matrix.org] | sender XXXXX [XXX] | 2021-08-06 21:28:22 | Received unknown event: MegolmEvent(source={'content': {'algorithm': 'm.megolm.v1.aes-sha2', 'ciphertext': 'AwgFEqAB8Nan2sc7IyEabZkXwKLUyz/tlrPxMwoTPHz4H8SLhuS0AD/K7DPhV1RpOJ5AgB2tobrW7CKH0trE5B7QMvp/6XcpKiSyKAWGTqsvl07rlHqGOqEPUf7PlSUtDZMvch3lYQaMHQBieSDT6+gNpJ2iiBlpdBxZlmavcCkzm8SXo3pDcL7JK9kt4GXkQLp7tWn6EJVQ2PkZnDa7MoMtfbYxd/Lo08OMXu+2Hnm83KE/xiaTyVw3cdgj3/UuGn+kUN0rWgCgCKhjID0IwMf9ldSQb1llQXc68B+Kd61l6cGtwuBkI53UpW2yCQ', 'device_id': 'LTUQENZNRX', 'sender_key': 'qxXN13jOmr4MlspZbmBqUB85FzyJuDt8m32HkLEefD0', 'session_id': 'mmsUFWpFsdxerIBDfNGhXlODh1Mhfo+TOPYyulJI3Sk'}, 'origin_server_ts': 1628278102151, 'room_id': '!rFTyESTNxkAoyZLznY:matrix.org', 'sender': 'XXXXXXX', 'type': 'm.room.encrypted', 'unsigned': {'age': 248567915}, 'event_id': '$fkJHAvQj3M_tKxZJRqvvY6kwfInGfkPwoF31E7kpcRM', 'user_id': 'XXXX', 'age': 248567915}, event_id='$fkJHAvQj3M_tKxZJRqvvY6kwfInGfkPwoF31E7kpcRM', sender='XXXXXX', server_timestamp=1628278102151, decrypted=False, verified=False, sender_key='qxXN13jOmr4MlspZbmBqUB85FzyJuDt8m32HkLEefD0', session_id='mmsUFWpFsdxerIBDfNGhXlODh1Mhfo+TOPYyulJI3Sk', transaction_id=None, device_id='LTUQENZNRX', ciphertext='AwgFEqAB8Nan2sc7IyEabZkXwKLUyz/tlrPxMwoTPHz4H8SLhuS0AD/K7DPhV1RpOJ5AgB2tobrW7CKH0trE5B7QMvp/6XcpKiSyKAWGTqsvl07rlHqGOqEPUf7PlSUtDZMvch3lYQaMHQBieSDT6+gNpJ2iiBlpdBxZlmavcCkzm8SXo3pDcL7JK9kt4GXkQLp7tWn6EJVQ2PkZnDa7MoMtfbYxd/Lo08OMXu+2Hnm83KE/xiaTyVw3cdgj3/UuGn+kUN0rWgCgCKhjID0IwMf9ldSQb1llQXc68B+Kd61l6cGtwuBkI53UpW2yCQ', algorithm='m.megolm.v1.aes-sha2', room_id='XXXX')
Hi. I was able to compile the Docker image for matrix-commander for use on my Raspberry Pi (4b, 32bit, running buster of Raspberry Pi OS). Sharing this information in case it is helpful to others. Thanks very much for Matrix Commander, I like that this E2EE client is so easy to use! The documentation is also excellent.
Changes I had to make for the Dockerfile:
A few observations and questions:
I have highlighted below the Docker file updates I made (they're in bold text). Thanks!
FROM fedora:33
RUN dnf install -y pip libolm-devel gcc python-devel python3-dbus libffi-devel libjpeg-devel zlib-devel
WORKDIR /app
COPY requirements.txt .
COPY matrix-commander.py .RUN pip3 install wheel && pip3 install -r /app/requirements.txt
VOLUME /data
ENTRYPOINT ["/bin/python3", "/app/matrix-commander.py" ,"-s", "/data/store", "-c", "/data/credentials.json"]
Add bash auto-complete file for bash auto completion when TAB is used.
I have wrote a bot program that pretends to be me for a specific reason.
I want to respond to a message that is gotten from matrix-commander.py --listen forever
How can I do it from a python program
There is more and more SSO login servers which prohibit explicit login and the only option is to re-use a previously generated login token. It would be cool to find an option in matrix-commander to set a token during initial setup.
Hello developers,
I tried to create a docker image as discribed docker/README.adoc, but it fails with a lot of messages like this:
Running transaction
Preparing : 1/1
Installing : python3-setuptools-49.1.3-2.fc33.noarch 1/33Error unpacking rpm package python3-setuptools-49.1.3-2.fc33.noarch
Installing : libmpc-1.1.0-9.fc33.armv7hl 2/33
error: unpacking of archive failed on file /usr/bin/easy_install;6113a251: cpio: utime failed - Inappropriate ioctl for device
error: python3-setuptools-49.1.3-2.fc33.noarch: install failed
My RaspPi:
System Information
------------------
Raspberry Pi 3 Model B Rev 1.2
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
Raspberry Pi reference 2021-03-04
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 461109415073d2eb67083709662ba983cc191f14, stage2
Linux raspberrypi-191 5.10.52-v7+ #1441 SMP Tue Aug 3 18:10:09 BST 2021 armv7l GNU/Linux
Revision : a02082
Serial : 00000000d88f6e6a
Model : Raspberry Pi 3 Model B Rev 1.2
Throttled flag : throttled=0x50000
Camera : supported=0 detected=0
Because I'm a newbie on dockers I'm not able to fix it for fedora and so I want to ask for help.
But I was able to create a docker image based on the matrix-nio/docker/Dockerfile.
I'm not sure if it's worth to share my Dockerfile or a fix for the current fedora Dockerfile is preferred.
Hi. I am wondering if we can use matrix-commander to send something that looks as good as the below screenshot, which was sent to Discord (using a Discord webhook): https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html
I see that matrix-commander supports a subset of HTML, but am wondering if anyone has some working example code/HTML snippets they could share. I am interested in what others have done to this point. I am just getting started, so looking forward to learning more about how far we can take the formatting of messages. 😄
I like Discord, but the things that annoy me about it are (a) I have no control over the data [it is stored on their servers] and (b) there is no end-to-end encryption. Hence I would like to use Matrix for this type of content, but am wondering if it is possible. Thanks.
I am trying to have a webhook (n8n or rundeck) call matrix through a execute command, however the workflow always hangs, it shows up in running process but doesn't send message until you manually stop the workflow or kill the process.
Works fine if I run it locally as a logged in user but fails if I use another program n8n or rundeck to run the program both hang which leads me to believe its matrix-commander keeping the process running for some reason
python3 /opt/matrix-commander/matrix-commander.py --log-level ERROR -c /opt/matrix-commander/credentials.json -s /opt/matrix-commander/store -m hi
2021-07-23 14:42:16,219: INFO: matrix-commander: Traceback (most recent call last):
File "/root/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1050, in create_connection
transport, protocol = await self._create_connection_transport(
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1080, in _create_connection_transport
await waiter
File "/usr/local/lib/python3.8/asyncio/sslproto.py", line 529, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/usr/local/lib/python3.8/asyncio/sslproto.py", line 189, in feed_ssldata
self._sslobj.do_handshake()
File "/usr/local/lib/python3.8/ssl.py", line 944, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'matrix.example.com'. (_ssl.c:1108)
How to skip this check?
It would be nice to have a sub-command to list all the members of a given room.
File "matrix-commander.py", line 3912, in <module>
if len(pargs.log_level) > 0:
TypeError: object of type 'NoneType' has no len()
I often share screenshots, it would be great to be able to pipe them in directly, rather than write them to a file, then send them.
Something like import -window 0x0000000 root png:- | matrix-commander -i
If you plan on having many credential files,
consider moving them to directory "/root/.config/matrix-commander".
can you give an example how multiple credentials can currently be used with matrix-commander?
Hi there!
What's the current status of this project? There had been rather constant development for a year but since roughly half a year there doesn't seem to be any activity anymore. Not complaining, just curious. It would be great to see this little gem flourish...
Thanks
I patched my local setup the way below, but a parameter would be cool to be able to use matrix-commander in company networks. Thank you for this cool peace of software:
diff -u matrix-commander.py.ORIG matrix-commander.py.01.w.proxy.SAV
--- matrix-commander.py.ORIG 2021-03-12 15:15:23.747356000 +0100
+++ matrix-commander.py.01.w.proxy.SAV 2021-03-12 15:20:19.495094000 +0100
@@ -2424,6 +2424,7 @@
# Initialize the matrix client
client = AsyncClient(
homeserver, user_id, store_path=store_dir, config=client_config,
+ proxy="http://10.50.50.3:8118",
)
pw = getpass.getpass()
@@ -2497,6 +2498,7 @@
device_id=credentials["device_id"],
store_path=store_dir,
config=client_config,
+ proxy="http://10.50.50.3:8118",
)
client.restore_login(
user_id=credentials["user_id"],
I'm trying to send JSON data elements as a message to my Matrix room, using Matrix Commander. It is working really great for regular messages (thanks!), but for JSON I was getting weird results. But then I realized I had a quoting issue.
I'm sure this is obvious to others, but it tripped me up for a while (or, maybe it is just too late and I need to go to bed 😆 ). Let me summarize my journey.
I figured out I could get Matrix Commander to send message as code by using -k -m {message}
(or --code -m {message}
), per the info at https://github.com/8go/matrix-commander#examples-of-calling-matrix-commander.
Trying to simulate sending JSON data as code, by sending message surrounded in braces containing 2 elements, with data for each element in quotes. This results in 3 messages sent.. realized it was because -m
is expecting a parameter that was quoted, and I was trying to quote yet again, so double quoting was happening and 3 messages were sent instead of just 1:
pi@pi:$ docker run --rm -v ./data:/data matrix-commander -k -m "{title: "hello", message: "here it is"}"
2021-04-08 05:27:32,532: INFO: matrix-commander: This message was sent: "{title: hello, message: here" to room "!{roomId}:matrix.org".
2021-04-08 05:27:33,027: INFO: matrix-commander: This message was sent: "it" to room "!{roomId}:matrix.org".
2021-04-08 05:27:33,496: INFO: matrix-commander: This message was sent: "is}" to room "!{roomId}:matrix.org".
pi@pi:$
When I try the same thing but with the data elements having no quotes, it sends only 1 message as expected.
pi@pi:$ docker run --rm -v ./data:/data matrix-commander -k -m "{title: hello, message: here it is}"
2021-04-08 05:28:29,902: INFO: matrix-commander: This message was sent: "{title: hello, message: here it is}" to room "!{roomId}:matrix.org".
pi@pi:$
It also works with single quotes.
pi@pi:$ docker run --rm -v ./data:/data matrix-commander -k -m "{title: 'hello', message: 'here it is'}"
2021-04-08 05:29:32,252: INFO: matrix-commander: This message was sent: "{title: 'hello', message: 'here it is'}" to room "!{roomId}:matrix.org".
And, finally, got it working like I wanted by using -m '{message}'
.. note the single quotes around the parameter for -m
below
pi@pi:$ docker run --rm -v ./data:/data matrix-commander --code -m '{title: "hello", message: "here it is"}'
2021-04-08 05:48:58,278: INFO: matrix-commander: This message was sent: "{title: "hello", message: "here it is"}" to room "!{roomId}:matrix.org".
I realize this may be obvious, but perhaps it would be helpful to include a note about this in the documentation? That is: If the message to be sent needs to include quotes, then ensure the parameter to -m
is surrounded in single quotes.
Thanks for considering my suggestion! 😄
doing:
--room-create 'testroom'
--room-invite '#testroom:synapse' --user '@botuser:synapse'
--room '#testroom:synapse' -m "Message 03"
results in:
[..]
InviteMemberEvent |{"type": "m.room.member", "sender": "@adminuser:synapse", "state_key": "@botuser:synapse", "origin_server_ts": 1629096986208, "unsigned": {"age": 85}, "event_id": "$9KQFUrY0oAPuSJhgB7KvCjSCW4RZ5OE_ua7SSEjjPQw"}
[..]
RoomEncryptionEvent |{"type": "m.room.encryption", "sender": "@adminuser:synapse", "content": {"algorithm": "m.megolm.v1.aes-sha2", "rotation_period_ms": 604800000, "rotation_period_msgs": 100}, "state_key": "", "origin_server_ts": 1629096983123, "unsigned": {"age": 3317}, "event_id": "$l75sfByabw6j7-_wqhFJWaDmNHAWrQU-mjZtpkPmF0E"}
[..]
RoomMessageText |{"content": {"msgtype": "m.text", "body": "Message 03"}, "type": "m.room.message", "room_id": "!bsXeDqiUpZvrPbtfFd:synapse", "event_id": "$Rczfwb96Qk22lUFX9Euk0EoLj2upxx4eM0f1NkpNVHQ", "sender": "@adminuser:synapse", "origin_server_ts": 1629096989732}
[..]
... where the last event should be m.room.encrypted
instead of m.room.message
...
seems like matrix-commander
didn't see/know its own m.room.encryption
event, so that state wasn't preserved correctly?
For this, we need to know the event ID. Maybe print those too on the start of the line with a switch?
Installing collected packages: asyncio, argparse, python_magic, Pillow, importlib-metadata, cachetools, atomicwrites, python-olm, markdown, datetime, matrix-nio
Running setup.py install for python-olm ... error
error: subprocess-exited-with-error
× Running setup.py install for python-olm did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
make: *** No rule to make target '../include/olm/olm.h', needed by 'include/olm/olm.h'. Stop.
I know this isn't an issue with this repo, as i can't even get pip to install olm at all. I can compile it from the .git, though, but i am evidently too tired to get pip to recognize it. Should i complain to matrix's issues?
I was hoping to not have to code API access in python, but it looks like i might have to >.<
From reading the source of send_file or send_image, I believe any attachment is uploaded unecrypted and will be readable for anyone in possession of the URL. Matrix documentation states that must be encrypted using one-time key and iv resp. and the decryption information be included with the room event.
Currently running matrix-commander on raspberry pi 4. Using Python-3.9.5.
It used to work, but then it just stopped working. Here's what happens if I manually start it.
~/matrix-commander $ python matrix-commander.py --version
_| | ||| _| matrix-commander
|| || _| _| a Matrix CLI client
_| _| _| _| _|
_| _| _| _| version 2021-May-25
_| | ||| _| enjoy and submit PRs
2021-07-02 21:53:47,759: INFO: matrix-commander: The program matrix-commander.py failed. Sorry. Here is the traceback.
2021-07-02 21:53:47,772: INFO: matrix-commander: Traceback (most recent call last):
File "/home/pi/matrix-commander/matrix-commander.py", line 3137, in main_send
client, credentials = login_using_credentials_file(
File "/home/pi/matrix-commander/matrix-commander.py", line 2561, in login_using_credentials_file
client.restore_login(
File "/home/pi/.local/lib/python3.9/site-packages/nio/client/base_client.py", line 407, in restore_login
self.load_store()
File "/home/pi/.local/lib/python3.9/site-packages/nio/client/base_client.py", line 383, in load_store
self.olm = Olm(self.user_id, self.device_id, self.store)
File "/home/pi/.local/lib/python3.9/site-packages/nio/crypto/olm_machine.py", line 213, in init
account = self.store.load_account() # type: ignore
File "/home/pi/.local/lib/python3.9/site-packages/nio/store/database.py", line 166, in load_account
return OlmAccount.from_pickle(
File "/home/pi/.local/lib/python3.9/site-packages/nio/crypto/sessions.py", line 45, in from_pickle
account = super().from_pickle(pickle, passphrase)
File "/home/pi/.local/lib/python3.9/site-packages/olm/account.py", line 166, in from_pickle
obj._check_error(ret)
File "/home/pi/.local/lib/python3.9/site-packages/olm/account.py", line 99, in _check_error
raise OlmAccountError(last_error)
olm.account.OlmAccountError: UNKNOWN_PICKLE_VERSION
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/matrix-commander/matrix-commander.py", line 4041, in
asyncio.get_event_loop().run_until_complete(main_send())
File "/usr/local/opt/python-3.9.5/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/pi/matrix-commander/matrix-commander.py", line 3155, in main_send
if client:
UnboundLocalError: local variable 'client' referenced before assignment
EDIT:
I deleted credentials.json and STORE directory and started all over. However, when I'm trying to verify via terminal, I finally get this error:
python matrix-commander.py --verify
This program is ready and waiting for the other party to initiate an emoji verification with us by selecting "Verify by Emoji"in their Matrix client.
2021-07-02 23:47:37,897: INFO: matrix-commander: The program matrix-commander.py failed. Sorry. Here is the traceback.
2021-07-02 23:47:37,907: INFO: matrix-commander: Traceback (most recent call last):
File "/home/pi/matrix-commander/matrix-commander.py", line 4019, in
asyncio.get_event_loop().run_until_complete(main_verify())
File "/usr/local/opt/python-3.9.5/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/pi/matrix-commander/matrix-commander.py", line 3122, in main_verify
await client.sync_forever(timeout=30000, full_state=True)
File "/home/pi/.local/lib/python3.9/site-packages/nio/client/async_client.py", line 1155, in sync_forever
sync_response = await self.sync(use_timeout, use_filter, since, full_state, presence)
File "/home/pi/.local/lib/python3.9/site-packages/nio/client/async_client.py", line 1028, in sync
response = await self._send(
File "/home/pi/.local/lib/python3.9/site-packages/nio/client/async_client.py", line 743, in _send
resp = await self.create_matrix_response(
File "/home/pi/.local/lib/python3.9/site-packages/nio/client/async_client.py", line 520, in create_matrix_response
resp = response_class.from_dict(parsed_dict, *data)
File "/home/pi/.local/lib/python3.9/site-packages/nio/responses.py", line 178, in wrapper
return f(cls, parsed_dict, *args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/nio/responses.py", line 1761, in from_dict
rooms = SyncResponse._get_room_info(parsed_dict["rooms"])
File "/home/pi/.local/lib/python3.9/site-packages/nio/responses.py", line 1697, in _get_room_info
for room_id, room_dict in parsed_dict["invite"].items():
KeyError: 'invite'
cannot get past this.
It doesn't help if I log in with my username via browser and complete verifications etc, matrix-commander shows the same above message. I cannot send a single message.
I have created an account on my homeserver for my bot. I cloned this repo and made a virtualenv with the required modules. I then invoked ./matrix-commander.py
and put in my details. At no point did it ask for my recovery key, so it cannot read any messages in encrypted rooms, it cannot do verification, and the messages it does send come up as 'not encrypted'. How do I give the bot the recovery key?
My up-to-date matrix-commander can send via matrix.org and members of the room can read it.
$ ./matrix-commander.py -m "Test $(date)"
2021-02-14 13:25:56,602: INFO: matrix-commander: This message was sent: "Test So 14 Feb 2021 13:25:46 UTC" to room "!xXyYzZroomroom:matrix.org".
When I start receiving, I can receive on single message, the one just sent.
Sending further messages (second terminal) or someone answering in the room, absolutely nothing happens.
But when someone in the room deletes his message, matrix-commander receives this redaction event.
Could someone please give me advice to dig deeper.
Log
command and login:
$ ./matrix-commander.py --debug --log-level INFO --listen forever --listen-self
2021-02-14 13:26:02,743: DEBUG: matrix-commander: Debug is turned on. debug count=1
2021-02-14 13:26:02,743: WARNING: matrix-commander: Debug option -d overwrote option --log-level.
2021-02-14 13:26:02,743: DEBUG: matrix-commander: Encryption is always enabled. It cannot be turned off.
2021-02-14 13:26:02,743: DEBUG: matrix-commander: All arguments are valid. All checks passed.
2021-02-14 13:26:02,744: DEBUG: matrix-commander: Trying to create a PID file to store process id 9057.
2021-02-14 13:26:02,744: DEBUG: matrix-commander: Successfully created PID file "/home/me/.run/matrix-commander.eba51492-11ab-423e-ab84-3a1a9dcba3fe.pid" to store process id 9057.
2021-02-14 13:26:02,744: DEBUG: matrix-commander: Credentials file existed. So this is the one we suggest to use. file: credentials.json
2021-02-14 13:26:02,744: DEBUG: matrix-commander: Found an existing store in directory "store" (local or arguments). It will be used.
2021-02-14 13:26:02,744: DEBUG: matrix-commander: Credentials file does exist.
2021-02-14 13:26:02,761: DEBUG: matrix-commander: Logged in using stored credentials from credentials file "credentials.json".
2021-02-14 13:26:02,761: DEBUG: matrix-commander: Logged_in() = True
2021-02-14 13:26:02,761: DEBUG: matrix-commander: Listening type: forever
This program is ready and listening for its Matrix messages. To stop program type Control-C on keyboard or send signal to process 9057. PID can also be found in file "/home/me/.run/matrix-commander.eba51492-11ab-423e-ab84-3a1a9dcba3fe.pid".
Receive the first message from self:
2021-02-14 13:26:06,023: DEBUG: matrix-commander: message_callback(): for room <nio.rooms.MatrixRoom object at 0x7d211fe9dc70> received this event: type: <class 'nio.events.room_events.RoomMessageText'>, event_id: $2lG6S1VkC28vnVna4VdeFc3RKLfhamPhPOuBXNWmhQ, event: @mybot:matrix.org: Test So 14 Feb 2021 13:25:46 UTC
2021-02-14 13:26:06,024: DEBUG: matrix-commander: event.server_timestamp = 1613309156506
2021-02-14 13:26:06,024: DEBUG: matrix-commander: event_datetime = 2021-02-14 13:25:56
2021-02-14 13:26:06,024: DEBUG: matrix-commander: type(msg) = <class 'str'>. msg is a string
2021-02-14 13:26:06,024: DEBUG: matrix-commander: Message received for room myRoom [!xXyYzZroomroom:matrix.org] | sender mybot [@mybot:matrix.org] | 2021-02-14 13:25:56 | Test So 14 Feb 2021 13:25:46 UTC
Message received for room myRoom [!xXyYzZroomroom:matrix.org] | sender mybot [@mybot:matrix.org] | 2021-02-14 13:25:56 | Test So 14 Feb 2021 13:25:46 UTC
Nothing happens even multiple messages have been sent to the room
Someone deleted his message. The redaction event however is received:
2021-02-14 13:27:32,836: DEBUG: matrix-commander: message_callback(): for room
oom object at 0x7fe9d211dc70> received this event: type: <class 'nio.events.room_e
nt'>, event_id: $eqAsAxzw8k2HOjWWVyLe0uw3wbRdDEvBJktf34WtYUc, event: RedactionEven
': {}, 'origin_server_ts': 1613309252216, 'redacts': '$bJMEkcPyep9UR0Zb37Xazg0x2mC
'sender': '@mymatrix:matrix.org', 'type': 'm.room.redaction', 'unsigned': {'age': 15
eqAsAxzw8k2HOjWWVyLe0uw3wbRdDEvBJktf34WtYUc'}, event_id='$vBJktfk2HOj3wbRdDEWWeqAs
c', sender='@mymatrix:matrix.org', server_timestamp=1613309252216, decrypted=False, v
der_key=None, session_id=None, transaction_id=None, redacts='$bJMEkcPyep9UR0Zb37Xa
KvLWk', reason=None)
2021-02-14 13:27:32,836: DEBUG: matrix-commander: event.server_timestamp = 1613
2021-02-14 13:27:32,837: DEBUG: matrix-commander: event_datetime = 2021-02-14 1
2021-02-14 13:27:32,837: DEBUG: matrix-commander: type(msg) = <class 'str'>. ms
2021-02-14 13:27:32,837: DEBUG: matrix-commander: Message received for room vBo
OoQDal:matrix.org] | sender mymatrix [@mymatrix:matrix.org] | 2021-02-14 13:27:32 | Rece
nt: sender: @mymatrix:matrix.org, redacts: $bp9UR0Zb5KKphJME37Xazg0x2mCJV6kcPyelSZKvL
Message received for room myRoom [!xXyYzZroomroomxXyYzZroomroom:matrix.org] | sender mymatrix [
| 2021-02-14 13:27:32 | Received redaction event: sender: @mymatrix:matrix.org, reda
R0ZJVKb37Xa65KKphlSZzg0x2mCvLWk
Hi,
First of all thanks a lot for this very helpful little utility!
I have created a specific matrix account on my homeserver for a matrix-commander instance, using another client, and have gone through the initial setup, with everything working ok. I can now send messages and read them.
I then invited the matrix-commander account into a room (with several other accounts), and wanted to send messages there, but these don't arrive, and it appears to be because I can't "accept" this invitation from the command line using matrix-commander, is this correct?
I guess if it is the case this issue could be seen as a feature-request. I feel matrix-commander is already so close to being a complete client, if this is not implemented yet it would be wonderful to have it.
Thanks again for all the great work.
Regards,
Mark.
I'm using an ARM processor (Raspberry Pi 4B, 32-bit OS, Raspberry Pi OS/buster). Compiled my own docker image of Matrix Commander and I've noticed a given example doesn't seem to work on my system. Could this be a bug?
Example given at https://github.com/8go/matrix-commander#examples-of-calling-matrix-commander, in the documentation, to send a message as code:
df -h | matrix-commander.py --code # formatting for code/tables
However, when I run it, this doesn't work.. bug? Just runs then exits to terminal with no output. I verified the room didn't receive any data.
df -h | docker run --rm -v ./data:/data matrix-commander --code
Thanks for any info! 😉
Hello,
while I execute the matrix-commander.py for the first time, I got this error
Could not find existing store directory anywhere. A new one will be created. It
will need to be verified. The store directory will be created in the directory
"store". Optionally, consider moving the persistent storage directory files
inside "store" into the directory "/home/hjk/.local/share/matrix-
commander/store" for a more consistent experience.
2022-04-27 23:04:25,819: ERROR: matrix-commander: The program matrix-commander.py failed. Sorry. Here is the traceback.
2022-04-27 23:04:25,853: ERROR: matrix-commander: Traceback (most recent call last):
File "/home/hjk/sunflower/utils/matrix-commander/matrix-commander.py", line 3137, in main_send
client, credentials = login_using_credentials_file(
File "/home/hjk/sunflower/utils/matrix-commander/matrix-commander.py", line 2543, in login_using_credentials_file
credentials = read_credentials_from_disk(credentials_file)
File "/home/hjk/sunflower/utils/matrix-commander/matrix-commander.py", line 1419, in read_credentials_from_disk
return json.load(f)
File "/usr/lib/python3.9/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/hjk/sunflower/utils/matrix-commander/matrix-commander.py", line 4041, in <module>
asyncio.get_event_loop().run_until_complete(main_send())
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/hjk/sunflower/utils/matrix-commander/matrix-commander.py", line 3155, in main_send
if client:
UnboundLocalError: local variable 'client' referenced before assignment
I see that there's a problem in json package.. but not sure.
Could anyone give a solution for this?
Hello. Is it possible for matrix-commander to send DMs (direct message) to a matrix account without a prior room name?
I am thinking of using matrix-commander as a notification medium but cannot entirely automate the process if a room name is needed on every DM.
Kind regards
First of, kudos for a really easy to setup command line client for matrix. This opens a bunch of possibilities !
I'd like to be able to archive photos that are send in a room and matrix-commander seems a good fit for this whist keeping it simple.
matrix-commander.py --listen tail --tail 4 --listen-self
Message received for room octoprint_encrypted [!xxx:matrix.org] | sender Arthur [@xxx:matrix.org] | 2020-09-19 17:02:34 | Received encrypted image: photo.png [https://matrix.org/_matrix/media/r0/download/matrix.org/abcdefg12345]
wget https://matrix.org/_matrix/media/r0/download/matrix.org/abcdefg12345
[snip]
file abcdefg12345
abcdefg12345: data
Obviously (and that's good news actually) the file is encryted.
Any chance of getting the file unencrypted though matrix-nio ?
for i in $(seq 1 10); do matrix-commander --message $i & ; done
Running the above yields:
peewee.OperationalError: database is locked
errorsUnable to decrypt: The secure channel with the sender was corrupted
ERROR: matrix-commander: Message send failed. Sorry.
with no tracebackIt would be excellent if multiple instances of this program could run concurrently, or at the very least wait politely for a while for any siblings to finish.
Hello,
not sure if this goes here or should be reported to nio library as it's the one that seems to really be erroring out,
today i started getting "room is not existent" errors when trying to send a message from a cron script,
i however know for sure the room id is correct as other crons which do a plain curl call are correctly working,
now that i tried adding debug level i can not reproduce it anymore, which is weird by itself
tried the listening mode to exclude issues with the room and got the traceback below
matrix-commander lives in its own pyenv which just today got updated from 3.8.10 to 3.8.11,
i recreated the env, so likely all the dependencies have been updated too, full "pip freeze" is at the end,
matrix-commander is at commit 06b4738
side issue: the message "The program matrix-commander.py failed. Sorry. Here is the traceback." should not be "INFO" level
$ python matrix-commander.py -dd -l once
2021-07-01 21:38:10,277: DEBUG: matrix-commander: Debug is turned on. debug count=2
2021-07-01 21:38:10,277: DEBUG: matrix-commander: Encryption is always enabled. It cannot be turned off.
2021-07-01 21:38:10,277: DEBUG: matrix-commander: All arguments are valid. All checks passed.
2021-07-01 21:38:10,277: DEBUG: matrix-commander: Trying to create a PID file to store process id ###.
2021-07-01 21:38:10,277: DEBUG: matrix-commander: Successfully created PID file "/home/user/.run/matrix-commander.<uuid>.pid" to store process id ###.
2021-07-01 21:38:10,277: DEBUG: asyncio: Using selector: EpollSelector
2021-07-01 21:38:10,278: DEBUG: matrix-commander: Credentials file existed. So this is the one we suggest to use. file: credentials.json
2021-07-01 21:38:10,278: DEBUG: matrix-commander: Found an existing store in directory "store" (local or arguments). It will be used.
2021-07-01 21:38:10,278: DEBUG: matrix-commander: Credentials file does exist.
2021-07-01 21:38:10,299: DEBUG: peewee: <cut>
2021-07-01 21:38:10,300: DEBUG: matrix-commander: Logged in using stored credentials from credentials file "credentials.json".
2021-07-01 21:38:10,300: DEBUG: matrix-commander: Logged_in() = True
2021-07-01 21:38:10,300: DEBUG: matrix-commander: Listening type: once
2021-07-01 21:38:11,000: INFO: matrix-commander: The program matrix-commander.py failed. Sorry. Here is the traceback.
2021-07-01 21:38:11,312: INFO: matrix-commander: Traceback (most recent call last):
File "matrix-commander.py", line 2901, in listen_all
resp_s = await client.sync(timeout=10000, full_state=True)
File "/home/user/.pyenv/versions/matrix-commander/lib/python3.8/site-packages/nio/client/async_client.py", line 1028, in sync
response = await self._send(
File "/home/user/.pyenv/versions/matrix-commander/lib/python3.8/site-packages/nio/client/async_client.py", line 743, in _send
resp = await self.create_matrix_response(
File "/home/user/.pyenv/versions/matrix-commander/lib/python3.8/site-packages/nio/client/async_client.py", line 520, in create_matrix_response
resp = response_class.from_dict(parsed_dict, *data)
File "/home/user/.pyenv/versions/matrix-commander/lib/python3.8/site-packages/nio/responses.py", line 178, in wrapper
return f(cls, parsed_dict, *args, **kwargs)
File "/home/user/.pyenv/versions/matrix-commander/lib/python3.8/site-packages/nio/responses.py", line 1761, in from_dict
rooms = SyncResponse._get_room_info(parsed_dict["rooms"])
File "/home/user/.pyenv/versions/matrix-commander/lib/python3.8/site-packages/nio/responses.py", line 1697, in _get_room_info
for room_id, room_dict in parsed_dict["invite"].items():
KeyError: 'invite'
2021-07-01 21:38:11,312: DEBUG: matrix-commander: The program matrix-commander.py terminated successfully.
2021-07-01 21:38:11,312: DEBUG: matrix-commander: Cleanup: cleaning up.
aiofiles==0.4.0
aiohttp==3.7.4.post0
aiohttp-socks==0.5.5
async-timeout==3.0.1
asyncio==3.4.3
atomicwrites==1.4.0
attrs==21.2.0
cachetools==4.2.2
cffi==1.14.5
chardet==4.0.0
DateTime==4.3
future==0.18.2
h11==0.9.0
h2==3.2.0
hpack==3.0.0
hyperframe==5.2.0
idna==3.2
jsonschema==3.2.0
Logbook==1.5.3
Markdown==3.3.4
matrix-nio==0.17.0
multidict==5.1.0
peewee==3.14.4
Pillow==8.3.0
pycparser==2.20
pycryptodome==3.10.1
pyrsistent==0.18.0
python-magic==0.4.24
python-olm==3.1.3
python-socks==1.2.4
pytz==2021.1
six==1.16.0
typing-extensions==3.10.0.0
unpaddedbase64==1.1.0
uuid==1.30
yarl==1.6.3
zope.interface==5.4.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.