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.pet import PenguinPuffle, Puffle
from houdini.data.room import Room from houdini.data.room import Room
from houdini.data.stamp import Stamp from houdini.data.stamp import Stamp
from houdini.data.permission import Permission
class ChecklistError(Exception): class ChecklistError(Exception):
@ -229,9 +230,12 @@ class ConnectedPenguinConverter(IConverter):
or none if the player is offline""" or none if the player is offline"""
async def convert(self, ctx): async def convert(self, ctx):
penguin_id = int(ctx.argument) try:
if penguin_id in ctx.p.server.penguins_by_id: try:
return ctx.p.server.penguins_by_id[penguin_id] 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 return None