logging and more info and service

This commit is contained in:
Cyberes 2024-04-03 23:07:42 -06:00
parent dcdcc15b53
commit 20685fe15c
3 changed files with 23 additions and 5 deletions

View File

@ -2,8 +2,8 @@
_Export a Matrix a room._
This is a simple bot that can export a Matrix room and upload the compressed archive to a Cloudflare R2 bucket for the
room to download.
A quick-n-dirty bot that exports a Matrix room and uploads the archive to a Cloudflare R2 bucket for the room to
download.
### Install
@ -24,4 +24,7 @@ room to download.
1. Invite the new bot to the room you want to export.
2. Send the message `!export` to start the export process.
The bot will upload the exported room to your R2 bucket and share the link with the room.
The bot will upload the exported room to your R2 bucket and share the link with the room.
Remember, if your room is encrypted and new members can't see old history prior to their joining then the bot won't be
able to export anything earlier than when it joined.

View File

@ -27,7 +27,8 @@ async def main(args):
config = DEFAULT_CONFIG | yaml_config
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.DEBUG if args.debug else logging.INFO)
logger.debug('Debug logging enabled!')
matrix_helper = MatrixClientHelper(
user_id=config['auth']['username'],
@ -39,7 +40,7 @@ async def main(args):
login_success, login_response = await matrix_helper.login()
if not login_success:
print(login_response)
logger.critical(f'Failed to login: {login_response}')
quit(1)
logger.info(f'Logged in as {client.user_id}')
@ -54,5 +55,6 @@ async def main(args):
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Export a Matrix room.')
parser.add_argument('--config', default=Path(SCRIPT_PATH) / 'config.yml')
parser.add_argument('--debug', '-d', action='store_true', help='Enable debug logging.')
args = parser.parse_args()
asyncio.run(main(args))

View File

@ -0,0 +1,13 @@
[Unit]
Description=Matrix Room Exporter Bot
After=network.target
[Service]
Type=simple
User=matrix-bots
ExecStart=/srv/matrix-room-exporter/venv/bin/python /srv/matrix-room-exporter/main.py
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target