1
0
mirror of https://github.com/TheFunny/ArisuAutoSweeper synced 2025-12-16 11:15:13 +00:00

feat(momotalk): add a single tool page for momotalk,

remove its scheduler,
and some minor improvements
This commit is contained in:
YoursFunny 2025-10-13 11:39:43 +08:00
parent 02b8de6d18
commit 3cd8161afb
Signed by: YoursFunny
GPG Key ID: 207EDC3CD5B40F9C
14 changed files with 103 additions and 75 deletions

View File

@ -377,6 +377,7 @@ pre.rich-traceback-code {
#pywebio-scope-scheduler-bar,
#pywebio-scope-log-bar,
#pywebio-scope-log,
#pywebio-scope-daemon-log-bar,
#pywebio-scope-daemon-overview #pywebio-scope-groups {
font-weight: 500;
margin: 0.3125rem;

View File

@ -133,12 +133,13 @@ pre.rich-traceback-code {
color: #c9d1d9;
}
#pywebio-scope-scheduler-bar,
#pywebio-scope-log-bar,
#pywebio-scope-log,
#pywebio-scope-running,
#pywebio-scope-pending,
#pywebio-scope-waiting,
#pywebio-scope-scheduler-bar,
#pywebio-scope-log-bar,
#pywebio-scope-log,
#pywebio-scope-daemon-log-bar,
#pywebio-scope-daemon-overview #pywebio-scope-groups {
background-color: #2f3136;
border: 1px solid #21262d;

View File

@ -133,12 +133,13 @@ pre.rich-traceback-code {
border: 1px solid lightgrey;
}
#pywebio-scope-scheduler-bar,
#pywebio-scope-log-bar,
#pywebio-scope-log,
#pywebio-scope-running,
#pywebio-scope-pending,
#pywebio-scope-waiting,
#pywebio-scope-scheduler-bar,
#pywebio-scope-log-bar,
#pywebio-scope-log,
#pywebio-scope-daemon-log-bar,
#pywebio-scope-daemon-overview #pywebio-scope-groups {
background-color: white;
border: 1px solid lightgrey;

View File

@ -250,11 +250,8 @@
}
},
"Momotalk": {
"Scheduler": {
"Enable": false,
"NextRun": "2020-01-01 00:00:00",
"Command": "Momotalk",
"ServerUpdate": "04:00"
"Momotalk": {
"Enable": true
}
}
}

View File

