refactor(task): 重新组织 kotonebot.tasks 模块

This commit is contained in:
XcantloadX 2025-03-26 23:24:19 +08:00
parent 4460ee38c1
commit 044b1c2cc8
17 changed files with 49 additions and 50 deletions

View File

@ -252,8 +252,7 @@ def calc(image: MatLike, card_count: int):
from kotonebot.backend.debug.mock import MockDevice
from kotonebot.backend.context import device, init_context, manual_context, inject_context
from kotonebot.tasks.actions.in_purodyuusu import handle_recommended_card, skill_card_count
from kotonebot.backend.context import device, init_context, manual_context
from kotonebot.backend.util import Profiler
init_context()
mock = MockDevice()

View File

View File

@ -1,9 +1,9 @@
"""收取活动费"""
import logging
from . import R
from .common import conf
from .actions.scenes import at_home, goto_home
from .. import R
from ..common import conf
from ..actions.scenes import at_home, goto_home
from kotonebot import task, device, image, color
logger = logging.getLogger(__name__)

View File

@ -1,9 +1,9 @@
"""领取礼物(邮箱)"""
import logging
from . import R
from .common import conf
from .actions.scenes import at_home, goto_home
from .. import R
from ..common import conf
from ..actions.scenes import at_home, goto_home
from kotonebot import device, image, task, color, rect_expand, sleep
logger = logging.getLogger(__name__)

View File

@ -3,10 +3,10 @@ import logging
from typing import Literal
from datetime import timedelta
from . import R
from .common import conf
from .actions.loading import wait_loading_end
from .actions.scenes import at_home, goto_home
from .. import R
from ..common import conf
from ..actions.loading import wait_loading_end
from ..actions.scenes import at_home, goto_home
from kotonebot import task, device, image, action, ocr, contains, cropped, rect_expand, color, sleep, regex
logger = logging.getLogger(__name__)

View File

@ -1,11 +1,11 @@
"""扭蛋机,支持任意次数的任意扭蛋类型"""
import logging
from kotonebot import task, action, device, image, sleep, Interval
from .. import R
from ..common import conf
from ..actions.scenes import at_home, goto_home
from kotonebot.backend.image import TemplateMatchResult
from . import R
from .common import conf
from .actions.scenes import at_home, goto_home
from kotonebot import task, action, device, image, sleep, Interval
logger = logging.getLogger(__name__)

View File

@ -1,10 +1,10 @@
"""领取社团奖励,并尽可能地给其他人送礼物"""
import logging
from . import R
from .common import conf
from .actions.scenes import at_home, goto_home
from kotonebot.tasks.game_ui import toolbar_menu
from .. import R
from ..common import conf
from ..game_ui import toolbar_menu
from ..actions.scenes import at_home, goto_home
from kotonebot import task, device, image, sleep, ocr
logger = logging.getLogger(__name__)

View File

@ -2,11 +2,11 @@
import logging
from gettext import gettext as _
from . import R
from .common import conf
from kotonebot.tasks.game_ui import WhiteFilter
from .actions.scenes import at_home, goto_home
from .actions.loading import wait_loading_end
from .. import R
from ..common import conf
from ..game_ui import WhiteFilter
from ..actions.scenes import at_home, goto_home
from ..actions.loading import wait_loading_end
from kotonebot import device, image, ocr, color, action, task, user, rect_expand, sleep, contains
logger = logging.getLogger(__name__)

View File

@ -1,10 +1,10 @@
"""领取任务奖励"""
import logging
from . import R
from .common import conf, Priority
from .actions.loading import wait_loading_end
from .actions.scenes import at_home, goto_home
from .. import R
from ..common import conf, Priority
from ..actions.loading import wait_loading_end
from ..actions.scenes import at_home, goto_home
from kotonebot import device, image, color, task, action, rect_expand, sleep
logger = logging.getLogger(__name__)

View File

@ -3,12 +3,12 @@ import logging
from typing import Optional
from typing_extensions import deprecated
from . import R
from .common import conf, DailyMoneyShopItems
from .. import R
from ..common import conf, DailyMoneyShopItems
from kotonebot.util import cropped
from kotonebot import task, device, image, ocr, action, sleep
from kotonebot.backend.dispatch import DispatcherContext, SimpleDispatcher, dispatcher
from .actions.scenes import goto_home, goto_shop, at_daily_shop
from ..actions.scenes import goto_home, goto_shop, at_daily_shop
logger = logging.getLogger(__name__)

View File

@ -1,10 +1,10 @@
"""升级一张支援卡,优先升级低等级支援卡"""
import logging
from .. import R
from ..common import conf
from ..actions.scenes import at_home, goto_home
from kotonebot import task, device, image, sleep
from . import R
from .common import conf
from .actions.scenes import at_home, goto_home
logger = logging.getLogger(__name__)

View File

View File

@ -9,19 +9,19 @@ import numpy as np
from cv2.typing import MatLike
from .. import R
from . import loading
from .scenes import at_home
from ..actions.loading import loading
from ..actions.scenes import at_home
from ..util.trace import trace
from kotonebot.tasks.game_ui import WhiteFilter
from .commu import handle_unread_commu
from ..game_ui import WhiteFilter
from ..actions.commu import handle_unread_commu
from ..common import ProduceAction, RecommendCardDetectionMode, conf
from kotonebot.errors import UnrecoverableError
from kotonebot.backend.context.context import use_screenshot
from .common import until_acquisition_clear, acquisitions, commut_event
from ..produce.common import until_acquisition_clear, acquisitions, commut_event
from kotonebot.util import Countdown, Interval, crop, cropped
from kotonebot.backend.dispatch import DispatcherContext, SimpleDispatcher
from kotonebot import ocr, device, contains, image, regex, action, sleep, color, Rect, wait
from .non_lesson_actions import (
from ..produce.non_lesson_actions import (
enter_allowance, allowance_available,
study_available, enter_study,
is_rest_available, rest,

View File

@ -5,11 +5,11 @@
"""
from logging import getLogger
from kotonebot.tasks.common import conf
from .. import R
from .common import acquisitions
from kotonebot.tasks.game_ui.commu_event_buttons import CommuEventButtonUI
from ..common import conf
from ..produce.common import acquisitions
from ..game_ui.commu_event_buttons import CommuEventButtonUI
from kotonebot.util import Interval
from kotonebot.errors import UnrecoverableError
from kotonebot import device, image, action, sleep
@ -67,7 +67,7 @@ def enter_study():
elif target == 'vocal':
logger.debug("Clicking on lesson vocal.")
device.double_click(image.expect(R.InPurodyuusu.TextSelfStudyVocal))
from .in_purodyuusu import until_practice_scene, practice
from ..produce.in_purodyuusu import until_practice_scene, practice
logger.info("Entering practice scene.")
until_practice_scene()
logger.info("Executing practice.")

View File

@ -7,11 +7,11 @@ from kotonebot.ui import user
from kotonebot.util import Countdown, Interval
from kotonebot.backend.dispatch import SimpleDispatcher
from . import R
from .common import conf, PIdol
from .actions.scenes import at_home, goto_home
from .actions.in_purodyuusu import hajime_pro, hajime_regular, resume_regular_produce
from kotonebot import device, image, ocr, task, action, sleep, equals, contains
from .. import R
from ..common import conf, PIdol
from ..actions.scenes import at_home, goto_home
from ..produce.in_purodyuusu import hajime_pro, hajime_regular, resume_regular_produce
from kotonebot import device, image, ocr, task, action, sleep, contains
logger = logging.getLogger(__name__)