diff --git a/apps/admin/__init__.py b/apps/admin/__init__.py index 816679c6..55820fe9 100644 --- a/apps/admin/__init__.py +++ b/apps/admin/__init__.py @@ -1,6 +1,6 @@ -from utils.apps.manager import listener_service from utils.mysql import MySQL from utils.redisdb import RedisDB +from utils.service.manager import listener_service from .cache import BotAdminCache from .repositories import BotAdminRepository from .services import BotAdminService diff --git a/apps/cookies/__init__.py b/apps/cookies/__init__.py index c526d388..80f14543 100644 --- a/apps/cookies/__init__.py +++ b/apps/cookies/__init__.py @@ -1,6 +1,6 @@ -from utils.apps.manager import listener_service from utils.mysql import MySQL from utils.redisdb import RedisDB +from utils.service.manager import listener_service from .cache import PublicCookiesCache from .repositories import CookiesRepository from .services import CookiesService, PublicCookiesService diff --git a/apps/game/__init__.py b/apps/game/__init__.py index 08090792..e57d7d28 100644 --- a/apps/game/__init__.py +++ b/apps/game/__init__.py @@ -1,5 +1,5 @@ -from utils.apps.manager import listener_service from utils.redisdb import RedisDB +from utils.service.manager import listener_service from .cache import GameStrategyCache from .services import GameStrategyService diff --git a/apps/sign/__init__.py b/apps/sign/__init__.py index 9ac44b84..3b418793 100644 --- a/apps/sign/__init__.py +++ b/apps/sign/__init__.py @@ -1,5 +1,5 @@ -from utils.apps.manager import listener_service from utils.mysql import MySQL +from utils.service.manager import listener_service from .repositories import SignRepository from .services import SignServices diff --git a/apps/template/__init__.py b/apps/template/__init__.py index 714c0f24..441825dd 100644 --- a/apps/template/__init__.py +++ b/apps/template/__init__.py @@ -1,5 +1,5 @@ from utils.aiobrowser import AioBrowser -from utils.apps.manager import listener_service +from utils.service.manager import listener_service from .services import TemplateService diff --git a/apps/user/__init__.py b/apps/user/__init__.py index 7b893be5..1286bb24 100644 --- a/apps/user/__init__.py +++ b/apps/user/__init__.py @@ -1,5 +1,5 @@ -from utils.apps.manager import listener_service from utils.mysql import MySQL +from utils.service.manager import listener_service from .repositories import UserRepository from .services import UserService diff --git a/apps/wiki/__init__.py b/apps/wiki/__init__.py index ed08a82b..078927b8 100644 --- a/apps/wiki/__init__.py +++ b/apps/wiki/__init__.py @@ -1,5 +1,5 @@ -from utils.apps.manager import listener_service from utils.redisdb import RedisDB +from utils.service.manager import listener_service from .cache import WikiCache from .services import WikiService diff --git a/jobs/public_cookies.py b/jobs/public_cookies.py index ceaf908c..e614230e 100644 --- a/jobs/public_cookies.py +++ b/jobs/public_cookies.py @@ -4,8 +4,8 @@ from telegram.ext import CallbackContext, JobQueue from apps.cookies.services import PublicCookiesService from logger import Log -from utils.apps.inject import inject from utils.job.manager import listener_jobs_class +from utils.service.inject import inject @listener_jobs_class() diff --git a/jobs/sign.py b/jobs/sign.py index 5bc0f835..dfabe233 100644 --- a/jobs/sign.py +++ b/jobs/sign.py @@ -13,9 +13,9 @@ from apps.sign.services import SignServices from apps.user import UserService from config import config from logger import Log -from utils.apps.inject import inject from utils.helpers import get_genshin_client from utils.job.manager import listener_jobs_class +from utils.service.inject import inject @listener_jobs_class() diff --git a/main.py b/main.py index 56c74cff..27e23c73 100644 --- a/main.py +++ b/main.py @@ -8,11 +8,11 @@ from telegram.warnings import PTBUserWarning from config import config from logger import Log from utils.aiobrowser import AioBrowser -from utils.apps.manager import ServicesManager from utils.job.register import register_job from utils.mysql import MySQL from utils.plugins.register import register_plugin_handlers from utils.redisdb import RedisDB +from utils.service.manager import ServicesManager # 无视相关警告 # 该警告说明在官方GITHUB的WIKI中Frequently Asked Questions里的What do the per_* settings in ConversationHandler do? diff --git a/plugins/abyss.py b/plugins/abyss.py index 73bda501..903185c8 100644 --- a/plugins/abyss.py +++ b/plugins/abyss.py @@ -9,11 +9,11 @@ from apps.user import UserService from apps.user.repositories import UserNotFoundError from logger import Log from plugins.base import BasePlugins -from utils.apps.inject import inject from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import get_genshin_client, url_to_file from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/plugins/adduser.py b/plugins/adduser.py index caf3c52d..0ff57fe9 100644 --- a/plugins/adduser.py +++ b/plugins/adduser.py @@ -14,10 +14,10 @@ from apps.user.services import UserService from logger import Log from models.base import RegionEnum from plugins.base import BasePlugins -from utils.apps.inject import inject from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject class AddUserCommandData(TelegramObject): diff --git a/plugins/admin.py b/plugins/admin.py index 71a7de21..19fbe69e 100644 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -4,9 +4,9 @@ from telegram.ext import CallbackContext, CommandHandler from apps.admin import BotAdminService from logger import Log -from utils.apps.inject import inject from utils.decorators.admins import bot_admins_rights_check from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/plugins/base.py b/plugins/base.py index 11f6a2b9..75bec7e3 100644 --- a/plugins/base.py +++ b/plugins/base.py @@ -6,7 +6,7 @@ from telegram.ext import CallbackContext, ConversationHandler, filters from apps.admin.services import BotAdminService from logger import Log -from utils.apps.inject import inject +from utils.service.inject import inject async def clean_message(context: CallbackContext, chat_id: int, message_id: int) -> bool: diff --git a/plugins/daily_note.py b/plugins/daily_note.py index d781ce3f..999ab7a7 100644 --- a/plugins/daily_note.py +++ b/plugins/daily_note.py @@ -14,11 +14,11 @@ from apps.user.repositories import UserNotFoundError from apps.user.services import UserService from logger import Log from plugins.base import BasePlugins -from utils.apps.inject import inject from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import get_genshin_client from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/plugins/gacha/gacha.py b/plugins/gacha/gacha.py index 5bf1d70b..18a54008 100644 --- a/plugins/gacha/gacha.py +++ b/plugins/gacha/gacha.py @@ -10,11 +10,11 @@ from logger import Log from models.apihelper.gacha import GachaInfo from plugins.base import BasePlugins from plugins.gacha.wish import WishCountInfo, get_one -from utils.apps.inject import inject from utils.bot import get_all_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/plugins/help.py b/plugins/help.py index ad44daa3..243d1225 100644 --- a/plugins/help.py +++ b/plugins/help.py @@ -6,10 +6,10 @@ from telegram.ext import CommandHandler, CallbackContext from apps.template.services import TemplateService from config import config from logger import Log -from utils.apps.inject import inject from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/plugins/inline.py b/plugins/inline.py index aa9d9121..a42d1196 100644 --- a/plugins/inline.py +++ b/plugins/inline.py @@ -8,7 +8,7 @@ from telegram.ext import CallbackContext from apps.wiki import WikiService from logger import Log -from utils.apps.inject import inject +from utils.service.inject import inject class Inline: diff --git a/plugins/ledger.py b/plugins/ledger.py index c33850ee..6821cc95 100644 --- a/plugins/ledger.py +++ b/plugins/ledger.py @@ -14,12 +14,12 @@ from apps.user.repositories import UserNotFoundError from apps.user.services import UserService from logger import Log from plugins.base import BasePlugins -from utils.apps.inject import inject from utils.bot import get_all_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import get_genshin_client from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject def check_ledger_month(context: CallbackContext) -> int: diff --git a/plugins/sign.py b/plugins/sign.py index 5bffbbed..76519e79 100644 --- a/plugins/sign.py +++ b/plugins/sign.py @@ -6,18 +6,18 @@ from telegram import Update from telegram.ext import CommandHandler, MessageHandler, ConversationHandler, filters, CallbackContext from apps.cookies.services import CookiesService -from apps.sign.services import SignServices from apps.sign.models import Sign as SignUser, SignStatusEnum +from apps.sign.services import SignServices from apps.user.repositories import UserNotFoundError from apps.user.services import UserService from logger import Log from plugins.base import BasePlugins -from utils.apps.inject import inject from utils.bot import get_all_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import get_genshin_client from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/plugins/strategy.py b/plugins/strategy.py index a99d8ad6..c1031884 100644 --- a/plugins/strategy.py +++ b/plugins/strategy.py @@ -5,12 +5,12 @@ from telegram.ext import filters, ConversationHandler, CommandHandler, MessageHa from apps.game.services import GameStrategyService from logger import Log from plugins.base import BasePlugins -from utils.apps.inject import inject from utils.bot import get_all_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import url_to_file from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/plugins/uid.py b/plugins/uid.py index 95e2448e..071e3bfc 100644 --- a/plugins/uid.py +++ b/plugins/uid.py @@ -13,11 +13,11 @@ from apps.user.repositories import UserNotFoundError from apps.user.services import UserService from logger import Log from plugins.base import BasePlugins -from utils.apps.inject import inject from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import url_to_file, get_genshin_client from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/plugins/weapon.py b/plugins/weapon.py index d8bb93f8..e63c1f07 100644 --- a/plugins/weapon.py +++ b/plugins/weapon.py @@ -7,12 +7,12 @@ from apps.wiki.services import WikiService from logger import Log from metadata.shortname import weaponToName from plugins.base import BasePlugins -from utils.apps.inject import inject from utils.bot import get_all_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import url_to_file from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/plugins/wiki.py b/plugins/wiki.py index 3664cea2..e4bebe67 100644 --- a/plugins/wiki.py +++ b/plugins/wiki.py @@ -3,10 +3,10 @@ from telegram.ext import CommandHandler, CallbackContext from apps.wiki.services import WikiService from plugins.base import BasePlugins -from utils.apps.inject import inject from utils.decorators.admins import bot_admins_rights_check from utils.decorators.error import error_callable from utils.plugins.manager import listener_plugins_class +from utils.service.inject import inject @listener_plugins_class() diff --git a/utils/decorators/admins.py b/utils/decorators/admins.py index 417c75b7..285c860f 100644 --- a/utils/decorators/admins.py +++ b/utils/decorators/admins.py @@ -2,7 +2,7 @@ from functools import wraps from typing import Callable from apps.admin.services import BotAdminService -from utils.apps.inject import inject +from utils.service.inject import inject def bot_admins_rights_check(func: Callable) -> Callable: diff --git a/utils/helpers.py b/utils/helpers.py index 21b56e80..610fefd7 100644 --- a/utils/helpers.py +++ b/utils/helpers.py @@ -7,9 +7,9 @@ import genshin import httpx from genshin import Client, types from httpx import UnsupportedProtocol +from service.cookies.services import CookiesService +from service.user.services import UserService -from apps.cookies.services import CookiesService -from apps.user.services import UserService from logger import Log from models.base import RegionEnum diff --git a/utils/apps/inject.py b/utils/service/inject.py similarity index 96% rename from utils/apps/inject.py rename to utils/service/inject.py index 4000ec67..7cec0810 100644 --- a/utils/apps/inject.py +++ b/utils/service/inject.py @@ -3,7 +3,7 @@ from functools import wraps from logger import Log from models.types import Func -from utils.apps.manager import ServiceDict +from utils.service.manager import ServiceDict def get_injections(func: Func): diff --git a/utils/apps/manager.py b/utils/service/manager.py similarity index 100% rename from utils/apps/manager.py rename to utils/service/manager.py