coin.py 400 B

12345678910111213
  1. from nio.events.room_events import RoomMessageText
  2. from nio.rooms import MatrixRoom
  3. from random import SystemRandom
  4. async def command_coin(room: MatrixRoom, event: RoomMessageText, bot):
  5. bot.logger.log("Flipping a coin...")
  6. heads = SystemRandom().choice([True, False])
  7. body = "Flipping a coin... It's " + ("heads!" if heads else "tails!")
  8. await bot.send_message(room, body, True)