Coder Social home page Coder Social logo

moan0s / matrix-registration-bot Goto Github PK

View Code? Open in Web Editor NEW
62.0 3.0 10.0 182 KB

A bot that is used to create and manage registration tokens for a matrix server

License: GNU Affero General Public License v3.0

Python 92.69% Dockerfile 4.20% Jinja 3.12%

matrix-registration-bot's Introduction

Matrix Registration Bot

Pypi badge License Docker pulls

This bot aims to create and manage registration tokens for a matrix server. It wants to help invitation based servers to maintain usability. It does not create a user itself, but allows registration only with a valid token as defined by Matrix standard MSC3231. The benefit is, that an administrator minimizes manual work and does not know a user's password at any time.

This means, that a user that registers on your server has to provide a registration token to successfully create an account. The token can be created by interacting with this bot. So to invite a friend you would send create to the bot which answers with a token. You send the token to the friend, and they can use this to create an account.

The feature was added in Matrix v1.2. More information can be found in the Synapse Documentation .

If you have any questions, or if you need help setting it up, read the troublshooting guide or join #matrix-registration-bot:hyteck.de.

Supported commands

Unrestricted commands

  • help: Shows this help

Restricted commands

  • list: Lists all registration tokens
  • show <token>: Shows token details in human-readable format
  • create: Creates a token that that is valid for one registration for seven days
  • delete <token> Deletes the specified token(s)
  • delete-all Deletes all tokens
  • allow @user:example.com Allows the specified user (or a user matching a regex pattern) to use restricted commands
  • disallow @user:example.com Stops a specified user (or a user matching a regex pattern) from using restricted commands

Permissions

By default, any user on the homeserver of the bot is allowed to use restricted commands. You can change that, by using the allow command to configure one (or multiple) specific user. Read the simple-matrix-bot documentation for more information. If you get locked out for any reason, simply modify the config.toml that is created in the bots working directory.

Getting started

If you already installed your homeserver with this ansible playbook you can make use of a very simple setup. Check out the setup instructions in the project's repo.

Prerequisites for all other installation methods

Server configuration

Your server should be configured to a token restricted registration. Add the following to your homeserver.yaml:

enable_registration: true
registration_requires_token: true

Create a bot account

Then you need to create an account for the bot on the server, like you would do with any other account. A good username is registration-bot. If you want to use token based login, note the access token of the bot. One way to get the token is to log in as the bot and got to Settings -> Help & About -> Access Token in Element, however you mustn't log out or the token will be invalidated. As an alternative you can use the command

curl -X POST --header 'Content-Type: application/json' -d '{
    "identifier": { "type": "m.id.user", "user": "YourBotUsername" },
    "password": "YourBotPassword",
    "type": "m.login.password"
}' 'https://matrix.YOURDOMAIN/_matrix/client/r0/login'

Once you are finished you can start the installation of the bot.

Manual Installation

The installation can easily be done via PyPi

$ pip install matrix-registration-bot

Configuration

Configure the bot with a file named config.yml. It should look like this

bot:
  server: "https://synapse.example.com"
  username: "registration-bot"
  access_token: "verysecret"
  # It is also possible to use a password based login by commenting out the access token line and adjusting the line below
  # password: "secretpassword"
  prefix: ""
api:
  # API endpoint of the registration tokens
  base_url: 'https://synapse.example.com'
  # Access token of an administrator on the server. If you configured the bot to be an admin on the sever you can use the same token as above.
  token: "supersecret"
logging:
  level: DEBUG/INFO/ERROR

It is also possible to use environment variables to configure the bot. The variable names are all upper case, concatenated with _ e.g. LOGGING_LEVEL.

Start the bot

Start the bot with

python -m matrix_registration_bot.bot

and then open a Direct Message to the bot. The type one of the following commands.

Automatically (re-)start the bot with Systemd

To have the bot start automatically after reboots create the file /etc/systemd/system/matrix-registration-bot.service with the following content on your server. This assumes you use that you place your configuration in /matrix/matrix-registration-bot/config.yml.

[Unit]
Description=matrix-registration-bot

[Service]
Type=simple

