mirror of
https://github.com/solero/houdini.git
synced 2024-11-08 20:28:20 +00:00
Handler engine now has support for missing argument defaults
This commit is contained in:
parent
91a4d8acd5
commit
db3825ccca
@ -88,13 +88,20 @@ class _ArgumentDeserializer:
|
||||
if ctx.component.annotation is ctx.component.empty and ctx.component.default is not ctx.component.empty:
|
||||
handler_call_arguments.append(ctx.component.default)
|
||||
elif ctx.component.kind == ctx.component.POSITIONAL_OR_KEYWORD:
|
||||
ctx.argument = next(ctx.arguments)
|
||||
converter = get_converter(ctx.component)
|
||||
ctx.argument = next(ctx.arguments, None)
|
||||
|
||||
if converter == str:
|
||||
self._consume_separated_string(ctx)
|
||||
if ctx.argument is None:
|
||||
if ctx.component.default is not ctx.component.empty:
|
||||
handler_call_arguments.append(ctx.component.default)
|
||||
else:
|
||||
raise StopIteration
|
||||
else:
|
||||
converter = get_converter(ctx.component)
|
||||
|
||||
handler_call_arguments.append(await do_conversion(converter, ctx))
|
||||
if converter == str:
|
||||
self._consume_separated_string(ctx)
|
||||
|
||||
handler_call_arguments.append(await do_conversion(converter, ctx))
|
||||
elif ctx.component.kind == ctx.component.VAR_POSITIONAL:
|
||||
for argument in ctx.arguments:
|
||||
ctx.argument = argument
|
||||
|
@ -58,12 +58,10 @@ async def handle_moderator_ban(p, penguin_id: int, ban_type: int, reason: int, d
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('m', 'r'))
|
||||
async def handle_report(p, penguin_id: int, *reason):
|
||||
reason = int(reason[0]) if reason else 0
|
||||
async def handle_report(p, penguin_id: int, reason: int = 0):
|
||||
date_now = datetime.datetime.now()
|
||||
server_id = p.server.server_config['Id']
|
||||
await Report.create(penguin_id=penguin_id, reporter_id=p.data.id, report_type=reason,
|
||||
date=date_now, server_id=server_id, room_id=p.room.id)
|
||||
await Report.create(penguin_id=penguin_id, reporter_id=p.id, report_type=reason,
|
||||
date=date_now, server_id=p.server.config.id, room_id=p.room.id)
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('o', 'moderatormessage'))
|
||||
|
Loading…
Reference in New Issue
Block a user