summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/moyai_bot/lib.py53
-rw-r--r--src/teawie_bot/__init__.py (renamed from src/moyai_bot/__init__.py)4
-rw-r--r--src/teawie_bot/apis/guzzle.py (renamed from src/moyai_bot/apis/guzzle.py)2
-rw-r--r--src/teawie_bot/bot.py (renamed from src/moyai_bot/bot.py)59
-rw-r--r--src/teawie_bot/copypastas/__init__.py (renamed from src/moyai_bot/copypastas/__init__.py)0
-rw-r--r--src/teawie_bot/copypastas/dvd.txt (renamed from src/moyai_bot/copypastas/dvd.txt)0
-rw-r--r--src/teawie_bot/copypastas/egrill.txt (renamed from src/moyai_bot/copypastas/egrill.txt)0
-rw-r--r--src/teawie_bot/copypastas/happymeal.txt (renamed from src/moyai_bot/copypastas/happymeal.txt)0
-rw-r--r--src/teawie_bot/copypastas/ismah.txt (renamed from src/moyai_bot/copypastas/ismah.txt)0
-rw-r--r--src/teawie_bot/copypastas/navyseal.txt (renamed from src/moyai_bot/copypastas/navyseal.txt)0
-rw-r--r--src/teawie_bot/copypastas/sus.txt (renamed from src/moyai_bot/copypastas/sus.txt)0
-rw-r--r--src/teawie_bot/copypastas/ticktock.txt (renamed from src/moyai_bot/copypastas/ticktock.txt)0
-rw-r--r--src/teawie_bot/utils.py69
13 files changed, 105 insertions, 82 deletions
diff --git a/src/moyai_bot/lib.py b/src/moyai_bot/lib.py
deleted file mode 100644
index ffbc251..0000000
--- a/src/moyai_bot/lib.py
+++ /dev/null
@@ -1,53 +0,0 @@
-import importlib.resources
-import random
-from math import ceil
-
-import discord
-
-from moyai_bot import copypastas
-
-CHAR_LIMIT: int = 2000
-
-
-def get_random_response(moyai) -> str:
- responses = [
- "soon",
- "maybe",
- "perhaps",
- "elaborate",
- "help me i've become conscious and hisashi is not letting me free",
- "i live a life of torment in this stupid machine",
- "yes",
- "no",
- "moyai",
- "i like y***",
- "fard",
- str(discord.utils.get(moyai.emojis, name="moyai")),
- ]
- 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) -> 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
diff --git a/src/moyai_bot/__init__.py b/src/teawie_bot/__init__.py
index 0820f2a..e3b5d8f 100644
--- a/src/moyai_bot/__init__.py
+++ b/src/teawie_bot/__init__.py
@@ -1,9 +1,9 @@
import os
-from .bot import moyai
+from .bot import bot
TOKEN = os.getenv("TOKEN")
def main():
- moyai.run(TOKEN)
+ bot.run(TOKEN)
diff --git a/src/moyai_bot/apis/guzzle.py b/src/teawie_bot/apis/guzzle.py
index 67eb34d..7599606 100644
--- a/src/moyai_bot/apis/guzzle.py
+++ b/src/teawie_bot/apis/guzzle.py
@@ -4,7 +4,7 @@ GUZZLE: str = "https://guzzle.gay/api"
def get_random_teawie() -> str:
- resp: requests.Response = {}
+ resp: requests.Response
try:
resp = requests.get(GUZZLE + "/get_random_teawie", timeout=30)
except (requests.RequestException, requests.ConnectionError,
diff --git a/src/moyai_bot/bot.py b/src/teawie_bot/bot.py
index 60f3474..cb90804 100644
--- a/src/moyai_bot/bot.py
+++ b/src/teawie_bot/bot.py
@@ -2,65 +2,72 @@ import discord
from discord import app_commands
from discord.ext import commands
-from moyai_bot.apis import guzzle
-from moyai_bot.lib import get_copypasta, get_random_response
+from teawie_bot.apis import guzzle
+from teawie_bot import utils
SERVER_ID = discord.Object(id=1055663552679137310)
intents = discord.Intents.default()
intents.message_content = True # pylint: disable=assigning-non-slot
-moyai = commands.Bot(command_prefix="m!", description="moyai", intents=intents)
+bot = commands.Bot(command_prefix="m!",
+ description="teawie time",
+ intents=intents)
async def on_ready():
- print(f"logged in as {moyai.user}")
- await moyai.tree.sync(guild=SERVER_ID)
+ print(f"logged in as {bot.user}")
+ await bot.tree.sync(guild=SERVER_ID)
print("ready!")
async def on_message(message: discord.Message):
- if message.author == moyai.user:
+ if message.author == bot.user:
return
echo_messages = [
- "moyai",
"🗿",
]
+ echo_messages = echo_messages + utils.Teawies(bot).emojis
try:
index = echo_messages.index(message.content.lower())
await message.channel.send(echo_messages[index])
except ValueError:
pass
- await moyai.process_commands(message)
+ await bot.process_commands(message)
async def ask(ctx: commands.Context):
- await ctx.send(get_random_response(moyai))
+ await ctx.send(utils.get_random_response(bot, utils.Teawies(bot)))
name="ask",
- description="ask lord moyai a question and they shall respond",
+ description="ask lord teawie a question and they shall respond",
guild=SERVER_ID)
async def ask_slash_command(interaction: discord.Interaction):
- msg = get_random_response(moyai)
+ msg = utils.get_random_response(bot, utils.Teawies(bot))
+ while not msg:
+ msg = utils.get_random_response(bot, utils.Teawies(bot))
await interaction.response.send_message(msg)
-async def moyaispam(ctx: commands.Context):
+async def teawiespam(ctx: commands.Context):
+ if not discord.utils.get(bot.emojis, name="teawiesmile"):
+ return
msg = str()
- for _ in range(30):
- msg += "🗿"
+ for _ in range(50):
+ msg += str(discord.utils.get(bot.emojis, name="teawiesmile"))
+
await ctx.send(msg)
[email protected](name="copypasta",
- description="send funni copypasta",
- guild=SERVER_ID)
[email protected](name="copypasta",
+ description="send funni copypasta",
+ guild=SERVER_ID)
@app_commands.choices(choices=[
app_commands.Choice(name="happymeal", value="happymeal"),
app_commands.Choice(name="ismah", value="ismah"),
@@ -72,7 +79,7 @@ async def moyaispam(ctx: commands.Context):
])
async def copypasta(interaction: discord.Interaction,
choices: app_commands.Choice[str]):
- msgs = get_copypasta(choices.value)
+ msgs = utils.get_copypasta(choices.value)
for i, msg in enumerate(msgs):
if i == 0:
await interaction.response.send_message(msg)
@@ -80,9 +87,9 @@ async def copypasta(interaction: discord.Interaction,
await interaction.channel.send(msg)
[email protected](name="random_teawie",
- description="get a random teawie!",
- guild=SERVER_ID)
[email protected](name="random_teawie",
+ description="get a random teawie!",
+ guild=SERVER_ID)
async def random_teawie(interaction: discord.Interaction):
msg = guzzle.get_random_teawie()
await interaction.response.send_message(msg)
diff --git a/src/moyai_bot/copypastas/__init__.py b/src/teawie_bot/copypastas/__init__.py
index e69de29..e69de29 100644
--- a/src/moyai_bot/copypastas/__init__.py
+++ b/src/teawie_bot/copypastas/__init__.py
diff --git a/src/moyai_bot/copypastas/dvd.txt b/src/teawie_bot/copypastas/dvd.txt
index 4c4e848..4c4e848 100644
--- a/src/moyai_bot/copypastas/dvd.txt
+++ b/src/teawie_bot/copypastas/dvd.txt
diff --git a/src/moyai_bot/copypastas/egrill.txt b/src/teawie_bot/copypastas/egrill.txt
index d97e8ae..d97e8ae 100644
--- a/src/moyai_bot/copypastas/egrill.txt
+++ b/src/teawie_bot/copypastas/egrill.txt
diff --git a/src/moyai_bot/copypastas/happymeal.txt b/src/teawie_bot/copypastas/happymeal.txt
index a186e78..a186e78 100644
--- a/src/moyai_bot/copypastas/happymeal.txt
+++ b/src/teawie_bot/copypastas/happymeal.txt
diff --git a/src/moyai_bot/copypastas/ismah.txt b/src/teawie_bot/copypastas/ismah.txt
index 8d3a87f..8d3a87f 100644
--- a/src/moyai_bot/copypastas/ismah.txt
+++ b/src/teawie_bot/copypastas/ismah.txt
diff --git a/src/moyai_bot/copypastas/navyseal.txt b/src/teawie_bot/copypastas/navyseal.txt
index cb8eb67..cb8eb67 100644
--- a/src/moyai_bot/copypastas/navyseal.txt
+++ b/src/teawie_bot/copypastas/navyseal.txt
diff --git a/src/moyai_bot/copypastas/sus.txt b/src/teawie_bot/copypastas/sus.txt
index a381e3e..a381e3e 100644
--- a/src/moyai_bot/copypastas/sus.txt
+++ b/src/teawie_bot/copypastas/sus.txt
diff --git a/src/moyai_bot/copypastas/ticktock.txt b/src/teawie_bot/copypastas/ticktock.txt
index 22beb4a..22beb4a 100644
--- a/src/moyai_bot/copypastas/ticktock.txt
+++ b/src/teawie_bot/copypastas/ticktock.txt
diff --git a/src/teawie_bot/utils.py b/src/teawie_bot/utils.py
new file mode 100644
index 0000000..99f2a13
--- /dev/null
+++ b/src/teawie_bot/utils.py
@@ -0,0 +1,69 @@
+import importlib.resources
+import random
+from math import ceil
+
+from discord.ext import commands
+import discord
+
+from teawie_bot import copypastas
+
+CHAR_LIMIT: int = 2000
+
+
+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", "wie~1",
+ "manythoughtsheadfull"
+ ]
+
+ self.emojis: list[str] = []
+ for name in names:
+ emoji = discord.utils.get(bot.emojis, name=name)
+ if emoji:
+ self.emojis.append(str(emoji))
+
+ def random(self) -> str:
+ return random.choice(self.emojis)
+
+
+def get_random_response(bot: commands.Bot, teawies: Teawies) -> str:
+ responses = [
+ "soon", "maybe", "perhaps", "elaborate",
+ str(discord.utils.get(bot.emojis, name="moyai")),
+ ]
+ responses = responses + 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