mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-18 15:15:32 +00:00
fix: momotalk
This commit is contained in:
parent
9bf970e5fb
commit
d7722c044e
BIN
assets/en/momotalk/CHATTING.png
Normal file
BIN
assets/en/momotalk/CHATTING.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
@ -14,6 +14,17 @@ BEGIN_STORY = ButtonWrapper(
|
|||||||
button=(796, 540, 1059, 591),
|
button=(796, 540, 1059, 591),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
CHATTING = ButtonWrapper(
|
||||||
|
name='CHATTING',
|
||||||
|
jp=None,
|
||||||
|
en=Button(
|
||||||
|
file='./assets/en/momotalk/CHATTING.png',
|
||||||
|
area=(774, 563, 821, 585),
|
||||||
|
search=(754, 543, 841, 605),
|
||||||
|
color=(89, 102, 121),
|
||||||
|
button=(774, 563, 821, 585),
|
||||||
|
),
|
||||||
|
)
|
||||||
CHAT_AREA = ButtonWrapper(
|
CHAT_AREA = ButtonWrapper(
|
||||||
name='CHAT_AREA',
|
name='CHAT_AREA',
|
||||||
jp=None,
|
jp=None,
|
||||||
|
|||||||
@ -26,7 +26,7 @@ SWITCH_SORT.add_state("descending", SORT_DESCENDING)
|
|||||||
button can be found in different locations"""
|
button can be found in different locations"""
|
||||||
REPLY_TEMPLATE = REPLY.matched_button.image
|
REPLY_TEMPLATE = REPLY.matched_button.image
|
||||||
STORY_TEMPLATE = STORY.matched_button.image
|
STORY_TEMPLATE = STORY.matched_button.image
|
||||||
|
CHATTING_TEMPLATE = CHATTING.matched_button.image
|
||||||
|
|
||||||
class MomoTalkUI(UI):
|
class MomoTalkUI(UI):
|
||||||
def __init__(self, config, device):
|
def __init__(self, config, device):
|
||||||
@ -68,18 +68,17 @@ class MomoTalkUI(UI):
|
|||||||
if timer.reached():
|
if timer.reached():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def select_then_disappear(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper, force_select=False):
|
def select_then_disappear(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper):
|
||||||
timer = Timer(5, 10).start()
|
timer = Timer(5, 10).start()
|
||||||
while 1:
|
while 1:
|
||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
if force_select or self.appear(dest_enter):
|
self.click_with_interval(dest_enter, interval=1)
|
||||||
self.click_with_interval(dest_enter, interval=1)
|
|
||||||
if not self.appear(dest_check):
|
if not self.appear(dest_check):
|
||||||
return True
|
return True
|
||||||
if timer.reached():
|
if timer.reached():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def set_switch(self, switch):
|
def set_switch(self, switch, state='on'):
|
||||||
"""
|
"""
|
||||||
Set switch to on. However, unsure why is inaccurate in momotalk.
|
Set switch to on. However, unsure why is inaccurate in momotalk.
|
||||||
Returns:
|
Returns:
|
||||||
@ -88,7 +87,7 @@ class MomoTalkUI(UI):
|
|||||||
if not switch.appear(main=self):
|
if not switch.appear(main=self):
|
||||||
logger.info(f'{switch.name} not found')
|
logger.info(f'{switch.name} not found')
|
||||||
return False
|
return False
|
||||||
switch.set('on', main=self)
|
switch.set(state, main=self)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -108,9 +107,10 @@ class MomoTalkUI(UI):
|
|||||||
center_pt = (int(pt[0] + template.shape[1] / 2 + x_add), int(pt[1] + template.shape[0] / 2 + y_add))
|
center_pt = (int(pt[0] + template.shape[1] / 2 + x_add), int(pt[1] + template.shape[0] / 2 + y_add))
|
||||||
seen.add(center_pt)
|
seen.add(center_pt)
|
||||||
if seen:
|
if seen:
|
||||||
seen = filter(lambda x: point_in_area(x, CHAT_AREA.area), seen)
|
if y_add != 0:
|
||||||
[click_coords(coords[0], coords[1]) for coords in seen]
|
seen = filter(lambda x: point_in_area(x, CHAT_AREA.area), seen)
|
||||||
self.swipe_page("down", self)
|
[click_coords(coords[0], coords[1]) for coords in seen]
|
||||||
|
self.swipe_page("down", self)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -132,18 +132,22 @@ class MomoTalkUI(UI):
|
|||||||
"""
|
"""
|
||||||
Switch from newest to unread and sort the messages in descending order
|
Switch from newest to unread and sort the messages in descending order
|
||||||
"""
|
"""
|
||||||
logger.info("Sorting messages...")
|
while 1:
|
||||||
steps = [UNREAD, CONFIRM_SORT, UNREAD_OFF, UNREAD_ON]
|
self.device.screenshot()
|
||||||
for i in range(len(steps)-2):
|
if self.set_switch(SWITCH_UNREAD):
|
||||||
self.select_then_check(steps[i], steps[i+1], similarity=0.95)
|
self.click_with_interval(CONFIRM_SORT, interval=2)
|
||||||
return not self.appear(CONFIRM_SORT) and self.appear(UNREAD) and self.appear(SORT_ON)
|
continue
|
||||||
|
if self.appear(UNREAD, similarity=0.95):
|
||||||
|
break
|
||||||
|
self.click_with_interval(UNREAD, interval=2)
|
||||||
|
return self.set_switch(SWITCH_SORT, "descending")
|
||||||
|
|
||||||
def check_first_student(self):
|
def check_first_student(self):
|
||||||
"""
|
"""
|
||||||
If the first student has a red notification return True and start chat.
|
If the first student has a red notification return True and start chat.
|
||||||
Otherwise it means no students are available for interaction.
|
Otherwise it means no students are available for interaction.
|
||||||
"""
|
"""
|
||||||
if self.match_color(FIRST_UNREAD, threshold=80) and self.select_then_disappear(FIRST_UNREAD, SELECT_STUDENT, force_select=True):
|
if self.match_color(FIRST_UNREAD, threshold=80) and self.select_then_disappear(FIRST_UNREAD, SELECT_STUDENT):
|
||||||
return True
|
return True
|
||||||
logger.warning("No students available for interaction")
|
logger.warning("No students available for interaction")
|
||||||
return False
|
return False
|
||||||
@ -154,24 +158,23 @@ class MomoTalkUI(UI):
|
|||||||
check if a reply or story button is found and click them.
|
check if a reply or story button is found and click them.
|
||||||
If the begin story button is found skip story.
|
If the begin story button is found skip story.
|
||||||
"""
|
"""
|
||||||
|
timer = Timer(8, 5).start()
|
||||||
logger.info("Chatting with student...")
|
logger.info("Chatting with student...")
|
||||||
stability_counter = 0
|
|
||||||
while 1:
|
while 1:
|
||||||
self.wait_until_stable(CHAT_AREA, timer=Timer(10, 10))
|
self.device.screenshot()
|
||||||
if self.appear(BEGIN_STORY):
|
if self.appear(BEGIN_STORY):
|
||||||
logger.info("Begin Story detected")
|
logger.info("Begin Story detected")
|
||||||
return True
|
return True
|
||||||
if self.click_all(REPLY_TEMPLATE, y_add=62):
|
elif self.click_all(CHATTING_TEMPLATE):
|
||||||
|
timer.reset()
|
||||||
|
elif self.click_all(REPLY_TEMPLATE, y_add=62):
|
||||||
logger.info("Clicked on reply")
|
logger.info("Clicked on reply")
|
||||||
stability_counter = 0
|
timer.reset()
|
||||||
continue
|
elif self.click_all(STORY_TEMPLATE, y_add=62):
|
||||||
if self.click_all(STORY_TEMPLATE, y_add=62):
|
|
||||||
logger.info("Clicked on story")
|
logger.info("Clicked on story")
|
||||||
stability_counter = 0
|
timer.reset()
|
||||||
continue
|
elif timer.reached():
|
||||||
logger.info("No new message detected")
|
logger.info("No new message detected")
|
||||||
stability_counter += 1
|
|
||||||
if stability_counter > 3:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def skip_story(self):
|
def skip_story(self):
|
||||||
@ -180,11 +183,17 @@ class MomoTalkUI(UI):
|
|||||||
button is clicked and disappears
|
button is clicked and disappears
|
||||||
"""
|
"""
|
||||||
logger.info("Attempting to skip story...")
|
logger.info("Attempting to skip story...")
|
||||||
steps = [BEGIN_STORY, MENU, SKIP]
|
steps = [CONFIRM_SKIP, SKIP, MENU, BEGIN_STORY]
|
||||||
for step in steps:
|
timer = Timer(1).start()
|
||||||
self.appear_then_click(step)
|
while 1:
|
||||||
if self.appear_then_click(CONFIRM_SKIP) and not self.appear(CONFIRM_SKIP, interval=5):
|
self.device.screenshot()
|
||||||
logger.info("Skipped story successfully")
|
if self.handle_reward():
|
||||||
return True
|
logger.info("Skipped story successfully")
|
||||||
return False
|
return True
|
||||||
|
for step in steps:
|
||||||
|
if self.appear_then_click(step):
|
||||||
|
while not timer.reached_and_reset():
|
||||||
|
pass
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user