refactor: call get_local_users before session deletion
Moved the call to get_local_users before the asynchronous HTTP session deletion to ensure user data is fetched prior to initiating the room shutdown process. This change improves the structure of the asynchronous operations and ensures local users information is available for logging and messaging promptly.
This commit is contained in:
parent
4e0bc7a84b
commit
cfd985a746
1 changed files with 2 additions and 1 deletions
3
bot.py
3
bot.py
|
@ -184,6 +184,8 @@ class RoombaBot:
|
||||||
"purge": purge,
|
"purge": purge,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local_users = await self.get_local_users(room_id)
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.delete(url, headers=headers, json=body) as resp:
|
async with session.delete(url, headers=headers, json=body) as resp:
|
||||||
if resp.status == 200:
|
if resp.status == 200:
|
||||||
|
@ -192,7 +194,6 @@ class RoombaBot:
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
f"Room {room_id} shutdown initiated successfully: delete_id={delete_id}"
|
f"Room {room_id} shutdown initiated successfully: delete_id={delete_id}"
|
||||||
)
|
)
|
||||||
local_users = await self.get_local_users(room_id)
|
|
||||||
await self.send_message(
|
await self.send_message(
|
||||||
self.moderation_room_id,
|
self.moderation_room_id,
|
||||||
f"Room {room_id} shutdown initiated successfully. Delete ID: {delete_id}. Local users: {', '.join(local_users)}",
|
f"Room {room_id} shutdown initiated successfully. Delete ID: {delete_id}. Local users: {', '.join(local_users)}",
|
||||||
|
|
Loading…
Reference in a new issue