WorkingDirectory=/matrix/matrix-registration-bot
ExecStart=python3 -m matrix_registration_bot.bot

Restart=always
RestartSec=30
SyslogIdentifier=matrix-registration-bot

[Install]
WantedBy=multi-user.target

After creating the service reload your daemon and start+enable the service.

$ sudo systemctl daemon-reload
$ sudo systemctl start matrix-registration-bot
$ sudo systemclt enable matrix-registration-bot

Install using docker-compose

To use this container via docker you can create the following docker-compose.yml and start the container with docker-compose up -d. Explanation on how to obtain the correct values of the configuration can be found in the Manual installation section.

version: "3.7"

services:
  matrix-registration-bot:
    image: moanos/matrix-registration-bot:latest
    environment:
      LOGGING_LEVEL: DEBUG
      BOT_SERVER: "https://synapse.example.com"
      BOT_USERNAME: "registration-bot"
      BOT_PASSWORD: "password"
      API_BASE_URL: 'https://synapse.example.com'
      API_TOKEN: "syt_xxxxxxxxxxxxxxxxxxxxxxxx"

git checkout de

End-to-End Encryption

From version 1.2.0 the bot supports E2E encryption. This is a bit safer and also allows to create direct messages (which are by default encrypted). This will be enabled by default.

Contributing

Feel free to contribute or discuss this bot at #matrix-registration-bot:hyteck.de or simply open issues and PRs here.

Code of Conduct

Related Projects

matrix-registration-bot's People

Contributors

bziemons avatar harharlinks avatar moan0s avatar noobping avatar olivercoad avatar rocuevas9511 avatar subdestagesmitextrakaese avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

matrix-registration-bot's Issues

Single allowed user with 'allow' command is broken

Adding a single user using the 'allow' command followed by a user address will lock out everyone from using restricted commands.
When adding a user via the command in config.toml:
allowlist = [ "re.compile('[@user:example.com]')",]

Manually adding just the user address will work:
allowlist = [ "@user:example.com",]

Check if service is still healthy

I suggest adding a health check to the docker-compose.yml file.
I can create a pull request for this, but I am unsure which would be the best way to check if the service is still healthy.

I am grateful for any help!

Bot crashes when attempting to invite

Hey, first I want to say thanks for this project- it's made delegating invites on my server much nicer :).

I've been running 1.1.5 successfully for nearly a year now, but python recently updated and I had to reinstall the bot. I ended up with 1.2.2 (according to __init__.py), and tried starting it up but ran into #23 (I'm using a virtualenv, not docker). So I switched to using the access token and it started up successfully, but it wouldn't respond to any messages, so I left the channel and recreated it, but now it crashes whenever I try to invite the bot. I tried reverting to 1.1.5 and have the same problem there, so I assume it's either something that changed with synapse or (most likely based on the log) either python or a dependency.

Here's the log:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/matrix_registration_bot/bot.py", line 203, in <module>
    run_bot()
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/matrix_registration_bot/bot.py", line 195, in run_bot
    bot.run()
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/simplematrixbotlib/bot.py", line 88, in run
    asyncio.run(self.main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/simplematrixbotlib/bot.py", line 81, in main
    await self.async_client.sync_forever(timeout=3000, full_state=True)
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 1199, in sync_forever
    await self.run_response_callbacks([await response])
                                       ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 605, in _wait_for_one
    return f.result()  # May raise f.exception().
           ^^^^^^^^^^
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 1046, in sync
    response = await self._send(
               ^^^^^^^^^^^^^^^^^
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 792, in _send
    await self.receive_response(resp)
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 704, in receive_response
    await self._handle_sync(response)
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 669, in _handle_sync
    await self._handle_invited_rooms(response)
  File "/var/lib/matrix-registration-bot/lib/python3.11/site-packages/nio/client/async_client.py", line 576, in _handle_invited_rooms
    await asyncio.coroutine(cb.func)(room, event)
          ^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?
2023-05-30 20:58:29,269 ERROR:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f119c045010>
2023-05-30 20:58:29,270 ERROR:Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f119c1fd5c0>, 15377.595381204)]']
connector: <aiohttp.connector.TCPConnector object at 0x7f119c044410>

Thanks!

