Update urls and asyncio calls

This commit is contained in:
Tulir Asokan 2025-03-25 20:06:19 +02:00
parent a8effa2efa
commit 3ce380645d
3 changed files with 4 additions and 4 deletions

View File

@ -59,7 +59,7 @@ async def load_config(path: str) -> None:
print("Matrix config file not found. Please enter your homeserver and access token.") print("Matrix config file not found. Please enter your homeserver and access token.")
homeserver_url = input("Homeserver URL: ") homeserver_url = input("Homeserver URL: ")
access_token = input("Access token: ") access_token = input("Access token: ")
whoami_url = URL(homeserver_url) / "_matrix" / "client" / "r0" / "account" / "whoami" whoami_url = URL(homeserver_url) / "_matrix" / "client" / "v3" / "account" / "whoami"
if whoami_url.scheme not in ("https", "http"): if whoami_url.scheme not in ("https", "http"):
whoami_url = whoami_url.with_scheme("https") whoami_url = whoami_url.with_scheme("https")
user_id = await whoami(whoami_url, access_token) user_id = await whoami(whoami_url, access_token)
@ -71,7 +71,7 @@ async def load_config(path: str) -> None:
}, config_file) }, config_file)
print(f"Wrote config to {path}") print(f"Wrote config to {path}")
upload_url = URL(homeserver_url) / "_matrix" / "media" / "r0" / "upload" upload_url = URL(homeserver_url) / "_matrix" / "media" / "v3" / "upload"
async def whoami(url: URL, access_token: str) -> str: async def whoami(url: URL, access_token: str) -> str:

View File

@ -143,7 +143,7 @@ parser.add_argument("path", help="Path to the sticker pack directory", type=str)
def cmd(): def cmd():
asyncio.get_event_loop().run_until_complete(main(parser.parse_args())) asyncio.run(main(parser.parse_args()))
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -161,7 +161,7 @@ async def main(args: argparse.Namespace) -> None:
def cmd() -> None: def cmd() -> None:
asyncio.get_event_loop().run_until_complete(main(parser.parse_args())) asyncio.run(main(parser.parse_args()))
if __name__ == "__main__": if __name__ == "__main__":