Give room objects penguins_by_id and penguins_by_username attributes

This commit is contained in:
Ben
2019-09-09 22:07:51 +01:00
parent 4495779bf1
commit 8018a7c21e
3 changed files with 22 additions and 13 deletions

View File

@@ -10,9 +10,9 @@ async def handle_send_message(p, penguin_id: int, message: str):
return await p.close()
if p.muted:
for room_player in p.room.penguins:
if room_player.data.moderator:
await room_player.sendXt("mm", message, penguin_id)
for penguin in p.room.penguins_by_id.values():
if penguin.data.moderator:
await penguin.send_xt("mm", message, penguin_id)
return
if has_command_prefix(message):

View File

@@ -17,7 +17,7 @@ async def handle_close_book(p):
@handlers.handler(XTPacket('j', 'jr'), client=ClientType.Legacy)
async def handle_join_room_toy(p):
for penguin in p.room.penguins:
for penguin in p.room.penguins_by_id.values():
if penguin.toy is not None:
await p.send_xt('at', penguin.data.id, penguin.toy)
@@ -25,6 +25,6 @@ async def handle_join_room_toy(p):
@handlers.handler(XTPacket('j', 'crl'), client=ClientType.Vanilla)
@handlers.depends_on_packet(XTPacket('j', 'jr'))
async def handle_client_room_loaded_toy(p):
for penguin in p.room.penguins:
for penguin in p.room.penguins_by_id.values():
if penguin.toy is not None:
await p.send_xt('at', penguin.data.id, penguin.toy)