Access token invalid after admin client log off

Using an administrator access token in config.yml is not a durable deployment, since an administrator account logout destroys the token.

It would be better to use a shared secret that persists such as the homeserver.yaml registration_shared_secret:

or am I missing a method that creates an admin access token that persists?

Docker Secrets

https://docs.docker.com/engine/swarm/secrets/

The docker container should be able to utilize docker secrets in accessing sensitive information, such as the bot's password and the API key. This can be done with docker secrets, and reading the value from a file (/run/secrets/<secret_name>). The docker image would need to support reading the current environment variables (or a subset of them) from a file. The standard way of doing this is to append _FILE to the end of the env var name, and reading from that file if the original env var is empty. So then a user could create a docker secret named bot_password and set the environment variable BOT_PASSWORD_FILE to /run/secrets/bot_password.

For a working example, see PostgresSQL

Uninstall with ansible

The ansible roles could also provide a uninstall role that is triggered by matrix-registration-bot-enabled=false.
In the main.yml it would look like this:

- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
  when: "run_setup|bool and not matrix_registration_bot_enabled|bool"
  tags:
    - setup-all
    - setup-matrix-registration-bot

Can't build latest version

Hi,

This doesn't docker build on version 1.2.2. It has an error when trying to setup python-olm

This means it is broken with matrix-docker-ansible-deploy on arm64 because the only image published is for amd64, so it builds the latest version instead of pulling the pre-build docker image.

#7 25.78   Running setup.py install for logbook: started
#7 26.14   Running setup.py install for logbook: finished with status 'done'
#7 27.25   DEPRECATION: future is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
#7 27.25   Running setup.py install for future: started
#7 27.83   Running setup.py install for future: finished with status 'done'
#7 27.93   DEPRECATION: atomicwrites is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
#7 27.93   Running setup.py install for atomicwrites: started
#7 28.18   Running setup.py install for atomicwrites: finished with status 'done'
#7 28.36   DEPRECATION: python-olm is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
#7 28.36   Running setup.py install for python-olm: started
#7 28.70   Running setup.py install for python-olm: finished with status 'error'
#7 28.70   error: subprocess-exited-with-error
#7 28.70   
#7 28.70   × Running setup.py install for python-olm did not run successfully.
#7 28.70   │ exit code: 1
#7 28.70   ╰─> [31 lines of output]
#7 28.70       make: *** No rule to make target '../include/olm/olm.h', needed by 'include/olm/olm.h'.  Stop.
#7 28.70       running install
#7 28.70       /opt/venv/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
#7 28.70         warnings.warn(
#7 28.70       running build
#7 28.70       running build_py
#7 28.70       creating build
#7 28.70       creating build/lib.linux-x86_64-cpython-311
#7 28.70       creating build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/group_session.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/_compat.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/__version__.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/sas.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/account.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/__init__.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/utility.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/pk.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/session.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       copying olm/_finalize.py -> build/lib.linux-x86_64-cpython-311/olm
#7 28.70       running build_ext
#7 28.70       generating cffi module 'build/temp.linux-x86_64-cpython-311/_libolm.c'
#7 28.70       creating build/temp.linux-x86_64-cpython-311
#7 28.70       building '_libolm' extension
#7 28.70       creating build/temp.linux-x86_64-cpython-311/build
#7 28.70       creating build/temp.linux-x86_64-cpython-311/build/temp.linux-x86_64-cpython-311
#7 28.70       gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/opt/venv/include -I/usr/local/include/python3.11 -c build/temp.linux-x86_64-cpython-311/_libolm.c -o build/temp.linux-x86_64-cpython-311/build/temp.linux-x86_64-cpython-311/_libolm.o -I../include
#7 28.70       build/temp.linux-x86_64-cpython-311/_libolm.c:570:18: fatal error: olm/olm.h: No such file or directory
#7 28.70         570 |         #include <olm/olm.h>
#7 28.70             |                  ^~~~~~~~~~~
#7 28.70       compilation terminated.
#7 28.70       error: command '/usr/bin/gcc' failed with exit code 1
#7 28.70       [end of output]
#7 28.70   
#7 28.70   note: This error originates from a subprocess, and is likely not a problem with pip.
#7 28.71 error: legacy-install-failure
#7 28.71 
#7 28.71 × Encountered error while trying to install package.
#7 28.71 ╰─> python-olm
#7 28.71 
#7 28.71 note: This is an issue with the package mentioned above, not pip.
#7 28.71 hint: See above for output from the failure.
#7 28.78 
#7 28.78 [notice] A new release of pip available: 22.3 -> 22.3.1
#7 28.78 [notice] To update, run: python -m pip install --upgrade pip
------
executor failed running [/bin/sh -c /opt/venv/bin/pip install --no-cache-dir matrix-registration-bot==1.2.2]: exit code: 1

