mirror of
https://github.com/Fluffy-Bean/Lynxie.git
synced 2025-05-14 08:02:17 +00:00
Clean up config.py and __main__.py
This commit is contained in:
parent
960f452e4a
commit
8bcde69224
2 changed files with 21 additions and 73 deletions
|
@ -4,9 +4,9 @@ import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.gateway import DiscordWebSocket
|
from discord.gateway import DiscordWebSocket
|
||||||
|
|
||||||
from lynxie.config import DISCORD_TOKEN, LYNXIE_PREFIX, E621_BLACKLIST
|
from lynxie.config import DISCORD_TOKEN, LYNXIE_PREFIX
|
||||||
from lynxie.database import CommandHistory, Database
|
from lynxie.database import CommandHistory, Database
|
||||||
from lynxie.utils import mobile_status
|
from lynxie.utils import mobile_status, error_message
|
||||||
from lynxie.commands import Help, Ping, Hello, Music, Animals, Img, E621
|
from lynxie.commands import Help, Ping, Hello, Music, Animals, Img, E621
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,32 +23,6 @@ lynxie = commands.Bot(
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f"Logged in as {lynxie.user} (ID: {lynxie.user.id})")
|
print(f"Logged in as {lynxie.user} (ID: {lynxie.user.id})")
|
||||||
|
|
||||||
in_guilds = "In Guilds: " + str(len(lynxie.guilds))
|
|
||||||
commands_used = "Commands called: " + str(
|
|
||||||
db.session.query(CommandHistory.user).count()
|
|
||||||
)
|
|
||||||
unique_users = "Unique Users: " + str(
|
|
||||||
db.session.query(CommandHistory.user).distinct().count()
|
|
||||||
)
|
|
||||||
blacklisted_words = "Blacklisted Words: " + str(len(E621_BLACKLIST))
|
|
||||||
|
|
||||||
bar_len = (
|
|
||||||
max(
|
|
||||||
len(in_guilds),
|
|
||||||
len(commands_used),
|
|
||||||
len(unique_users),
|
|
||||||
len(blacklisted_words),
|
|
||||||
)
|
|
||||||
+ 4
|
|
||||||
)
|
|
||||||
|
|
||||||
print("---- Stats " + "-" * (bar_len - 11))
|
|
||||||
print(f"| {in_guilds}{' ' * (bar_len - len(in_guilds) - 3)}|")
|
|
||||||
print(f"| {commands_used}{' ' * (bar_len - len(commands_used) - 3)}|")
|
|
||||||
print(f"| {unique_users}{' ' * (bar_len - len(unique_users) - 3)}|")
|
|
||||||
print(f"| {blacklisted_words}{' ' * (bar_len - len(blacklisted_words) - 3)}|")
|
|
||||||
print("-" * bar_len)
|
|
||||||
|
|
||||||
|
|
||||||
@lynxie.event
|
@lynxie.event
|
||||||
async def on_command(ctx):
|
async def on_command(ctx):
|
||||||
|
@ -68,13 +42,10 @@ async def on_command(ctx):
|
||||||
|
|
||||||
|
|
||||||
@lynxie.event
|
@lynxie.event
|
||||||
async def on_message_edit(before, after):
|
async def on_command_error(ctx, error):
|
||||||
if (
|
print(error)
|
||||||
before.author == lynxie.user
|
error = "An internal error occurred while processing your command, oopsie..."
|
||||||
or before.author.bot
|
await ctx.reply(embed=error_message(error), delete_after=5)
|
||||||
or before.content == after.content
|
|
||||||
):
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
async def run():
|
async def run():
|
||||||
|
|
|
@ -1,58 +1,32 @@
|
||||||
import os
|
import os
|
||||||
|
import requests
|
||||||
import dotenv
|
import dotenv
|
||||||
from discord import Object
|
from discord import Object
|
||||||
|
|
||||||
|
|
||||||
|
LYNXIE_PREFIX = "?"
|
||||||
|
|
||||||
DISCORD_TOKEN = (
|
DISCORD_TOKEN = (
|
||||||
dotenv.dotenv_values(".env").get("DISCORD_TOKEN")
|
dotenv.dotenv_values(".env").get("DISCORD_TOKEN")
|
||||||
or os.environ.get("DISCORD_TOKEN")
|
or os.environ.get("DISCORD_TOKEN")
|
||||||
or None
|
or None
|
||||||
)
|
)
|
||||||
DISCORD_GUILD_ID = Object(id=1040757387033849976)
|
DISCORD_GUILD_ID = Object(id=1040757387033849976)
|
||||||
LYNXIE_PREFIX = "?"
|
|
||||||
|
|
||||||
DATA_PATH = os.path.join("lynxie", "data")
|
DATA_PATH = os.path.join("lynxie", "data")
|
||||||
ASSETS_PATH = os.path.join("lynxie", "assets")
|
ASSETS_PATH = os.path.join("lynxie", "assets")
|
||||||
|
|
||||||
|
|
||||||
DATABASE_URI = f"sqlite:///" + os.path.join(DATA_PATH, "lynxie.db")
|
DATABASE_URI = f"sqlite:///" + os.path.join(DATA_PATH, "lynxie.db")
|
||||||
|
|
||||||
|
|
||||||
# https://tinyfox.dev/docs/
|
# https://tinyfox.dev/docs/
|
||||||
# TODO: Get list from API instead of hardcoding
|
tinyfox_animals = requests.get("https://api.tinyfox.dev/img?animal=animal&json").json()
|
||||||
# https://api.tinyfox.dev/img?animal=animal&json
|
TINYFOX_ANIMALS = tinyfox_animals["available"]
|
||||||
TINYFOX_ANIMALS = [
|
|
||||||
"chi",
|
|
||||||
"bear",
|
|
||||||
"dog",
|
|
||||||
"capy",
|
|
||||||
"caracal",
|
|
||||||
"chee",
|
|
||||||
"yote",
|
|
||||||
"bleat",
|
|
||||||
"dook",
|
|
||||||
"fox",
|
|
||||||
"yeen",
|
|
||||||
"jaguar",
|
|
||||||
"leo",
|
|
||||||
"lynx",
|
|
||||||
"mane",
|
|
||||||
"puma",
|
|
||||||
"poss",
|
|
||||||
"ott",
|
|
||||||
"manul",
|
|
||||||
"marten",
|
|
||||||
"bun",
|
|
||||||
"racc",
|
|
||||||
"wah",
|
|
||||||
"serval",
|
|
||||||
"shiba",
|
|
||||||
"skunk",
|
|
||||||
"snek",
|
|
||||||
"snep",
|
|
||||||
"tig",
|
|
||||||
"woof",
|
|
||||||
]
|
|
||||||
|
|
||||||
IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp"]
|
IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp"]
|
||||||
|
|
||||||
IMAGE_OVERLAYS = {
|
IMAGE_OVERLAYS = {
|
||||||
"bubble": {
|
"bubble": {
|
||||||
"path": os.path.join(ASSETS_PATH, "overlays", "bubble.png"),
|
"path": os.path.join(ASSETS_PATH, "overlays", "bubble.png"),
|
||||||
|
@ -85,6 +59,7 @@ IMAGE_OVERLAYS = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
E621_API_KEY = (
|
E621_API_KEY = (
|
||||||
dotenv.dotenv_values(".env").get("E621_API_KEY")
|
dotenv.dotenv_values(".env").get("E621_API_KEY")
|
||||||
or os.environ.get("E621_API_KEY")
|
or os.environ.get("E621_API_KEY")
|
||||||
|
@ -96,5 +71,7 @@ E621_USERNAME = (
|
||||||
or None
|
or None
|
||||||
)
|
)
|
||||||
E621_BLACKLIST = set()
|
E621_BLACKLIST = set()
|
||||||
with open(os.path.join(ASSETS_PATH, "e621_blacklist.txt"), "r") as f:
|
with open(os.path.join(ASSETS_PATH, "e621_blacklist.txt"), "r") as file:
|
||||||
[E621_BLACKLIST.add(line.strip()) for line in f.readlines() if line.strip()]
|
for line in file.readlines():
|
||||||
|
if word := line.strip():
|
||||||
|
E621_BLACKLIST.add(word)
|
||||||
|
|
Loading…
Add table
Reference in a new issue