Skip to content

Commit

Permalink
Allow !tg random command with text names instead of emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Apr 25, 2020
1 parent 37ecd57 commit 84ff0c7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mautrix_telegram/commands/telegram/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 84ff0c7

Please sign in to comment.