@ -1062,28 +1062,10 @@
}
},
"Momotalk": {
"Scheduler": {
"Momotalk": {
"Enable": {
"type": "checkbox",
"value": false,
"option": [
true,
false
]
},
"NextRun": {
"type": "datetime",
"value": "2020-01-01 00:00:00",
"validate": "datetime"
},
"Command": {
"type": "input",
"value": "Momotalk",
"display": "hide"
},
"ServerUpdate": {
"type": "input",
"value": "04:00",
"value": true,
"display": "hide"
}
}

View File

@ -267,3 +267,10 @@ ItemStorage:
stored: StoredTacticalChallengeTicket
order: 6
color: "#7ac8e5"
# ==================== Momotalk ====================
Momotalk:
Enable:
value: true
display: hide

View File

@ -33,7 +33,13 @@
"tasks": [
"Circle",
"Task",
"Mail",
"Mail"
]
},
"Tool": {
"menu": "collapse",
"page": "tool",
"tasks": [
"Momotalk"
]
}

View File

@ -80,5 +80,12 @@ Reward:
- Scheduler
Mail:
- Scheduler
# ==================== Tool ====================
Tool:
menu: 'collapse'
page: 'tool'
tasks:
Momotalk:
- Scheduler
- Momotalk

View File

@ -166,3 +166,6 @@ class GeneratedConfig:
ItemStorage_BountyTicket = {}
ItemStorage_ScrimmageTicket = {}
ItemStorage_TacticalChallengeTicket = {}
# Group `Momotalk`
Momotalk_Enable = True

View File

@ -15,6 +15,10 @@
"Reward": {
"name": "Reward",
"help": ""
},
"Tool": {
"name": "Tools",
"help": ""
}
},
"Task": {
@ -849,6 +853,16 @@
"help": ""
}
},
"Momotalk": {
"_info": {
"name": "Momotalk",
"help": "Tools need to stop the scheduler and then run independently"
},
"Enable": {
"name": "",
"help": ""
}
},
"Gui": {
"Aside": {
"Install": "Install",

View File

@ -15,6 +15,10 @@
"Reward": {
"name": "收菜",
"help": ""
},
"Tool": {
"name": "工具",
"help": ""
}
},
"Task": {
@ -849,6 +853,16 @@
"help": ""
}
},
"Momotalk": {
"_info": {
"name": "Momotalk",
"help": "工具需要停止调度器再单独运行"
},
"Enable": {
"name": "",
"help": ""
}
},
"Gui": {
"Aside": {
"Install": "安装",

View File

@ -611,7 +611,7 @@ class AlasGUI(Frame):
[
put_scope("scheduler-bar"),
put_scope("groups"),
put_scope("log-bar"),
put_scope("daemon-log-bar"),
put_scope("log", [put_html("")]),
],
)
@ -625,7 +625,7 @@ class AlasGUI(Frame):
[
put_scope(
"_daemon_upper",
[put_scope("scheduler-bar"), put_scope("log-bar")],
[put_scope("scheduler-bar"), put_scope("daemon-log-bar")],
),
put_scope("groups"),
put_scope("log", [put_html("")]),
@ -654,16 +654,17 @@ class AlasGUI(Frame):
scope="scheduler_btn",
)
with use_scope("log-bar"):
put_text(t("Gui.Overview.Log")).style(
"font-size: 1.25rem; margin: auto .5rem auto;"
)
put_scope(
"log-bar-btns",
[
put_scope("log_scroll_btn"),
],
)
with use_scope("daemon-log-bar"):
with use_scope("log-title"):
put_text(t("Gui.Overview.Log")).style(
"font-size: 1.25rem; margin: auto .5rem auto;"
)
put_scope(
"log-bar-btns",
[
put_scope("log_scroll_btn"),
],
)
switch_log_scroll = BinarySwitchButton(
label_on=t("Gui.Button.ScrollON"),

View File

@ -6,11 +6,12 @@ from multiprocessing import Process
from typing import Dict, List, Union
from filelock import FileLock
from rich.console import Console, ConsoleRenderable
from module.config.utils import filepath_config
from module.logger import logger, set_file_logger, set_func_logger
from module.webui.fake import get_config_mod, mod_instance
from module.webui.setting import State
from rich.console import Console, ConsoleRenderable
class ProcessManager:
@ -147,6 +148,10 @@ class ProcessManager:
if e is not None:
AzurLaneAutoScript.stop_event = e
ArisuAutoSweeper(config_name=config_name).loop()
elif func == "Momotalk":
from tasks.momotalk.momotalk import MomoTalk
MomoTalk(config=config_name, task="Momotalk").run()
else:
logger.critical(f"No function matched: {func}")
logger.info(f"[{config_name}] exited. Reason: Finish\n")

View File

@ -1,9 +1,7 @@
import cv2
import numpy as np
from module.base.base import ModuleBase
from module.base.timer import Timer
from module.base.utils import point_in_area, area_size
from module.base.utils import area_size
from module.logger import logger
from module.ui.switch import Switch
from tasks.base.page import page_main, page_momo_talk
@ -24,23 +22,19 @@ SWITCH_SORT.add_state("descending", SORT_DESCENDING)
"""Required for template matching as reply and story
button can be found in different locations"""
REPLY_TEMPLATE = REPLY.matched_button.image
STORY_TEMPLATE = STORY.matched_button.image
CHATTING_TEMPLATE = CHATTING.matched_button.image
REPLY_TEMPLATE = REPLY
STORY_TEMPLATE = STORY
CHATTING_TEMPLATE = CHATTING
class MomoTalkUI(UI):
def __init__(self, config, device):
super().__init__(config, device)
self.swipe_vector_range = (0.65, 0.85)
self.list = CHAT_AREA
self.click_coords = self.device.click_methods.get(self.config.Emulator_ControlMethod, self.device.click_adb)
swipe_vector_range = (0.65, 0.85)
list = CHAT_AREA
def swipe_page(self, direction: str, main: ModuleBase, vector_range=None, reverse=False):
def swipe_page(self, direction: str, vector_range=None, reverse=False):
"""
Args:
direction: up, down
main:
vector_range (tuple[float, float]):
reverse (bool):
"""
@ -58,7 +52,7 @@ class MomoTalkUI(UI):
if reverse:
vector = (-vector[0], -vector[1])
main.device.swipe_vector(vector, self.list.button)
self.device.swipe_vector(vector, self.list.button)
def select_then_disappear(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper):
timer = Timer(5, 10).start()
@ -83,24 +77,19 @@ class MomoTalkUI(UI):
return True
def click_all(self, template, x_add=0, y_add=0):
def click_all(self, template: ButtonWrapper, offset: tuple[int, int] = (0, 0)) -> bool:
"""
Find the all the locations of the template adding an offset if specified and click them.
If after filter, no coords then swipe.
"""
image = self.device.screenshot()
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
threshold = 0.8
locations = np.where(result >= threshold)
seen = set()
for pt in zip(*locations[::-1]):
center_pt = (int(pt[0] + template.shape[1] / 2 + x_add), int(pt[1] + template.shape[0] / 2 + y_add))
seen.add(center_pt)
template.load_search(self.list.area)
template.matched_button._button_offset = offset
seen = template.match_multi_template(self.device.image, similarity=0.8)
if seen:
if y_add != 0:
seen = filter(lambda x: point_in_area(x, CHAT_AREA.area), seen)
[self.click_coords(coords[0], coords[1]) for coords in seen]
self.swipe_page("down", self)
if any(offset):
for button in seen:
self.device.click(button)
self.swipe_page("down")
return True
return False
@ -157,10 +146,10 @@ class MomoTalkUI(UI):
return True
elif self.click_all(CHATTING_TEMPLATE):
timer.reset()
elif self.click_all(REPLY_TEMPLATE, y_add=62):
elif self.click_all(REPLY_TEMPLATE, offset=(0, 62)):
logger.info("Clicked on reply")
timer.reset()
elif self.click_all(STORY_TEMPLATE, y_add=62):
elif self.click_all(STORY_TEMPLATE, offset=(0, 62)):
logger.info("Clicked on story")
timer.reset()
elif timer.reached():