ConnectedPenguinConverter now accepts usernames

This commit is contained in:
Ben 2020-05-17 03:27:01 +01:00
parent 9c9ab2dd7d
commit 69fde9b21a

View File

@ -10,6 +10,7 @@ from houdini.data.item import Item
from houdini.data.pet import PenguinPuffle, Puffle
from houdini.data.room import Room
from houdini.data.stamp import Stamp
from houdini.data.permission import Permission
class ChecklistError(Exception):
@ -229,10 +230,13 @@ class ConnectedPenguinConverter(IConverter):
or none if the player is offline"""
async def convert(self, ctx):
penguin_id = int(ctx.argument)
if penguin_id in ctx.p.server.penguins_by_id:
return ctx.p.server.penguins_by_id[penguin_id]
return None
try:
try:
return ctx.p.server.penguins_by_id[int(ctx.argument)]
except ValueError:
return ctx.p.server.penguins_by_username[ctx.argument.lower()]
except KeyError:
return None
class ConnectedIglooConverter(IConverter):