pull/122/head
stijndcl 2022-09-23 20:30:00 +02:00
parent bf32a5ef47
commit 773491e2ff
2 changed files with 58 additions and 1 deletions

View File

@ -11,6 +11,7 @@ from didier import Didier
from didier.data.apis.imgflip import generate_meme
from didier.exceptions.no_match import expect
from didier.menus.memes import MemeSource
from didier.utils.discord import constants
from didier.views.modals import GenerateMeme
@ -25,6 +26,22 @@ class Fun(commands.Cog):
def __init__(self, client: Didier):
self.client = client
@commands.hybrid_command(name="clap")
async def clap(self, ctx: commands.Context, *, text: str):
"""Clap a message with emojis for extra dramatic effect"""
chars = list(filter(lambda c: c.isalnum(), text))
if not chars:
return await ctx.reply("👏", mention_author=False)
text = "👏".join(list(map(lambda c: constants.EMOJI_MAP.get(c), chars)))
text = f"👏{text}👏"
if len(text) > constants.Limits.MESSAGE_LENGTH:
return await ctx.reply("Message is too long.", mention_author=False)
return await ctx.reply(text, mention_author=False)
async def _do_generate_meme(self, meme_name: str, fields: list[str]) -> str:
async with self.client.postgres_session as session:
result = expect(await get_meme_by_name(session, meme_name), entity_type="meme", argument=meme_name)

View File

@ -1,6 +1,46 @@
from enum import Enum
__all__ = ["Limits"]
__all__ = ["EMOJI_MAP", "Limits"]
EMOJI_MAP = {
"a": "🇦",
"b": "🇧",
"c": "🇨",
"d": "🇩",
"e": "🇪",
"f": "🇫",
"g": "🇬",
"h": "🇭",
"i": "🇮",
"j": "🇯",
"k": "🇰",
"l": "🇱",
"m": "🇲",
"n": "🇳",
"o": "🇴",
"p": "🇵",
"q": "🇶",
"r": "🇷",
"s": "🇸",
"t": "🇹",
"u": "🇺",
"v": "🇻",
"w": "🇼",
"x": "🇽",
"y": "🇾",
"z": "🇿",
"0": "0⃣",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
"7": "7",
"8": "8",
"9": "9",
}
class Limits(int, Enum):