Allow !tg random command with text names instead of emojis

This commit is contained in:
Tulir Asokan
2020-04-25 18:33:34 +03:00
parent 37ecd57a9b
commit 84ff0c777d
+6 -2
View File
@@ -315,10 +315,14 @@ async def random(evt: CommandEvent) -> EventID:
if not evt.is_portal:
return await evt.reply("You can only roll dice in portal rooms")
portal = po.Portal.get_by_mxid(evt.room_id)
arg = evt.args[0] if len(evt.args) > 0 else "dice"
emoticon = {
"dart": "\U0001F3AF",
"dice": "\U0001F3B2",
}.get(arg, arg)
try:
await evt.sender.client.send_media(await portal.get_input_entity(evt.sender),
InputMediaDice(evt.args[0] if len(evt.args) > 0
else "\U0001F3B2"))
InputMediaDice(emoticon))
except EmoticonInvalidError:
return await evt.reply("Invalid emoji for randomization")