Respond only to mention

Some users would like the bot to only respond when mentioned. This should be configurable by the admin via the config file

Password login of bot is broken

When i try to start the docker container:

2022-10-25 22:58:06,523 DEBUG:No config file set via the environment variable
2022-10-25 22:58:06,524 DEBUG:No config file set via the --config option, defaulting to config.yml in working directory
2022-10-25 22:58:06,524 INFO:Tying to load bot configuration from config.yml
2022-10-25 22:58:06,524 ERROR:Cold not find bot configuration at config.yml
2022-10-25 22:58:06,524 DEBUG:BOT_SERVER set via environment
2022-10-25 22:58:06,524 DEBUG:BOT_USERNAME set via environment
2022-10-25 22:58:06,524 DEBUG:BOT_PASSWORD set via environment
2022-10-25 22:58:06,524 DEBUG:BOT_ACCESS_TOKEN not set in environment
2022-10-25 22:58:06,525 DEBUG:API_BASE_URL set via environment
2022-10-25 22:58:06,525 DEBUG:API_TOKEN set via environment
2022-10-25 22:58:06,525 DEBUG:LOGGING_LEVEL set via environment
2022-10-25 22:58:06,525 INFO:Using password based authentication for the bot
2022-10-25 22:58:06,561 INFO:Loaded the simple-matrix-bot config file config.toml
2022-10-25 22:58:06,562 DEBUG:Using selector: EpollSelector
Traceback (most recent call last):
  File "/opt/venv/bin/matrix-registration-bot", line 8, in <module>
    sys.exit(run_bot())
  File "/opt/venv/lib/python3.10/site-packages/matrix_registration_bot/bot.py", line 201, in run_bot
    bot.run()
  File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/bot.py", line 88, in run
    asyncio.run(self.main())
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/bot.py", line 50, in main
    await self.api.login()
  File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/api.py", line 151, in login
    self.async_client.load_store()
  File "/opt/venv/lib/python3.10/site-packages/nio/client/base_client.py", line 356, in load_store
    raise LocalProtocolError("User id is not set")
nio.exceptions.LocalProtocolError: User id is not set

400 Bad Request error with forced SSO

image

Hi - I'm getting the above errors when trying to use the bot. I suspect it is something to do with my forcing all logins through SSO with a separate LDAP server. No logins from synapse database.

