@ -44,6 +44,9 @@ https://github.com/poljar/matrix-nio)
content repository
- new option ` - - separator ` to customize the column separator in outputs
- new option ` - - mxc - to - http `
- new option ` - - devices ` to list devices of current user
- new option ` - - discovery - info ` to print discovery info of homeserver
- new option ` - - login_info ` to get the available login methods from the server
# Summary, TLDR
@ -147,6 +150,9 @@ Please give it a :star: on Github right now so others find it more easily.
- Supports getting and setting display name
- Supports getting and setting presence
- Uploading and downloading to / from resource depository
- Listing your devices
- Listing discovery info
- Listing available login methods supported by server
- Supports skipping SSL verification to use HTTP instead of HTTPS
- Supports providing local SSL certificate files
- Supports notification via OS of received messages
@ -493,7 +499,10 @@ $ matrix-commander -m "{title: \"${TITLE}\", message: \"${MSG}\"}"
$ matrix - commander - m " Don ' t do this "
$ matrix - commander - m ' He said " No " to me. '
$ matrix - commander - - separator " || " # customize column separator in outputs
$ matrix - commander - - mxc - to - http mac : / / example . com / abc . . . # get HTTP
$ matrix - commander - - mxc - to - http mxc : / / example . com / abc . . . # get HTTP
$ matrix - commander - - devices # to list devices of matrix-commander
$ matrix - commander - - discovery - info # print discovery info of homeserver
$ matrix - commander - - login - info # list login methods
$ # example of how to use stdin, how to pipe data into the program
$ echo " Some text " | matrix - commander # send a text msg via pipe
$ echo " Some text " | matrix - commander - m - # long form to send text via pipe
@ -549,6 +558,7 @@ usage: matrix_commander.py [-h] [-d] [--log-level LOG_LEVEL [LOG_LEVEL ...]]
[ - - download DOWNLOAD ] [ - - joined - rooms ]
[ - - joined - members JOINED_MEMBERS [ JOINED_MEMBERS . . . ] ]
[ - - mxc - to - http MXC_TO_HTTP [ MXC_TO_HTTP . . . ] ]
[ - - devices ] [ - - discovery - info ] [ - - login - info ]
[ - - whoami ] [ - - no - ssl ]
[ - - ssl - certificate SSL_CERTIFICATE ] [ - - no - sso ]
[ - - file - name FILE_NAME ] [ - - key - dict KEY_DICT ]
@ -957,6 +967,13 @@ options:
corresponding HTTP URLs . The MXC URIs to provide look
something like this
' mxc://example.com/SomeStrangeUriKey ' .
- - devices Print the list of devices . All device of this account
will be printed , one device per line .
- - discovery - info Print discovery information about current homeserver .
Note that not all homeservers support discovery and an
error might be reported .
- - login - info Print login methods supported by the homeserver . It
prints one login method per line .
- - whoami Print the user id used by matrix - commander ( itself ) .
One can get this information also by looking at the
credentials file .
@ -1017,7 +1034,7 @@ options:
information program will continue to run . This is
useful for having version number in the log files .
You are running version 2.2 7 .0 2022 - 06 - 03. Enjoy , star on Github and
You are running version 2.2 8 .0 2022 - 06 - 03. Enjoy , star on Github and
contribute by submitting a Pull Request .
` ` `
@ -1121,11 +1138,12 @@ import magic
import pkg_resources
from aiohttp import ClientConnectorError , ClientSession , TCPConnector , web
from markdown import markdown
from nio import ( AsyncClient , AsyncClientConfig , DownloadError ,
EnableEncryptionBuilder , JoinedMembersError , JoinedRoomsError ,
JoinError , KeyVerificationCancel , KeyVerificationEvent ,
from nio import ( AsyncClient , AsyncClientConfig , DevicesError ,
DiscoveryInfoError , DownloadError , EnableEncryptionBuilder ,
JoinedMembersError , JoinedRoomsError , JoinError ,
KeyVerificationCancel , KeyVerificationEvent ,
KeyVerificationKey , KeyVerificationMac , KeyVerificationStart ,
LocalProtocolError , Login Response, MatrixRoom ,
LocalProtocolError , Login InfoError, Login Response, MatrixRoom ,
MessageDirection , PresenceGetError , PresenceSetError ,
ProfileGetAvatarResponse , ProfileGetDisplayNameError ,
ProfileSetDisplayNameError , RedactedEvent , RedactionEvent ,
@ -1152,7 +1170,7 @@ except ImportError:
# version number
VERSION = " 2022-06-03 "
VERSIONNR = " 2.2 7 .0"
VERSIONNR = " 2.2 8 .0"
# matrix-commander; for backwards compitability replace _ with -
PROG_WITHOUT_EXT = os . path . splitext ( os . path . basename ( __file__ ) ) [ 0 ] . replace (
" _ " , " - "
@ -4209,6 +4227,38 @@ async def action_mxc_to_http(client: AsyncClient, credentials: dict) -> None:
print ( f " { mxc } { SEP } { http } " )
async def action_devices ( client : AsyncClient , credentials : dict ) - > None :
""" List devices of account while already logged in. """
resp = await client . devices ( )
if isinstance ( resp , DevicesError ) :
gs . log . error ( f " devices failed with { resp } " )
else :
gs . log . debug ( f " devices successful with { resp } " )
print ( * resp . devices , sep = " \n " ) # one per line
async def action_discovery_info (
client : AsyncClient , credentials : dict
) - > None :
""" List discovery_info of home server while already logged in. """
resp = await client . discovery_info ( )
if isinstance ( resp , DiscoveryInfoError ) :
gs . log . error ( f " discovery_info failed with { resp } " )
else :
gs . log . debug ( f " discovery_info successful with { resp } " )
print ( resp )
async def action_login_info ( client : AsyncClient , credentials : dict ) - > None :
""" List login methods of home server while already logged in. """
resp = await client . login_info ( )
if isinstance ( resp , LoginInfoError ) :
gs . log . error ( f " login_info failed with { resp } " )
else :
gs . log . debug ( f " login_info successful with { resp } " )
print ( * resp . flows , sep = " \n " ) # one per line
async def action_whoami ( client : AsyncClient , credentials : dict ) - > None :
""" Get user id while already logged in. """
whoami = credentials [ " user_id " ]
@ -4281,6 +4331,12 @@ async def main_roomsetget_action() -> None:
await action_joined_members ( client , credentials )
if gs . pa . mxc_to_http :
await action_mxc_to_http ( client , credentials )
if gs . pa . devices :
await action_devices ( client , credentials )
if gs . pa . discovery_info :
await action_discovery_info ( client , credentials )
if gs . pa . login_info :
await action_login_info ( client , credentials )
if gs . pa . whoami :
await action_whoami ( client , credentials )
if gs . setget_action :
@ -4519,6 +4575,9 @@ def initial_check_of_args() -> None: # noqa: C901
or gs . pa . joined_rooms
or gs . pa . joined_members
or gs . pa . mxc_to_http
or gs . pa . devices
or gs . pa . discovery_info
or gs . pa . login_info
or gs . pa . whoami
) :
gs . setget_action = True
@ -5500,6 +5559,31 @@ def main(
" to provide look something like this "
" ' mxc://example.com/SomeStrangeUriKey ' . " ,
)
ap . add_argument (
# no single char flag
" --devices " ,
required = False ,
action = " store_true " ,
help = " Print the list of devices. All device of this "
" account will be printed, one device per line. " ,
)
ap . add_argument (
# no single char flag
" --discovery-info " ,
required = False ,
action = " store_true " ,
help = " Print discovery information about current homeserver. "
" Note that not all homeservers support discovery and an error "
" might be reported. " ,
)
ap . add_argument (
# no single char flag
" --login-info " ,
required = False ,
action = " store_true " ,
help = " Print login methods supported by the homeserver. "
" It prints one login method per line. " ,
)
ap . add_argument (
# no single char flag
" --whoami " ,