mirror of
https://github.com/artiemis/artemis.git
synced 2026-02-14 08:31:55 +00:00
rewrite project into a package structure
This commit is contained in:
parent
13d2073387
commit
e2b5a245b5
0
artemis/__init__.py
Normal file
0
artemis/__init__.py
Normal file
@ -17,14 +17,16 @@ from discord import Webhook
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands.cooldowns import BucketType
|
||||
|
||||
import utils
|
||||
from utils import reddit
|
||||
from utils.api import API
|
||||
from utils.catbox import Catbox, Litterbox
|
||||
from utils.common import read_json, ArtemisError
|
||||
from utils.constants import TEMP_DIR
|
||||
from utils.unogs import uNoGS
|
||||
from utils import config
|
||||
from .cogs import EXTENSIONS
|
||||
|
||||
from . import utils
|
||||
from .utils import reddit
|
||||
from .utils.api import API
|
||||
from .utils.catbox import Catbox, Litterbox
|
||||
from .utils.common import read_json, ArtemisError
|
||||
from .utils.constants import TEMP_DIR
|
||||
from .utils.unogs import uNoGS
|
||||
from .utils import config
|
||||
|
||||
|
||||
logging.basicConfig(
|
||||
@ -118,8 +120,7 @@ class Artemis(commands.Bot):
|
||||
|
||||
await self.load_extension("jishaku")
|
||||
|
||||
extensions = [e.name for e in iter_modules(["cogs"], prefix="cogs.")]
|
||||
for extension in extensions:
|
||||
for extension in EXTENSIONS:
|
||||
await self.load_extension(extension)
|
||||
|
||||
async def close(self):
|
||||
3
artemis/cogs/__init__.py
Normal file
3
artemis/cogs/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from pkgutil import iter_modules
|
||||
|
||||
EXTENSIONS = [module.name for module in iter_modules(__path__, f"{__package__}.")]
|
||||
@ -16,13 +16,13 @@ from bs4 import BeautifulSoup
|
||||
from discord.ext import commands
|
||||
from discord.utils import format_dt
|
||||
|
||||
import utils
|
||||
from utils.common import ArtemisError
|
||||
from utils.anilist import build_anilist_embed, build_character_embed
|
||||
from utils.views import DropdownView, ViewPages
|
||||
from .. import utils
|
||||
from ..utils.common import ArtemisError
|
||||
from ..utils.anilist import build_anilist_embed, build_character_embed
|
||||
from ..utils.views import DropdownView, ViewPages
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
watching_query = """query ($userId: Int, $type: MediaType) {
|
||||
@ -11,11 +11,11 @@ from typing import TYPE_CHECKING
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from utils import config
|
||||
from utils.constants import RIP_EMOJIS, TEEHEE_EMOJIS
|
||||
from ..utils import config
|
||||
from ..utils.constants import RIP_EMOJIS, TEEHEE_EMOJIS
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
log = logging.getLogger("artemis")
|
||||
cmd_log = logging.getLogger("commands")
|
||||
@ -13,13 +13,13 @@ import pendulum
|
||||
from bs4 import BeautifulSoup
|
||||
from discord.ext import commands
|
||||
|
||||
import utils
|
||||
from utils import config
|
||||
from utils.common import ArtemisError, read_json, trim
|
||||
from utils.views import DropdownView, ViewPages
|
||||
from .. import utils
|
||||
from ..utils import config
|
||||
from ..utils.common import ArtemisError, read_json, trim
|
||||
from ..utils.views import DropdownView, ViewPages
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
class Pokemon(TypedDict):
|
||||
@ -17,22 +17,22 @@ from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from wiktionaryparser import WiktionaryParser
|
||||
|
||||
import utils
|
||||
from utils import iso_639
|
||||
from utils.common import (
|
||||
from .. import utils
|
||||
from ..utils import iso_639
|
||||
from ..utils.common import (
|
||||
ArtemisError,
|
||||
Stopwatch,
|
||||
read_json,
|
||||
)
|
||||
from utils.constants import (
|
||||
from ..utils.constants import (
|
||||
GT_LANGUAGES_EXTRAS,
|
||||
WIKT_LANGUAGES,
|
||||
)
|
||||
from utils.flags import TranslateFlags, TTSFlags, WiktionaryFlags
|
||||
from utils.views import ViewPages
|
||||
from ..utils.flags import TranslateFlags, TTSFlags, WiktionaryFlags
|
||||
from ..utils.views import ViewPages
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
# Mod aiogoogletrans
|
||||
GT_LANGUAGES.update(GT_LANGUAGES_EXTRAS)
|
||||
@ -21,16 +21,16 @@ from PIL import Image
|
||||
from pycaption import SRTWriter, WebVTTReader
|
||||
from yt_dlp.utils import parse_duration
|
||||
|
||||
import utils
|
||||
from utils.common import ArtemisError
|
||||
from utils.constants import MAX_DISCORD_SIZE, MAX_LITTERBOX_SIZE, TEMP_DIR
|
||||
from utils.catbox import CatboxError
|
||||
from utils.flags import DLFlags
|
||||
from utils.iso_639 import get_language_name
|
||||
from utils.views import DropdownView
|
||||
from .. import utils
|
||||
from ..utils.common import ArtemisError
|
||||
from ..utils.constants import MAX_DISCORD_SIZE, MAX_LITTERBOX_SIZE, TEMP_DIR
|
||||
from ..utils.catbox import CatboxError
|
||||
from ..utils.flags import DLFlags
|
||||
from ..utils.iso_639 import get_language_name
|
||||
from ..utils.views import DropdownView
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
yt_dlp.utils.bug_reports_message = lambda: ""
|
||||
|
||||
@ -15,12 +15,12 @@ from discord.ext import commands
|
||||
from discord.utils import format_dt, snowflake_time
|
||||
from humanize import naturalsize
|
||||
|
||||
import utils
|
||||
from utils.common import ArtemisError
|
||||
from utils.views import BaseView
|
||||
from .. import utils
|
||||
from ..utils.common import ArtemisError
|
||||
from ..utils.views import BaseView
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
class Meta(commands.Cog):
|
||||
@ -6,10 +6,10 @@ import discord
|
||||
import pendulum
|
||||
from discord.ext import commands
|
||||
|
||||
from utils.common import ArtemisError, parse_short_time
|
||||
from ..utils.common import ArtemisError, parse_short_time
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
class ShortTime(commands.Converter):
|
||||
@ -10,12 +10,12 @@ from typing import TYPE_CHECKING, Optional
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
import utils
|
||||
from cogs.media import DEFAULT_OPTS, run_ytdlp
|
||||
from utils.views import DropdownView
|
||||
from .. import utils
|
||||
from ..utils.views import DropdownView
|
||||
from .media import DEFAULT_OPTS, run_ytdlp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
async def in_voice_channel(ctx: commands.Context):
|
||||
@ -10,14 +10,14 @@ import discord
|
||||
import magic
|
||||
from discord.ext import commands
|
||||
|
||||
import utils
|
||||
from utils.common import ArtemisError
|
||||
from utils.constants import TESSERACT_LANGUAGES
|
||||
from utils.flags import Flags, OCRFlags, OCRTranslateFlags
|
||||
from utils.iso_639 import get_language_name
|
||||
from .. import utils
|
||||
from ..utils.common import ArtemisError
|
||||
from ..utils.constants import TESSERACT_LANGUAGES
|
||||
from ..utils.flags import Flags, OCRFlags, OCRTranslateFlags
|
||||
from ..utils.iso_639 import get_language_name
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
class OCR(commands.Cog):
|
||||
@ -13,13 +13,13 @@ from discord.ext import commands
|
||||
from jishaku import codeblocks
|
||||
import pendulum
|
||||
|
||||
import utils
|
||||
from utils.common import ArtemisError
|
||||
from utils.constants import TEMP_DIR
|
||||
from utils.views import BaseView
|
||||
from .. import utils
|
||||
from ..utils.common import ArtemisError
|
||||
from ..utils.constants import TEMP_DIR
|
||||
from ..utils.views import BaseView
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
class Owner(commands.Cog, command_attrs={"hidden": True}):
|
||||
@ -19,14 +19,14 @@ from discord.utils import format_dt
|
||||
from humanize import intcomma
|
||||
from PIL import Image
|
||||
|
||||
import utils
|
||||
from utils import enigma2
|
||||
from utils.common import ArtemisError
|
||||
from utils.flags import WikipediaFlags
|
||||
from utils.views import DropdownView
|
||||
from .. import utils
|
||||
from ..utils import enigma2
|
||||
from ..utils.common import ArtemisError
|
||||
from ..utils.flags import WikipediaFlags
|
||||
from ..utils.views import DropdownView
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
class Useful(commands.Cog):
|
||||
@ -6,7 +6,7 @@ from typing import Any, Optional
|
||||
import discord
|
||||
from anilist.types import Anime, Character, Manga
|
||||
|
||||
from utils.common import trim
|
||||
from .common import trim
|
||||
|
||||
ANILIST_COLOR = 0x02A9FF
|
||||
FOOTER = "Powered by AniList APIv2"
|
||||
@ -4,12 +4,12 @@ import asyncio
|
||||
import io
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING, Any, Literal
|
||||
from utils.common import ArtemisError
|
||||
from .common import ArtemisError
|
||||
|
||||
import aiohttp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -5,7 +5,7 @@ from typing import Dict, Literal, Optional
|
||||
|
||||
import aiohttp
|
||||
|
||||
from utils.common import is_valid_url
|
||||
from .common import is_valid_url
|
||||
|
||||
Expiration = Literal[1, 12, 24, 72]
|
||||
|
||||
@ -24,10 +24,10 @@ from discord.ext import commands
|
||||
import feedparser
|
||||
from rapidfuzz import process
|
||||
|
||||
import utils
|
||||
from .. import utils
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
# url regex
|
||||
@ -1,5 +1,5 @@
|
||||
import os
|
||||
from utils.common import read_toml
|
||||
from .common import read_toml
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from pathlib import Path
|
||||
from utils.common import read_json
|
||||
from .common import read_json
|
||||
|
||||
MAX_DISCORD_SIZE = 25 * 1024**2
|
||||
MAX_API_SIZE = 200 * 1024**2
|
||||
@ -6,10 +6,10 @@ from csv import DictReader
|
||||
from io import StringIO
|
||||
from typing import TYPE_CHECKING, Literal, TypedDict
|
||||
|
||||
from utils.common import fuzzy_search, read_json
|
||||
from .common import fuzzy_search, read_json
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
|
||||
class Language(TypedDict):
|
||||
@ -8,7 +8,7 @@ from collections import deque
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import Artemis
|
||||
from ..bot import Artemis
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
@ -12,8 +12,8 @@ from aiohttp import ClientSession
|
||||
from humanize import intcomma
|
||||
from yt_dlp.utils import random_user_agent
|
||||
|
||||
import utils
|
||||
from utils.common import ArtemisError
|
||||
from . import utils
|
||||
from .common import ArtemisError
|
||||
|
||||
|
||||
class Route:
|
||||
@ -7,7 +7,7 @@ from urllib.parse import quote
|
||||
from aiohttp import ClientSession
|
||||
from yt_dlp.utils import random_user_agent
|
||||
|
||||
import utils
|
||||
from . import utils
|
||||
|
||||
|
||||
class uNoGSError(Exception):
|
||||
@ -3,7 +3,7 @@ from typing import Any, List
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from utils.common import trim
|
||||
from .common import trim
|
||||
|
||||
|
||||
class BaseView(discord.ui.View):
|
||||
Loading…
x
Reference in New Issue
Block a user