mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-16 17:45:12 +00:00
feat(momotalk): add a single tool page for momotalk,
remove its scheduler, and some minor improvements
This commit is contained in:
parent
02b8de6d18
commit
3cd8161afb
@ -377,6 +377,7 @@ pre.rich-traceback-code {
|
|||||||
#pywebio-scope-scheduler-bar,
|
#pywebio-scope-scheduler-bar,
|
||||||
#pywebio-scope-log-bar,
|
#pywebio-scope-log-bar,
|
||||||
#pywebio-scope-log,
|
#pywebio-scope-log,
|
||||||
|
#pywebio-scope-daemon-log-bar,
|
||||||
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin: 0.3125rem;
|
margin: 0.3125rem;
|
||||||
|
|||||||
@ -133,12 +133,13 @@ pre.rich-traceback-code {
|
|||||||
color: #c9d1d9;
|
color: #c9d1d9;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pywebio-scope-scheduler-bar,
|
|
||||||
#pywebio-scope-log-bar,
|
|
||||||
#pywebio-scope-log,
|
|
||||||
#pywebio-scope-running,
|
#pywebio-scope-running,
|
||||||
#pywebio-scope-pending,
|
#pywebio-scope-pending,
|
||||||
#pywebio-scope-waiting,
|
#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 {
|
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
||||||
background-color: #2f3136;
|
background-color: #2f3136;
|
||||||
border: 1px solid #21262d;
|
border: 1px solid #21262d;
|
||||||
|
|||||||
@ -133,12 +133,13 @@ pre.rich-traceback-code {
|
|||||||
border: 1px solid lightgrey;
|
border: 1px solid lightgrey;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pywebio-scope-scheduler-bar,
|
|
||||||
#pywebio-scope-log-bar,
|
|
||||||
#pywebio-scope-log,
|
|
||||||
#pywebio-scope-running,
|
#pywebio-scope-running,
|
||||||
#pywebio-scope-pending,
|
#pywebio-scope-pending,
|
||||||
#pywebio-scope-waiting,
|
#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 {
|
#pywebio-scope-daemon-overview #pywebio-scope-groups {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border: 1px solid lightgrey;
|
border: 1px solid lightgrey;
|
||||||
|
|||||||
@ -250,11 +250,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Momotalk": {
|
"Momotalk": {
|
||||||
"Scheduler": {
|
"Momotalk": {
|
||||||
"Enable": false,
|
"Enable": true
|
||||||
"NextRun": "2020-01-01 00:00:00",
|
|
||||||
"Command": "Momotalk",
|
|
||||||
"ServerUpdate": "04:00"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1062,28 +1062,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Momotalk": {
|
"Momotalk": {
|
||||||
"Scheduler": {
|
"Momotalk": {
|
||||||
"Enable": {
|
"Enable": {
|
||||||
"type": "checkbox",
|
"type": "checkbox",
|
||||||
"value": false,
|
"value": true,
|
||||||
"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",
|
|
||||||
"display": "hide"
|
"display": "hide"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -267,3 +267,10 @@ ItemStorage:
|
|||||||
stored: StoredTacticalChallengeTicket
|
stored: StoredTacticalChallengeTicket
|
||||||
order: 6
|
order: 6
|
||||||
color: "#7ac8e5"
|
color: "#7ac8e5"
|
||||||
|
|
||||||
|
# ==================== Momotalk ====================
|
||||||
|
|
||||||
|
Momotalk:
|
||||||
|
Enable:
|
||||||
|
value: true
|
||||||
|
display: hide
|
||||||
@ -33,7 +33,13 @@
|
|||||||
"tasks": [
|
"tasks": [
|
||||||
"Circle",
|
"Circle",
|
||||||
"Task",
|
"Task",
|
||||||
"Mail",
|
"Mail"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Tool": {
|
||||||
|
"menu": "collapse",
|
||||||
|
"page": "tool",
|
||||||
|
"tasks": [
|
||||||
"Momotalk"
|
"Momotalk"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,5 +80,12 @@ Reward:
|
|||||||
- Scheduler
|
- Scheduler
|
||||||
Mail:
|
Mail:
|
||||||
- Scheduler
|
- Scheduler
|
||||||
|
|
||||||
|
# ==================== Tool ====================
|
||||||
|
|
||||||
|
Tool:
|
||||||
|
menu: 'collapse'
|
||||||
|
page: 'tool'
|
||||||
|
tasks:
|
||||||
Momotalk:
|
Momotalk:
|
||||||
- Scheduler
|
- Momotalk
|
||||||
@ -166,3 +166,6 @@ class GeneratedConfig:
|
|||||||
ItemStorage_BountyTicket = {}
|
ItemStorage_BountyTicket = {}
|
||||||
ItemStorage_ScrimmageTicket = {}
|
ItemStorage_ScrimmageTicket = {}
|
||||||
ItemStorage_TacticalChallengeTicket = {}
|
ItemStorage_TacticalChallengeTicket = {}
|
||||||
|
|
||||||
|
# Group `Momotalk`
|
||||||
|
Momotalk_Enable = True
|
||||||
|
|||||||
@ -15,6 +15,10 @@
|
|||||||
"Reward": {
|
"Reward": {
|
||||||
"name": "Reward",
|
"name": "Reward",
|
||||||
"help": ""
|
"help": ""
|
||||||
|
},
|
||||||
|
"Tool": {
|
||||||
|
"name": "Tools",
|
||||||
|
"help": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Task": {
|
"Task": {
|
||||||
@ -849,6 +853,16 @@
|
|||||||
"help": ""
|
"help": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Momotalk": {
|
||||||
|
"_info": {
|
||||||
|
"name": "Momotalk",
|
||||||
|
"help": "Tools need to stop the scheduler and then run independently"
|
||||||
|
},
|
||||||
|
"Enable": {
|
||||||
|
"name": "",
|
||||||
|
"help": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
"Gui": {
|
"Gui": {
|
||||||
"Aside": {
|
"Aside": {
|
||||||
"Install": "Install",
|
"Install": "Install",
|
||||||
|
|||||||
@ -15,6 +15,10 @@
|
|||||||
"Reward": {
|
"Reward": {
|
||||||
"name": "收菜",
|
"name": "收菜",
|
||||||
"help": ""
|
"help": ""
|
||||||
|
},
|
||||||
|
"Tool": {
|
||||||
|
"name": "工具",
|
||||||
|
"help": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Task": {
|
"Task": {
|
||||||
@ -849,6 +853,16 @@
|
|||||||
"help": ""
|
"help": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Momotalk": {
|
||||||
|
"_info": {
|
||||||
|
"name": "Momotalk",
|
||||||
|
"help": "工具需要停止调度器再单独运行"
|
||||||
|
},
|
||||||
|
"Enable": {
|
||||||
|
"name": "",
|
||||||
|
"help": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
"Gui": {
|
"Gui": {
|
||||||
"Aside": {
|
"Aside": {
|
||||||
"Install": "安装",
|
"Install": "安装",
|
||||||
|
|||||||
@ -611,7 +611,7 @@ class AlasGUI(Frame):
|
|||||||
[
|
[
|
||||||
put_scope("scheduler-bar"),
|
put_scope("scheduler-bar"),
|
||||||
put_scope("groups"),
|
put_scope("groups"),
|
||||||
put_scope("log-bar"),
|
put_scope("daemon-log-bar"),
|
||||||
put_scope("log", [put_html("")]),
|
put_scope("log", [put_html("")]),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -625,7 +625,7 @@ class AlasGUI(Frame):
|
|||||||
[
|
[
|
||||||
put_scope(
|
put_scope(
|
||||||
"_daemon_upper",
|
"_daemon_upper",
|
||||||
[put_scope("scheduler-bar"), put_scope("log-bar")],
|
[put_scope("scheduler-bar"), put_scope("daemon-log-bar")],
|
||||||
),
|
),
|
||||||
put_scope("groups"),
|
put_scope("groups"),
|
||||||
put_scope("log", [put_html("")]),
|
put_scope("log", [put_html("")]),
|
||||||
@ -654,16 +654,17 @@ class AlasGUI(Frame):
|
|||||||
scope="scheduler_btn",
|
scope="scheduler_btn",
|
||||||
)
|
)
|
||||||
|
|
||||||
with use_scope("log-bar"):
|
with use_scope("daemon-log-bar"):
|
||||||
put_text(t("Gui.Overview.Log")).style(
|
with use_scope("log-title"):
|
||||||
"font-size: 1.25rem; margin: auto .5rem auto;"
|
put_text(t("Gui.Overview.Log")).style(
|
||||||
)
|
"font-size: 1.25rem; margin: auto .5rem auto;"
|
||||||
put_scope(
|
)
|
||||||
"log-bar-btns",
|
put_scope(
|
||||||
[
|
"log-bar-btns",
|
||||||
put_scope("log_scroll_btn"),
|
[
|
||||||
],
|
put_scope("log_scroll_btn"),
|
||||||
)
|
],
|
||||||
|
)
|
||||||
|
|
||||||
switch_log_scroll = BinarySwitchButton(
|
switch_log_scroll = BinarySwitchButton(
|
||||||
label_on=t("Gui.Button.ScrollON"),
|
label_on=t("Gui.Button.ScrollON"),
|
||||||
|
|||||||
@ -6,11 +6,12 @@ from multiprocessing import Process
|
|||||||
from typing import Dict, List, Union
|
from typing import Dict, List, Union
|
||||||
|
|
||||||
from filelock import FileLock
|
from filelock import FileLock
|
||||||
|
from rich.console import Console, ConsoleRenderable
|
||||||
|
|
||||||
from module.config.utils import filepath_config
|
from module.config.utils import filepath_config
|
||||||
from module.logger import logger, set_file_logger, set_func_logger
|
from module.logger import logger, set_file_logger, set_func_logger
|
||||||
from module.webui.fake import get_config_mod, mod_instance
|
from module.webui.fake import get_config_mod, mod_instance
|
||||||
from module.webui.setting import State
|
from module.webui.setting import State
|
||||||
from rich.console import Console, ConsoleRenderable
|
|
||||||
|
|
||||||
|
|
||||||
class ProcessManager:
|
class ProcessManager:
|
||||||
@ -147,6 +148,10 @@ class ProcessManager:
|
|||||||
if e is not None:
|
if e is not None:
|
||||||
AzurLaneAutoScript.stop_event = e
|
AzurLaneAutoScript.stop_event = e
|
||||||
ArisuAutoSweeper(config_name=config_name).loop()
|
ArisuAutoSweeper(config_name=config_name).loop()
|
||||||
|
elif func == "Momotalk":
|
||||||
|
from tasks.momotalk.momotalk import MomoTalk
|
||||||
|
|
||||||
|
MomoTalk(config=config_name, task="Momotalk").run()
|
||||||
else:
|
else:
|
||||||
logger.critical(f"No function matched: {func}")
|
logger.critical(f"No function matched: {func}")
|
||||||
logger.info(f"[{config_name}] exited. Reason: Finish\n")
|
logger.info(f"[{config_name}] exited. Reason: Finish\n")
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
import cv2
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from module.base.base import ModuleBase
|
|
||||||
from module.base.timer import Timer
|
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.logger import logger
|
||||||
from module.ui.switch import Switch
|
from module.ui.switch import Switch
|
||||||
from tasks.base.page import page_main, page_momo_talk
|
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
|
"""Required for template matching as reply and story
|
||||||
button can be found in different locations"""
|
button can be found in different locations"""
|
||||||
REPLY_TEMPLATE = REPLY.matched_button.image
|
REPLY_TEMPLATE = REPLY
|
||||||
STORY_TEMPLATE = STORY.matched_button.image
|
STORY_TEMPLATE = STORY
|
||||||
CHATTING_TEMPLATE = CHATTING.matched_button.image
|
CHATTING_TEMPLATE = CHATTING
|
||||||
|
|
||||||
|
|
||||||
class MomoTalkUI(UI):
|
class MomoTalkUI(UI):
|
||||||
def __init__(self, config, device):
|
swipe_vector_range = (0.65, 0.85)
|
||||||
super().__init__(config, device)
|
list = CHAT_AREA
|
||||||
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)
|
|
||||||
|
|
||||||
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:
|
Args:
|
||||||
direction: up, down
|
direction: up, down
|
||||||
main:
|
|
||||||
vector_range (tuple[float, float]):
|
vector_range (tuple[float, float]):
|
||||||
reverse (bool):
|
reverse (bool):
|
||||||
"""
|
"""
|
||||||
@ -58,7 +52,7 @@ class MomoTalkUI(UI):
|
|||||||
|
|
||||||
if reverse:
|
if reverse:
|
||||||
vector = (-vector[0], -vector[1])
|
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):
|
def select_then_disappear(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper):
|
||||||
timer = Timer(5, 10).start()
|
timer = Timer(5, 10).start()
|
||||||
@ -83,24 +77,19 @@ class MomoTalkUI(UI):
|
|||||||
|
|
||||||
return True
|
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.
|
Find the all the locations of the template adding an offset if specified and click them.
|
||||||
If after filter, no coords then swipe.
|
If after filter, no coords then swipe.
|
||||||
"""
|
"""
|
||||||
image = self.device.screenshot()
|
template.load_search(self.list.area)
|
||||||
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
|
template.matched_button._button_offset = offset
|
||||||
threshold = 0.8
|
seen = template.match_multi_template(self.device.image, similarity=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)
|
|
||||||
if seen:
|
if seen:
|
||||||
if y_add != 0:
|
if any(offset):
|
||||||
seen = filter(lambda x: point_in_area(x, CHAT_AREA.area), seen)
|
for button in seen:
|
||||||
[self.click_coords(coords[0], coords[1]) for coords in seen]
|
self.device.click(button)
|
||||||
self.swipe_page("down", self)
|
self.swipe_page("down")
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -157,10 +146,10 @@ class MomoTalkUI(UI):
|
|||||||
return True
|
return True
|
||||||
elif self.click_all(CHATTING_TEMPLATE):
|
elif self.click_all(CHATTING_TEMPLATE):
|
||||||
timer.reset()
|
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")
|
logger.info("Clicked on reply")
|
||||||
timer.reset()
|
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")
|
logger.info("Clicked on story")
|
||||||
timer.reset()
|
timer.reset()
|
||||||
elif timer.reached():
|
elif timer.reached():
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user