Files
overub/modules/fun/__init__.py
2025-12-21 17:12:32 +01:00

82 lines
2.5 KiB
Python

import random
from core.module import Module
class FunModule(Module):
name = "fun"
version = "0.1.0"
description = "Fun commands"
async def on_load(self) -> None:
builder = self.commands
@builder.command(
name="dice",
description="Roll a dice",
category="fun",
usage=".dice",
)
async def dice_cmd(event, args):
await event.reply(f"You rolled {random.randint(1, 6)}")
@builder.command(
name="joke",
description="Tell a joke",
category="fun",
usage=".joke",
)
async def joke_cmd(event, args):
jokes = [
"Why do programmers prefer dark mode? Because light attracts bugs.",
"There are 10 types of people in the world: those who understand binary and those who don't.",
"I would tell you a UDP joke, but you might not get it.",
]
await event.reply(random.choice(jokes))
@builder.command(
name="8ball",
description="Magic 8-ball",
category="fun",
usage=".8ball <question>",
)
async def eightball_cmd(event, args):
answers = [
"Yes.",
"No.",
"Maybe.",
"Ask again later.",
"Definitely.",
]
await event.reply(random.choice(answers))
@builder.command(
name="rps",
description="Rock paper scissors",
category="fun",
usage=".rps <rock|paper|scissors>",
)
async def rps_cmd(event, args):
choices = ["rock", "paper", "scissors"]
user = args[0].lower() if args else ""
if user not in choices:
await event.reply("Choose rock, paper, or scissors")
return
bot = random.choice(choices)
await event.reply(f"You: {user} | Bot: {bot}")
@builder.command(
name="trivia",
description="Trivia question",
category="fun",
usage=".trivia",
)
async def trivia_cmd(event, args):
trivia = [
("What is the capital of France?", "Paris"),
("2 + 2 = ?", "4"),
("What language is OverUB written in?", "Python"),
]
question, answer = random.choice(trivia)
await event.reply(f"{question}\nAnswer: {answer}")