Change handler allow_once syntax to work without parentheses

This commit is contained in:
Ben 2019-06-21 01:39:25 +01:00
parent 8b0ff4e944
commit 67476e7c10
6 changed files with 10 additions and 10 deletions

View File

@ -200,12 +200,12 @@ def check(predicate):
return decorator
def allow_once():
def check_for_packet(listener, p):
return listener.packet not in p.received_packets
return check(check_for_packet)
def check_for_packet(listener, p):
return listener.packet not in p.received_packets
allow_once = check(check_for_packet)
def player_attribute(**attrs):
def check_for_attributes(_, p):
for attr, value in attrs.items():

View File

@ -4,7 +4,7 @@ from houdini.converters import VersionChkConverter
@handlers.handler(XMLPacket('verChk'))
@handlers.allow_once()
@handlers.allow_once
async def handle_version_check(p, version: VersionChkConverter):
if not version == 153:
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.allow_once()
@handlers.allow_once
async def handle_random_key(p, data):
await p.send_xml({'body': {'action': 'rndK', 'r': '-1'}, 'k': 'houdini'})

View File

@ -16,7 +16,7 @@ from datetime import datetime
@handlers.handler(XMLPacket('login'))
@handlers.allow_once()
@handlers.allow_once
async def handle_login(p, credentials: Credentials):
loop = asyncio.get_event_loop()

View File

@ -11,7 +11,7 @@ handle_random_key = login.handle_random_key
@handlers.handler(XMLPacket('login'))
@handlers.allow_once()
@handlers.allow_once
async def handle_login(p, credentials: WorldCredentials):
tr = p.server.redis.multi_exec()
tr.get('{}.lkey'.format(credentials.id))

View File

@ -3,6 +3,6 @@ from houdini.handlers import XTPacket
@handlers.handler(XTPacket('i', 'gi'))
@handlers.allow_once()
@handlers.allow_once
async def handle_get_inventory(p):
await p.send_xt('gi', *p.data.inventory.keys())

View File

@ -8,7 +8,7 @@ import ujson
@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):
if penguin_id != p.data.id:
return await p.close()