Get player username by swid handler

This commit is contained in:
Ben 2019-12-02 23:26:03 +00:00
parent ad8119a4d5
commit 2fd0a68aef

View File

@ -1,4 +1,5 @@
from houdini import handlers from houdini import handlers
from houdini.converters import SeparatorConverter
from houdini.handlers import XTPacket from houdini.handlers import XTPacket
from houdini.data.penguin import Penguin from houdini.data.penguin import Penguin
from houdini.constants import ClientType from houdini.constants import ClientType
@ -111,6 +112,31 @@ async def handle_get_player_by_swid(p, penguin_id: int):
await p.send_xt('pbs', penguin_id, penguin_id, nickname) await p.send_xt('pbs', penguin_id, penguin_id, nickname)
_id_converter = SeparatorConverter(separator=',', mapper=int)
@handlers.handler(XTPacket('u', 'pbsu'), client=ClientType.Vanilla)
@handlers.cooldown(1)
async def handle_get_player_username_by_swid(p, ids: _id_converter):
ids = list(ids)
query = Penguin.select('id', 'nickname').where(Penguin.id.in_(ids))
async with p.server.db.transaction():
nicknames = {
pid: nickname async for pid, nickname in query.gino.iterate()}
await p.send_xt('pbsu', ','.join(nicknames[pid] for pid in ids))
@handlers.handler(XTPacket('u', 'gabcms'))
async def handle_get_ab_test_data(p):
pass
@handlers.handler(XTPacket('u', 'rpfi'))
async def handle_send_refresh_player_friend_info(p):
pass
@handlers.handler(XTPacket('u', 'pbn'), client=ClientType.Vanilla) @handlers.handler(XTPacket('u', 'pbn'), client=ClientType.Vanilla)
@handlers.cooldown(1) @handlers.cooldown(1)
async def handle_get_player_by_name(p, player_name: str): async def handle_get_player_by_name(p, player_name: str):