2023-04-19 06:11:28 +00:00
|
|
|
from nio.events.room_events import RoomMessageText
|
|
|
|
from nio.rooms import MatrixRoom
|
|
|
|
|
|
|
|
from random import SystemRandom
|
|
|
|
|
2023-04-23 13:26:46 +00:00
|
|
|
|
2023-04-25 11:25:53 +00:00
|
|
|
async def command_coin(room: MatrixRoom, event: RoomMessageText, bot):
|
|
|
|
bot.logger.log("Flipping a coin...")
|
2023-04-19 06:11:28 +00:00
|
|
|
|
|
|
|
heads = SystemRandom().choice([True, False])
|
2023-04-25 11:25:53 +00:00
|
|
|
body = "Flipping a coin... It's " + ("heads!" if heads else "tails!")
|
2023-04-19 06:11:28 +00:00
|
|
|
|
2023-04-25 11:25:53 +00:00
|
|
|
await bot.send_message(room, body, True)
|