Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tyrant/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)

# Load the extensions we want
bot.load_extension("tyrant.cogs.ask_tyrant")
bot.load_extension("tyrant.cogs.lemon_facts")
bot.load_extension("tyrant.cogs.fruit_vs_vegetables")
bot.load_extension("tyrant.cogs.purge")
Expand Down
72 changes: 72 additions & 0 deletions tyrant/cogs/ask_tyrant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import random

from discord.ext import commands
from discord.ext.commands import Bot, Cog, Context

from tyrant import constants

# Unsuitable responses we need to remove.
UNSUITABLE_RESPONSES = [
"I'm sorry Dave, I'm afraid I can't do that.",
"Not gonna happen.",
"Out of the question.",
"Can do!",
"You're the boss!",
"I got you.",
"No problem.",
"You got it!",
]


class AskTyrant(Cog):
"""Provide answers for generic yes or no questions."""

def __init__(self, bot: Bot):
"""Initialize this cog with the Bot instance."""
self.bot = bot

self.negative_replies = list(constants.NEGATIVE_REPLIES)
self.positive_replies = list(constants.POSITIVE_REPLIES)
self.uncertain_replies = list(constants.UNCERTAIN_REPLIES)

# Filtering out unsuitable responses for use here.
for response in UNSUITABLE_RESPONSES:
if response in self.negative_replies:
self.negative_replies.remove(response)
elif response in self.positive_replies:
self.positive_replies.remove(response)
elif response in self.uncertain_replies:
self.uncertain_replies.remove(response)

self.positive_replies = tuple(self.positive_replies)
self.negative_replies = tuple(self.negative_replies)
self.uncertain_replies = tuple(self.uncertain_replies)

self.verb_lookup = {
self.positive_replies: constants.POSITIVE_VERBS,
self.negative_replies: constants.NEGATIVE_VERBS,
self.uncertain_replies: constants.UNCERTAIN_VERBS,
}

@commands.command(aliases=("8b", "8ball", "pleasesir"))
async def ask(self, ctx: Context, *, question: str = None):
"""Send random answers to generic yes or no questions."""
if question is None:
await ctx.send(
f'**The Tyrant proclaims**, "You are bad at asking questions"'
)
return

reply_pool = random.choice(
(self.positive_replies, self.negative_replies, self.uncertain_replies)
)

response_verb = random.choice(self.verb_lookup[reply_pool])
random_response = random.choice(reply_pool)

await ctx.send(f'**The Tyrant {response_verb},** "{random_response}"')


def setup(bot: Bot) -> None:
"""Add the cog to the bot."""
bot.add_cog(AskTyrant(bot))
21 changes: 21 additions & 0 deletions tyrant/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os
from typing import Optional

POSITIVE_VERBS = ["pronounces", "decrees", "proclaims", "ordains"]
NEGATIVE_VERBS = ["commands", "orders", "demands", "dictates"]
UNCERTAIN_VERBS = ["mumbles", "suggests", "mutters", "shrugs, and says"]

NEGATIVE_REPLIES = [
"Noooooo!!",
"Nope.",
Expand Down Expand Up @@ -41,6 +45,23 @@
"I'll allow it.",
]

UNCERTAIN_REPLIES = [
"I have no idea.",
"How would I know?",
"Ask me tomorrow.",
"Ask me when you're older.",
"Maybe?",
"It's hard to say for sure.",
"Who knows?",
"Nyesno.",
"Sure! Wait, maybe not.",
"You never know!",
"I know the answer, but I won't tell you.",
"Frudgeknuckle.",
"Rorchestershire.",
"Could go either way!",
]

ERROR_REPLIES = [
"Please don't do that.",
"You have to stop.",
Expand Down