Bot user is created / registered in synapse and in LDAP - I can log in via single sign on as the bot. I do have 2FA configured on SSO. I believe bot was working prior to requiring login via SSO (i.e. was logging in based on LDAP.

Everything has been installed using the Ansible deployment here.

SSO provider is Authelia / LDAP provider is LLDAP.

Please let me know if I can give you any further info - probably something I have misconfigured as am learning SSO / LDAP.

Fetch API token with user/password

As the bot now supports password-based login we could also move away from using access tokens at all. This would mean that the bot must be an admin user (security relevant) but also make it easier to deploy (see spantaleev/matrix-docker-ansible-deploy#2723).

the bot could then use either the access token it uses for messaging or an access token obtained for this purpose to interact with the admin API

Matrix Support room is down ?

#matrix-registration-bot:hyteck.de is not accessible at this time.
Try again later, or ask a room or space admin to check if you have access.

Bot cannot be started

Hi,

this is my first contact with Matrix, please bear with me.
I am probably doing something fundamentally wrong.

I have installed the registration bot and configured it so far.
Now when I want to start it, I get the following error:

(env) root@vmd76330:~/synapse# python -m matrix_registration_bot.bot
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/root/synapse/env/lib/python3.7/site-packages/matrix_registration_bot/bot.py", line 18, in <module>
    access_token=bot_access_token)
TypeError: __init__() got an unexpected keyword argument 'access_token'
(env) root@vmd76330:~/synapse#

I'm honestly not quite sure where to put the config file.
To be on the safe side I have it here:
/root/synapse/env/lib/python3.7/site-packages/matrix_registration_bot/
and once here:
/root/synapse/

My Config.yml looks like this:
bot:
  server: "https://matrix.mydomain.de"
  username: "registration-bot"
  access_token: "syt_c_______________________________________________gw"
api:
  # API endpoint of the registration tokens
  base_url: 'https://matrix.mydomain.de'
  endpoint: '/_synapse/admin/v1/registration_tokens'
  # Access token of an administrator on the server
  token: "syt_Y_______________________________________eC"

I've already searched the whole internet and tried to solve it myself, but I just don't know where the problem is.

Can you maybe help me?

Make bot prefix configurable

Some users want the bot to use a prefix which can help in a room with multiple bots. This should be configurable by the administrator of the server (via the config file).

Internally the bot prefix can be set when creating match.

match = botlib.MessageMatch(room, message, bot, PREFIX)

Profile picture

The matrix-bot should automatically set a profile picture to make itself recognizable

Bot dies

Version: docker
Compose:

version: "3.8"
services:
  regbot:
    image: moanos/matrix-registration-bot:latest
    environment:
      LOGGING_LEVEL: DEBUG
      BOT_SERVER: "https://matrix.gofferje.net"
      BOT_USERNAME: "botname"
      BOT_PASSWORD: "<removed>"
      API_BASE_URL: 'https://matrix.gofferje.net'
      API_TOKEN: "<removed>"

networks:
  default:
    external:
      name: web_services
 

Log:

2023-07-08 09:34:29,317 DEBUG:('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 ?', ['@botname:gofferje.net', '<removed>', 1, 0])

Traceback (most recent call last):

  File "/opt/venv/bin/matrix-registration-bot", line 8, in <module>

    sys.exit(run_bot())

Connected to https://matrix.gofferje.net as @botname:gofferje.net (<removed>)

This bot's public fingerprint ("Session key") for one-sided verification is: 5M37 ptwg QhYk IDAc Pigu kybM LWDO i723 DHtQ skXT 5cM

             ^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/matrix_registration_bot/bot.py", line 201, in run_bot

    bot.run()

  File "/opt/venv/lib/python3.11/site-packages/simplematrixbotlib/bot.py", line 88, in run

    asyncio.run(self.main())

  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run

    return runner.run(main)

           ^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run

    return self._loop.run_until_complete(task)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete

    return future.result()

           ^^^^^^^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/simplematrixbotlib/bot.py", line 81, in main

    await self.async_client.sync_forever(timeout=3000, full_state=True)

  File "/opt/venv/lib/python3.11/site-packages/nio/client/base_client.py", line 111, in wrapper

    return await func(self, *args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/nio/client/async_client.py", line 1232, in sync_forever

    await self.run_response_callbacks([await response])

                                       ^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 605, in _wait_for_one

    return f.result()  # May raise f.exception().

           ^^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/nio/client/base_client.py", line 111, in wrapper

    return await func(self, *args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/nio/client/async_client.py", line 1074, in sync

    response = await self._send(

               ^^^^^^^^^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/nio/client/async_client.py", line 778, in _send

    transport_resp = await self.send(

                     ^^^^^^^^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/nio/client/async_client.py", line 303, in wrapper

    return await func(self, *args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/nio/client/async_client.py", line 850, in send

    return await self.client_session.request(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/aiohttp/client.py", line 560, in _request

    await resp.start(conn)

  File "/opt/venv/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 894, in start

    with self._timer:

  File "/opt/venv/lib/python3.11/site-packages/aiohttp/helpers.py", line 721, in __exit__

    raise asyncio.TimeoutError from None

Traceback: ValueError: Invalid Homeserver

-- Journal begins at Mon 2022-08-01 19:39:35 CEST, ends at Wed 2022-08-03 14:41:19 CEST. --
Aug 03 13:56:05 "redacted" systemd[1]: Stopping Matrix registration bot...
Aug 03 13:56:06 "redacted" matrix-bot-matrix-registration-bot[2694077]: matrix-bot-matrix-registration-bot
Aug 03 13:56:06 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Main process exited, code=exited, status=137/n/a
Aug 03 13:56:06 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Failed with result 'exit-code'.
Aug 03 13:56:06 "redacted" systemd[1]: Stopped Matrix registration bot.
Aug 03 13:56:06 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Consumed 10.113s CPU time.
Aug 03 13:56:06 "redacted" systemd[1]: Starting Matrix registration bot...
Aug 03 13:56:06 "redacted" systemd[1]: Started Matrix registration bot.
Aug 03 13:56:11 "redacted" matrix-bot-matrix-registration-bot[2694139]: 2022-08-03 11:56:11,541 INFO:Tying to load bot configuration from /config/config.yml
Aug 03 13:56:11 "redacted" matrix-bot-matrix-registration-bot[2694139]: 2022-08-03 11:56:11,550 DEBUG:BOT_SERVER not set in environment
Aug 03 13:56:11 "redacted" matrix-bot-matrix-registration-bot[2694139]: 2022-08-03 11:56:11,550 DEBUG:BOT_USERNAME not set in environment
Aug 03 13:56:11 "redacted" matrix-bot-matrix-registration-bot[2694139]: 2022-08-03 11:56:11,551 DEBUG:BOT_PASSWORD not set in environment
Aug 03 13:56:11 "redacted" matrix-bot-matrix-registration-bot[2694139]: 2022-08-03 11:56:11,551 DEBUG:BOT_ACCESS_TOKEN not set in environment
Aug 03 13:56:11 "redacted" matrix-bot-matrix-registration-bot[2694139]: 2022-08-03 11:56:11,553 DEBUG:API_BASE_URL not set in environment
Aug 03 13:56:11 "redacted" matrix-bot-matrix-registration-bot[2694139]: 2022-08-03 11:56:11,553 DEBUG:API_TOKEN not set in environment
Aug 03 13:56:11 "redacted" matrix-bot-matrix-registration-bot[2694139]: 2022-08-03 11:56:11,554 DEBUG:LOGGING_LEVEL not set in environment
Aug 03 13:56:11 "redacted" matrix-bot-matrix-registration-bot[2694139]: 2022-08-03 11:56:11,813 INFO:Loaded the simple-matrix-bot config file config.toml
Aug 03 14:04:17 "redacted" systemd[1]: Stopping Matrix registration bot...
Aug 03 14:04:18 "redacted" matrix-bot-matrix-registration-bot[2700551]: matrix-bot-matrix-registration-bot
Aug 03 14:04:19 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Main process exited, code=exited, status=137/n/a
Aug 03 14:04:19 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Failed with result 'exit-code'.
Aug 03 14:04:19 "redacted" systemd[1]: Stopped Matrix registration bot.
Aug 03 14:04:56 "redacted" systemd[1]: Starting Matrix registration bot...
Aug 03 14:04:57 "redacted" systemd[1]: Started Matrix registration bot.
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: 2022-08-03 12:05:19,221 INFO:Tying to load bot configuration from /config/config.yml
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: 2022-08-03 12:05:19,241 DEBUG:BOT_SERVER not set in environment
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: 2022-08-03 12:05:19,243 DEBUG:BOT_USERNAME not set in environment
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: 2022-08-03 12:05:19,245 DEBUG:BOT_PASSWORD not set in environment
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: 2022-08-03 12:05:19,246 DEBUG:BOT_ACCESS_TOKEN not set in environment
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: 2022-08-03 12:05:19,247 DEBUG:API_BASE_URL not set in environment
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: 2022-08-03 12:05:19,250 DEBUG:API_TOKEN not set in environment
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: 2022-08-03 12:05:19,251 DEBUG:LOGGING_LEVEL not set in environment
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: 2022-08-03 12:05:19,795 INFO:Loaded the simple-matrix-bot config file config.toml
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]: Traceback (most recent call last):
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]:   File "/opt/venv/bin/matrix-registration-bot", line 8, in <module>
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]:     sys.exit(run_bot())
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]:   File "/opt/venv/lib/python3.10/site-packages/matrix_registration_bot/bot.py", line 195, in run_bot
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]:     bot.run()
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]:   File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/bot.py", line 84, in run
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]:     asyncio.run(self.main())
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]:   File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
Aug 03 14:05:19 "redacted" matrix-bot-matrix-registration-bot[2703366]:     return loop.run_until_complete(main)
Aug 03 14:05:20 "redacted" matrix-bot-matrix-registration-bot[2703366]:   File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
Aug 03 14:05:20 "redacted" matrix-bot-matrix-registration-bot[2703366]:     return future.result()
Aug 03 14:05:20 "redacted" matrix-bot-matrix-registration-bot[2703366]:   File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/bot.py", line 46, in main
Aug 03 14:05:20 "redacted" matrix-bot-matrix-registration-bot[2703366]:     raise ValueError("Invalid Homeserver")
Aug 03 14:05:20 "redacted" matrix-bot-matrix-registration-bot[2703366]: ValueError: Invalid Homeserver
Aug 03 14:05:21 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Main process exited, code=exited, status=1/FAILURE
Aug 03 14:05:21 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Failed with result 'exit-code'.
Aug 03 14:05:51 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Scheduled restart job, restart counter is at 1.
Aug 03 14:05:51 "redacted" systemd[1]: Stopped Matrix registration bot.
Aug 03 14:05:51 "redacted" systemd[1]: Starting Matrix registration bot...
Aug 03 14:05:51 "redacted" systemd[1]: Started Matrix registration bot.
Aug 03 14:05:55 "redacted" matrix-bot-matrix-registration-bot[2704822]: 2022-08-03 12:05:55,190 INFO:Tying to load bot configuration from /config/config.yml
Aug 03 14:05:55 "redacted" matrix-bot-matrix-registration-bot[2704822]: 2022-08-03 12:05:55,195 DEBUG:BOT_SERVER not set in environment
Aug 03 14:05:55 "redacted" matrix-bot-matrix-registration-bot[2704822]: 2022-08-03 12:05:55,196 DEBUG:BOT_USERNAME not set in environment
Aug 03 14:05:55 "redacted" matrix-bot-matrix-registration-bot[2704822]: 2022-08-03 12:05:55,197 DEBUG:BOT_PASSWORD not set in environment
Aug 03 14:05:55 "redacted" matrix-bot-matrix-registration-bot[2704822]: 2022-08-03 12:05:55,197 DEBUG:BOT_ACCESS_TOKEN not set in environment
Aug 03 14:05:55 "redacted" matrix-bot-matrix-registration-bot[2704822]: 2022-08-03 12:05:55,198 DEBUG:API_BASE_URL not set in environment
Aug 03 14:05:55 "redacted" matrix-bot-matrix-registration-bot[2704822]: 2022-08-03 12:05:55,199 DEBUG:API_TOKEN not set in environment
Aug 03 14:05:55 "redacted" matrix-bot-matrix-registration-bot[2704822]: 2022-08-03 12:05:55,199 DEBUG:LOGGING_LEVEL not set in environment
Aug 03 14:05:55 "redacted" matrix-bot-matrix-registration-bot[2704822]: 2022-08-03 12:05:55,357 INFO:Loaded the simple-matrix-bot config file config.toml
Aug 03 14:12:01 "redacted" systemd[1]: Stopping Matrix registration bot...
Aug 03 14:12:03 "redacted" matrix-bot-matrix-registration-bot[2709254]: matrix-bot-matrix-registration-bot
Aug 03 14:12:03 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Main process exited, code=exited, status=137/n/a
Aug 03 14:12:03 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Failed with result 'exit-code'.
Aug 03 14:12:03 "redacted" systemd[1]: Stopped Matrix registration bot.
Aug 03 14:13:11 "redacted" systemd[1]: Starting Matrix registration bot...
Aug 03 14:13:12 "redacted" systemd[1]: Started Matrix registration bot.
Aug 03 14:13:36 "redacted" matrix-bot-matrix-registration-bot[2712691]: 2022-08-03 12:13:36,778 INFO:Tying to load bot configuration from /config/config.yml
Aug 03 14:13:36 "redacted" matrix-bot-matrix-registration-bot[2712691]: 2022-08-03 12:13:36,791 DEBUG:BOT_SERVER not set in environment
Aug 03 14:13:36 "redacted" matrix-bot-matrix-registration-bot[2712691]: 2022-08-03 12:13:36,794 DEBUG:BOT_USERNAME not set in environment
Aug 03 14:13:36 "redacted" matrix-bot-matrix-registration-bot[2712691]: 2022-08-03 12:13:36,795 DEBUG:BOT_PASSWORD not set in environment
Aug 03 14:13:36 "redacted" matrix-bot-matrix-registration-bot[2712691]: 2022-08-03 12:13:36,797 DEBUG:BOT_ACCESS_TOKEN not set in environment
Aug 03 14:13:36 "redacted" matrix-bot-matrix-registration-bot[2712691]: 2022-08-03 12:13:36,798 DEBUG:API_BASE_URL not set in environment
Aug 03 14:13:36 "redacted" matrix-bot-matrix-registration-bot[2712691]: 2022-08-03 12:13:36,800 DEBUG:API_TOKEN not set in environment
Aug 03 14:13:36 "redacted" matrix-bot-matrix-registration-bot[2712691]: 2022-08-03 12:13:36,800 DEBUG:LOGGING_LEVEL not set in environment
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]: 2022-08-03 12:13:37,306 INFO:Loaded the simple-matrix-bot config file config.toml
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]: Traceback (most recent call last):
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:   File "/opt/venv/bin/matrix-registration-bot", line 8, in <module>
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:     sys.exit(run_bot())
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:   File "/opt/venv/lib/python3.10/site-packages/matrix_registration_bot/bot.py", line 195, in run_bot
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:     bot.run()
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:   File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/bot.py", line 84, in run
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:     asyncio.run(self.main())
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:   File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:     return loop.run_until_complete(main)
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:   File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:     return future.result()
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:   File "/opt/venv/lib/python3.10/site-packages/simplematrixbotlib/bot.py", line 46, in main
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]:     raise ValueError("Invalid Homeserver")
Aug 03 14:13:37 "redacted" matrix-bot-matrix-registration-bot[2712691]: ValueError: Invalid Homeserver
Aug 03 14:13:38 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Main process exited, code=exited, status=1/FAILURE
Aug 03 14:13:38 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Failed with result 'exit-code'.
Aug 03 14:14:08 "redacted" systemd[1]: matrix-bot-matrix-registration-bot.service: Scheduled restart job, restart counter is at 1.
Aug 03 14:14:08 "redacted" systemd[1]: Stopped Matrix registration bot.
Aug 03 14:14:08 "redacted" systemd[1]: Starting Matrix registration bot...
Aug 03 14:14:08 "redacted" systemd[1]: Started Matrix registration bot.
Aug 03 14:14:12 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:14:12,349 INFO:Tying to load bot configuration from /config/config.yml
Aug 03 14:14:12 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:14:12,354 DEBUG:BOT_SERVER not set in environment
Aug 03 14:14:12 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:14:12,355 DEBUG:BOT_USERNAME not set in environment
Aug 03 14:14:12 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:14:12,356 DEBUG:BOT_PASSWORD not set in environment
Aug 03 14:14:12 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:14:12,357 DEBUG:BOT_ACCESS_TOKEN not set in environment
Aug 03 14:14:12 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:14:12,357 DEBUG:API_BASE_URL not set in environment
Aug 03 14:14:12 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:14:12,358 DEBUG:API_TOKEN not set in environment
Aug 03 14:14:12 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:14:12,358 DEBUG:LOGGING_LEVEL not set in environment
Aug 03 14:14:12 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:14:12,501 INFO:Loaded the simple-matrix-bot config file config.toml
Aug 03 14:39:05 "redacted" matrix-bot-matrix-registration-bot[2714121]: 2022-08-03 12:39:05,105 INFO:@roughnecks:"redacted" listed all tokens

It works after the error, so this is happening only when restarting the Ansible playbook.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.