Fix mbc upload printing error on the first upload

This commit is contained in:
Tulir Asokan 2021-11-28 18:29:45 +02:00
parent 66d227ecdb
commit 4fafdee3a8

View File

@ -41,7 +41,7 @@ async def upload_file(sess: aiohttp.ClientSession, file: IO, server: str) -> Non
url = (URL(server) / "_matrix/maubot/v1/plugins/upload").with_query({"allow_override": "true"}) url = (URL(server) / "_matrix/maubot/v1/plugins/upload").with_query({"allow_override": "true"})
headers = {"Content-Type": "application/zip"} headers = {"Content-Type": "application/zip"}
async with sess.post(url, data=file, headers=headers) as resp: async with sess.post(url, data=file, headers=headers) as resp:
if resp.status == 200: if resp.status in (200, 201):
data = await resp.json() data = await resp.json()
print(f"{Fore.GREEN}Plugin {Fore.CYAN}{data['id']} v{data['version']}{Fore.GREEN} " print(f"{Fore.GREEN}Plugin {Fore.CYAN}{data['id']} v{data['version']}{Fore.GREEN} "
f"uploaded to {Fore.CYAN}{server}{Fore.GREEN} successfully.{Fore.RESET}") f"uploaded to {Fore.CYAN}{server}{Fore.GREEN} successfully.{Fore.RESET}")