Kumi
202bed25c6
Replace bunch of globals with single dictionary Move commands to subdirectory Add coin toss command (because) Add command to ignore previous messages in a room as context
14 lines
No EOL
484 B
Python
14 lines
No EOL
484 B
Python
from nio.events.room_events import RoomMessageText
|
|
from nio.rooms import MatrixRoom
|
|
|
|
from random import SystemRandom
|
|
|
|
async def command_coin(room: MatrixRoom, event: RoomMessageText, context: dict):
|
|
context["logger"]("Flipping a coin...")
|
|
|
|
heads = SystemRandom().choice([True, False])
|
|
|
|
await context["client"].room_send(
|
|
room.room_id, "m.room.message", {"msgtype": "m.notice",
|
|
"body": "Heads!" if heads else "Tails!"}
|
|
) |