feat: complete roll command

This commit is contained in:
RatCornu 2026-04-05 02:07:36 +02:00
parent 74f991af40
commit 3ab4e424a1
Signed by: ratcornu
GPG key ID: B3BE02E379E6E8E2
2 changed files with 120 additions and 10 deletions

28
main.py
View file

@ -26,21 +26,36 @@ bot.start_time = datetime.now()
async def ping(room, message):
mtch = matrix.match.MessageMatch(room, message, bot, PREFIX)
if mtch.is_not_from_this_bot and mtch.prefix and mtch.command("ping"):
await misc.ping(bot, mtch, room, message)
try:
await misc.ping(bot, mtch, room, message)
except Exception as e:
await bot.api.send_text_message(
room.room_id, f"Unexpected error: {e}", reply_to=message.event_id
)
@bot.listener.on_message_event
async def echo(room, message):
mtch = matrix.match.MessageMatch(room, message, bot, PREFIX)
if mtch.is_not_from_this_bot and mtch.prefix and mtch.command("echo"):
await misc.echo(bot, mtch, room, message)
try:
await misc.echo(bot, mtch, room, message)
except Exception as e:
await bot.api.send_text_message(
room.room_id, f"Unexpected error: {e}", reply_to=message.event_id
)
@bot.listener.on_message_event
async def uptime(room, message):
mtch = matrix.match.MessageMatch(room, message, bot, PREFIX)
if mtch.is_not_from_this_bot and mtch.prefix and mtch.command("uptime"):
await misc.uptime(bot, mtch, room, message)
try:
await misc.uptime(bot, mtch, room, message)
except Exception as e:
await bot.api.send_text_message(
room.room_id, f"Unexpected error: {e}", reply_to=message.event_id
)
@bot.listener.on_message_event
@ -51,7 +66,12 @@ async def roll(room, message):
and mtch.prefix
and (mtch.command("roll") or mtch.command("r"))
):
await dice.roll(bot, mtch, room, message)
try:
await dice.roll(bot, mtch, room, message)
except Exception as e:
await bot.api.send_text_message(
room.room_id, f"Unexpected error: {e}", reply_to=message.event_id
)
bot.run()