mirror of
https://github.com/solero/houdini.git
synced 2024-11-25 06:57:24 +00:00
Handler engine now has support for missing argument defaults
This commit is contained in:
parent
91a4d8acd5
commit
db3825ccca
@ -88,7 +88,14 @@ 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)
|
||||
ctx.argument = next(ctx.arguments, None)
|
||||
|
||||
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)
|
||||
|
||||
if converter == str:
|
||||
|
@ -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