matrix-nio
matrix-nio copied to clipboard
AsyncClient.download() always M_NOT_FOUND?
Hello!
I think this is probably a brainfart, but I just can't figure out where I'm going wrong.
I took one of the examples and tried making it download all RoomMessageFile that cross its path
async with aiofiles.open(CONFIG_FILE) as f:
contents = await f.read()
config = json.loads(contents)
client = AsyncClient(config["homeserver"])
client.access_token = config["access_token"]
client.user_id = config["user_id"]
client.device_id = config["device_id"]
async def message_callback(room: MatrixRoom, event: RoomMessageFile) -> None:
try:
print(room.name, event.source['content']['body'], event.url)
except:
pass
try:
dl = await client.download(mxc=event.url, save_to=event.source['content']['body'], allow_remote=True)
if isinstance(dl, DownloadError):
print(dl)
except Exception as e:
print(e)
client.add_event_callback(message_callback, RoomMessageFile)
await client.sync_forever(timeout=30000) # milliseconds
...but I always get M_NOT_FOUND. Element and other clients can download the same files, using the same mxc:// address just fine.
Any ideas?