feat: MAA完整功能上线
This commit is contained in:
@@ -23,11 +23,13 @@ __version__ = "5.0.0"
|
||||
__author__ = "DLmaster361 <DLmaster_361@163.com>"
|
||||
__license__ = "GPL-3.0 license"
|
||||
|
||||
from .broadcast import Broadcast
|
||||
from .config import Config, MaaConfig, GeneralConfig, MaaUserConfig
|
||||
from .timer import MainTimer
|
||||
from .task_manager import TaskManager
|
||||
|
||||
__all__ = [
|
||||
"Broadcast",
|
||||
"Config",
|
||||
"MaaConfig",
|
||||
"GeneralConfig",
|
||||
|
||||
51
app/core/broadcast.py
Normal file
51
app/core/broadcast.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# AUTO_MAA:A MAA Multi Account Management and Automation Tool
|
||||
# Copyright © 2024-2025 DLmaster361
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Contact: DLmaster_361@163.com
|
||||
|
||||
|
||||
import asyncio
|
||||
from copy import deepcopy
|
||||
from typing import Set
|
||||
|
||||
from app.utils import get_logger
|
||||
|
||||
|
||||
logger = get_logger("消息广播")
|
||||
|
||||
|
||||
class _Broadcast:
|
||||
|
||||
def __init__(self):
|
||||
self.__subscribers: Set[asyncio.Queue] = set()
|
||||
|
||||
async def subscribe(self, queue: asyncio.Queue):
|
||||
"""订阅者注册"""
|
||||
self.__subscribers.add(queue)
|
||||
|
||||
async def unsubscribe(self, queue: asyncio.Queue):
|
||||
"""取消订阅"""
|
||||
self.__subscribers.remove(queue)
|
||||
|
||||
async def put(self, item):
|
||||
"""向所有订阅者广播消息"""
|
||||
for subscriber in self.__subscribers:
|
||||
await subscriber.put(deepcopy(item))
|
||||
|
||||
|
||||
Broadcast = _Broadcast()
|
||||
@@ -593,10 +593,9 @@ class AppConfig(GlobalConfig):
|
||||
self.log_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
self.config_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
self.message_queue = asyncio.Queue()
|
||||
self.silence_dict: Dict[Path, datetime] = {}
|
||||
self.power_sign = "NoAction"
|
||||
self.if_ignore_silence = False
|
||||
self.if_ignore_silence: List[uuid.UUID] = []
|
||||
|
||||
self.ScriptConfig = MultipleConfig([MaaConfig, GeneralConfig])
|
||||
self.PlanConfig = MultipleConfig([MaaPlanConfig])
|
||||
|
||||
@@ -78,7 +78,9 @@ class _TaskManager:
|
||||
else:
|
||||
raise ValueError(f"The task corresponding to UID {uid} could not be found.")
|
||||
|
||||
if task_id in self.task_dict:
|
||||
if task_id in self.task_dict or (
|
||||
actual_id is not None and actual_id in self.task_dict
|
||||
):
|
||||
|
||||
raise RuntimeError(f"The task {task_id} is already running.")
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ class _MainTimer:
|
||||
|
||||
if (
|
||||
not Config.if_ignore_silence
|
||||
and await Config.get("Function", "IfSilence")
|
||||
and await Config.get("Function", "BossKey") != ""
|
||||
and Config.get("Function", "IfSilence")
|
||||
and Config.get("Function", "BossKey") != ""
|
||||
):
|
||||
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user