mirror of
https://github.com/solero/houdini.git
synced 2025-01-10 22:57:01 +00:00
Change handler allow_once syntax to work without parentheses
This commit is contained in:
parent
8b0ff4e944
commit
67476e7c10
@ -200,12 +200,12 @@ def check(predicate):
|
|||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def allow_once():
|
def check_for_packet(listener, p):
|
||||||
def check_for_packet(listener, p):
|
return listener.packet not in p.received_packets
|
||||||
return listener.packet not in p.received_packets
|
|
||||||
return check(check_for_packet)
|
|
||||||
|
|
||||||
|
|
||||||
|
allow_once = check(check_for_packet)
|
||||||
|
|
||||||
def player_attribute(**attrs):
|
def player_attribute(**attrs):
|
||||||
def check_for_attributes(_, p):
|
def check_for_attributes(_, p):
|
||||||
for attr, value in attrs.items():
|
for attr, value in attrs.items():
|
||||||
|
@ -4,7 +4,7 @@ from houdini.converters import VersionChkConverter
|
|||||||
|
|
||||||
|
|
||||||
@handlers.handler(XMLPacket('verChk'))
|
@handlers.handler(XMLPacket('verChk'))
|
||||||
@handlers.allow_once()
|
@handlers.allow_once
|
||||||
async def handle_version_check(p, version: VersionChkConverter):
|
async def handle_version_check(p, version: VersionChkConverter):
|
||||||
if not version == 153:
|
if not version == 153:
|
||||||
await p.send_xml({'body': {'action': 'apiKO', 'r': '0'}})
|
await p.send_xml({'body': {'action': 'apiKO', 'r': '0'}})
|
||||||
@ -14,6 +14,6 @@ async def handle_version_check(p, version: VersionChkConverter):
|
|||||||
|
|
||||||
|
|
||||||
@handlers.handler(XMLPacket('rndK'))
|
@handlers.handler(XMLPacket('rndK'))
|
||||||
@handlers.allow_once()
|
@handlers.allow_once
|
||||||
async def handle_random_key(p, data):
|
async def handle_random_key(p, data):
|
||||||
await p.send_xml({'body': {'action': 'rndK', 'r': '-1'}, 'k': 'houdini'})
|
await p.send_xml({'body': {'action': 'rndK', 'r': '-1'}, 'k': 'houdini'})
|
||||||
|
@ -16,7 +16,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
|
|
||||||
@handlers.handler(XMLPacket('login'))
|
@handlers.handler(XMLPacket('login'))
|
||||||
@handlers.allow_once()
|
@handlers.allow_once
|
||||||
async def handle_login(p, credentials: Credentials):
|
async def handle_login(p, credentials: Credentials):
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ handle_random_key = login.handle_random_key
|
|||||||
|
|
||||||
|
|
||||||
@handlers.handler(XMLPacket('login'))
|
@handlers.handler(XMLPacket('login'))
|
||||||
@handlers.allow_once()
|
@handlers.allow_once
|
||||||
async def handle_login(p, credentials: WorldCredentials):
|
async def handle_login(p, credentials: WorldCredentials):
|
||||||
tr = p.server.redis.multi_exec()
|
tr = p.server.redis.multi_exec()
|
||||||
tr.get('{}.lkey'.format(credentials.id))
|
tr.get('{}.lkey'.format(credentials.id))
|
||||||
|
@ -3,6 +3,6 @@ from houdini.handlers import XTPacket
|
|||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('i', 'gi'))
|
@handlers.handler(XTPacket('i', 'gi'))
|
||||||
@handlers.allow_once()
|
@handlers.allow_once
|
||||||
async def handle_get_inventory(p):
|
async def handle_get_inventory(p):
|
||||||
await p.send_xt('gi', *p.data.inventory.keys())
|
await p.send_xt('gi', *p.data.inventory.keys())
|
||||||
|
@ -8,7 +8,7 @@ import ujson
|
|||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('j', 'js'), pre_login=True)
|
@handlers.handler(XTPacket('j', 'js'), pre_login=True)
|
||||||
@handlers.allow_once()
|
@handlers.allow_once
|
||||||
async def handle_join_server(p, penguin_id: int, login_key: str, lang: str):
|
async def handle_join_server(p, penguin_id: int, login_key: str, lang: str):
|
||||||
if penguin_id != p.data.id:
|
if penguin_id != p.data.id:
|
||||||
return await p.close()
|
return await p.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user