From 52e58d2da91d2980823612d6c55e41ed6af0382e Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 4 Feb 2023 23:12:58 -0500 Subject: feat: bit of a refactor - moved teawie_bot to root directory - added nix flake --- src/teawie_bot/utils.py | 70 ------------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 src/teawie_bot/utils.py (limited to 'src/teawie_bot/utils.py') diff --git a/src/teawie_bot/utils.py b/src/teawie_bot/utils.py deleted file mode 100644 index c75135b..0000000 --- a/src/teawie_bot/utils.py +++ /dev/null @@ -1,70 +0,0 @@ -import importlib.resources -import random -from math import ceil - -import discord -from discord.ext import commands - -from teawie_bot import copypastas - -CHAR_LIMIT: int = 2000 - - -# pylint: disable-next=too-few-public-methods -class Teawies: - """ - wrapper class around list[discord.Emoji] - """ - - def __init__(self, bot: commands.Bot): - names = [ - "teawiecry", "teawiederp", "teawiedizzy", - "teawienerdcroppedanddownsized", "teawieneutral", "teawiepet", - "teawiepetfast", "teawiepop", "teawiesmile", "teawiesmug", - "teawiestarstruck", "tei", "wavy", "wie", "manythoughtsheadfull" - ] - - self.emojis: list[str] = [ - str(discord.utils.get(bot.emojis, name=name)) for name in names - ] - - def random(self) -> str: - return random.choice(self.emojis) - - -def get_random_response(bot: commands.Bot) -> str: - responses = [ - "soon", - "maybe", - "perhaps", - "elaborate", - str(discord.utils.get(bot.emojis, name="moyai")), - ] - responses = responses + bot.teawies.emojis - return random.choice(responses) - - -def split_msg(msg: str) -> list[str]: - """ - splits a message into multiple parts so that it - can fit into the discord character limit - """ - split = ceil(len(msg) / ceil(len(msg) / CHAR_LIMIT)) - return [msg[i:i + split] for i in range(0, len(msg), split)] - - -def get_copypasta(name: str) -> list[str]: - try: - res = importlib.resources.read_text(copypastas, name + ".txt") - except OSError: - return ["something went wrong :("] - - if res == "": - return [f"couldn't send copypasta: {name} :("] - - if len(res) >= CHAR_LIMIT: - res = split_msg(res) - else: - res = [res] - - return res -- cgit v1.2.3