base_task.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. from time import sleep, time
  5. import random
  6. from datetime import datetime, timedelta
  7. from module.atom.animate import RuleAnimate
  8. from module.atom.click import RuleClick
  9. from module.atom.gif import RuleGif
  10. from module.atom.image import RuleImage
  11. from module.atom.list import RuleList
  12. from module.atom.long_click import RuleLongClick
  13. from module.atom.ocr import RuleOcr
  14. from module.atom.swipe import RuleSwipe
  15. from module.base.timer import Timer
  16. from module.config.config import Config
  17. from module.device.device import Device
  18. from module.exception import ScriptError
  19. from module.logger import logger
  20. from module.ocr.base_ocr import OcrMode
  21. from tasks.Component.Costume.costume_base import CostumeBase
  22. from tasks.Component.config_base import Time
  23. from tasks.GlobalGame.assets import GlobalGameAssets
  24. from tasks.GlobalGame.config_emergency import FriendInvitation
  25. from typing import Union
  26. class BaseTask(GlobalGameAssets, CostumeBase):
  27. config: Config = None
  28. device: Device = None
  29. folder: str
  30. name: str
  31. stage: str
  32. limit_time: timedelta = None # 限制运行的时间,是软时间,不是硬时间
  33. limit_count: int = None # 限制运行的次数
  34. current_count: int = None # 当前运行的次数
  35. def __init__(self, config: Config, device: Device) -> None:
  36. """
  37. :rtype: object
  38. """
  39. self.config = config
  40. self.device = device
  41. self.interval_timer = {} # 这个是用来记录每个匹配的运行间隔的,用于控制运行频率
  42. self.animates = {} # 保存缓存
  43. self.start_time = datetime.now() # 启动的时间
  44. self.check_costume(self.config.global_game.costume_config)
  45. # self.friend_timer = None # 这个是用来记录勾协的时间的
  46. # if self.config.global_game.emergency.invitation_detect_interval:
  47. # self.interval_time = self.config.global_game.emergency.invitation_detect_interval
  48. # self.friend_timer = Timer(self.interval_time)
  49. # self.friend_timer.start()
  50. # 战斗次数相关
  51. self.current_count = 0 # 战斗次数
  52. def _burst(self) -> bool:
  53. """
  54. 游戏界面突发异常检测
  55. :return: 没有出现返回False, 其他True
  56. """
  57. image = self.device.image
  58. appear_invitation = self.appear(self.I_G_ACCEPT)
  59. if not appear_invitation:
  60. return False
  61. logger.info('Invitation appearing')
  62. invite_type = self.config.global_game.emergency.friend_invitation
  63. detect_record = self.device.detect_record
  64. match invite_type:
  65. case FriendInvitation.ACCEPT:
  66. logger.info(f"Accept friend invitation")
  67. click_button = self.I_G_ACCEPT
  68. case FriendInvitation.REJECT:
  69. logger.info(f"Reject friend invitation")
  70. click_button = self.I_G_REJECT
  71. case FriendInvitation.ONLY_JADE:
  72. # 勾协
  73. logger.info(f"Only accept jade invitation")
  74. if self.appear(self.I_G_JADE):
  75. click_button = self.I_G_ACCEPT
  76. else:
  77. click_button = self.I_G_IGNORE
  78. case FriendInvitation.JADE_AND_FOOD:
  79. # 如果是接受勾协和粮协
  80. logger.info(f"Accept jade and food invitation")
  81. if self.appear(self.I_G_JADE) or self.appear(self.I_G_CAT_FOOD) or self.appear(self.I_G_DOG_FOOD):
  82. click_button = self.I_G_ACCEPT
  83. else:
  84. click_button = self.I_G_IGNORE
  85. case FriendInvitation.IGNORE:
  86. # 如果是忽略
  87. logger.info(f"Ignore friend invitation")
  88. click_button = self.I_G_IGNORE
  89. case _:
  90. raise ScriptError(f'Unknown friend invitation type: {invite_type}')
  91. if not click_button:
  92. raise ScriptError(f'Unknown click button type: {invite_type}')
  93. while 1:
  94. self.device.screenshot()
  95. if not self.appear(target=click_button):
  96. logger.info('Deal with invitation done')
  97. break
  98. if self.appear_then_click(click_button, interval=0.8):
  99. continue
  100. # 有的时候长战斗 点击后会取消战斗状态
  101. self.device.detect_record = detect_record
  102. # 如果接受邀请则立即执行悬赏任务
  103. if click_button == self.I_G_ACCEPT:
  104. self.set_next_run(task='WantedQuests', target=datetime.now().replace(microsecond=0))
  105. return True
  106. def screenshot(self, soft_skip: bool = False):
  107. """
  108. 截图 引入中间函数的目的是 为了解决如协作的这类突发的事件
  109. :param soft_skip: True跳过截图(但保证设备一定有图才跳过,否则依然截图)
  110. :return:
  111. """
  112. if not soft_skip or not self.exist_image():
  113. self.device.screenshot()
  114. # 判断勾协
  115. self._burst()
  116. # # 判断网络异常
  117. # if self.appear(self.I_NETWORK_ABNORMAL):
  118. # logger.warning(f"Network abnormal")
  119. # raise GameStuckError
  120. #
  121. # # 判断网络错误
  122. # if self.appear(self.I_NETWORK_ERROR):
  123. # logger.warning(f"Network error")
  124. # raise GameStuckError
  125. return self.device.image
  126. def exist_image(self) -> bool:
  127. """
  128. 判断当前设备是否有图片
  129. :return: 有返回True,没有返回False
  130. """
  131. return hasattr(self.device, 'image') and self.device.image is not None
  132. def appear(self,
  133. target: RuleImage | RuleGif | RuleOcr,
  134. interval: float = None,
  135. threshold: float = None):
  136. """
  137. :param target: 匹配的目标可以是RuleImage, 也可以是RuleOcr
  138. :param interval:
  139. :param threshold:
  140. :return:
  141. """
  142. if interval:
  143. if target.name in self.interval_timer:
  144. if self.interval_timer[target.name].limit != interval:
  145. self.interval_timer[target.name] = Timer(interval)
  146. else:
  147. self.interval_timer[target.name] = Timer(interval)
  148. if not self.interval_timer[target.name].reached():
  149. return False
  150. if isinstance(target, RuleOcr):
  151. appear = self.ocr_appear(target, interval)
  152. else:
  153. appear = target.match(self.device.image, threshold=threshold)
  154. if appear and interval:
  155. self.interval_timer[target.name].reset()
  156. return appear
  157. def appear_then_click(self,
  158. target: RuleImage | RuleGif,
  159. action: Union[RuleClick, RuleLongClick] = None,
  160. interval: float = None,
  161. threshold: float = None,
  162. duration: float = None):
  163. """
  164. 出现了就点击,默认点击图片的位置,如果添加了click参数,就点击click的位置
  165. :param duration: 如果是长按,可以手动指定duration,不指定默认.单位是ms!!!!
  166. :param action: 可以是RuleClick, 也可以是RuleLongClick
  167. :param target: 可以是RuleImage后续支持RuleOcr
  168. :param interval:
  169. :param threshold:
  170. :return: True or False
  171. """
  172. if not isinstance(target, RuleImage) and not isinstance(target, RuleGif):
  173. return False
  174. appear = self.appear(target, interval=interval, threshold=threshold)
  175. if appear and not action:
  176. x, y = target.coord()
  177. self.device.click(x, y, control_name=target.name)
  178. elif appear and action:
  179. x, y = action.coord()
  180. if isinstance(action, RuleLongClick):
  181. if duration is None:
  182. self.device.long_click(x, y, duration=action.duration / 1000, control_name=target.name)
  183. else:
  184. self.device.long_click(x, y, duration=duration / 1000, control_name=target.name)
  185. elif isinstance(action, RuleClick):
  186. self.device.click(x, y, control_name=target.name)
  187. return appear
  188. def wait_until_appear(self,
  189. target: RuleImage | RuleOcr,
  190. skip_first_screenshot=False,
  191. wait_time: int = None) -> bool:
  192. """
  193. 等待直到出现目标
  194. :param wait_time: 等待时间,单位秒
  195. :param target:
  196. :param skip_first_screenshot:
  197. :return:
  198. """
  199. wait_timer = None
  200. if wait_time:
  201. wait_timer = Timer(wait_time)
  202. wait_timer.start()
  203. while 1:
  204. if skip_first_screenshot:
  205. skip_first_screenshot = False
  206. else:
  207. self.screenshot()
  208. if wait_timer and wait_timer.reached():
  209. logger.warning(f"Wait until appear {target.name} timeout")
  210. return False
  211. if isinstance(target, RuleImage) and self.appear(target):
  212. return True
  213. if isinstance(target, RuleOcr) and self.ocr_appear(target):
  214. return True
  215. def wait_until_appear_then_click(self,
  216. target: RuleImage,
  217. action: Union[RuleClick, RuleLongClick] = None,
  218. wait_time: int = None) -> bool:
  219. """
  220. 等待直到出现目标,然后点击
  221. :param wait_time:
  222. :param action:
  223. :param target:
  224. :return:
  225. """
  226. if not self.wait_until_appear(target, wait_time):
  227. return False
  228. click_x, click_y = target.coord()
  229. if action is None:
  230. self.device.click(click_x, click_y, control_name=target.name)
  231. elif isinstance(action, RuleLongClick):
  232. self.device.long_click(click_x, click_y, duration=action.duration / 1000, control_name=target.name)
  233. elif isinstance(action, RuleClick):
  234. self.device.click(click_x, click_y, control_name=target.name)
  235. return True
  236. def wait_until_disappear(self, target: RuleImage) -> None:
  237. while 1:
  238. self.screenshot()
  239. if not self.appear(target):
  240. break
  241. def wait_until_stable(self,
  242. target: RuleImage,
  243. timer=Timer(0.3, count=1),
  244. timeout=Timer(5, count=10),
  245. skip_first_screenshot=True):
  246. """
  247. 等待目标稳定,即连续多次匹配成功
  248. :param target:
  249. :param timer:
  250. :param timeout:
  251. :param skip_first_screenshot:
  252. :return:
  253. """
  254. target._match_init = False
  255. timeout.reset()
  256. while 1:
  257. if skip_first_screenshot:
  258. skip_first_screenshot = False
  259. else:
  260. self.screenshot()
  261. if target._match_init:
  262. if target.match(self.device.image):
  263. if timer.reached():
  264. break
  265. else:
  266. # button.load_color(self.device.image)
  267. timer.reset()
  268. else:
  269. # target.load_color(self.device.image)
  270. target._match_init = True
  271. if timeout.reached():
  272. logger.warning(f'Wait_until_stable({target}) timeout')
  273. break
  274. def wait_animate_stable(self, rule: RuleAnimate, interval: float = None, timeout: float = None):
  275. """
  276. 不同与上面的wait_until_stable,这个将会匹配连续的两帧图片的特定区域
  277. @param rule:
  278. @param interval:
  279. @param timeout:
  280. @return:
  281. """
  282. if not isinstance(rule, RuleAnimate):
  283. rule = RuleAnimate(rule)
  284. timeout_timer = Timer(timeout).start() if timeout is not None else None
  285. while 1:
  286. self.screenshot()
  287. if interval:
  288. if rule.name in self.interval_timer:
  289. if self.interval_timer[rule.name].limit != interval:
  290. self.interval_timer[rule.name] = Timer(interval)
  291. else:
  292. self.interval_timer[rule.name] = Timer(interval)
  293. if not self.interval_timer[rule.name].reached():
  294. return False
  295. stable = rule.stable(self.device.image)
  296. if stable:
  297. if interval:
  298. self.interval_timer[rule.name].reset()
  299. break
  300. if timeout_timer and timeout_timer.reached():
  301. logger.info(f'Wait_animate_stable({rule}) timeout')
  302. break
  303. def swipe(self, swipe: RuleSwipe, interval: float = None) -> None:
  304. """
  305. :param interval:
  306. :param swipe:
  307. :return:
  308. """
  309. if not isinstance(swipe, RuleSwipe):
  310. return
  311. if interval:
  312. if swipe.name in self.interval_timer:
  313. # 如果传入的限制时间不一样,则替换限制新的传入的时间
  314. if self.interval_timer[swipe.name].limit != interval:
  315. self.interval_timer[swipe.name] = Timer(interval)
  316. else:
  317. # 如果没有限制时间,则创建限制时间
  318. self.interval_timer[swipe.name] = Timer(interval)
  319. # 如果时间还没到达,则不执行
  320. if not self.interval_timer[swipe.name].reached():
  321. return
  322. x1, y1, x2, y2 = swipe.coord()
  323. self.device.swipe(p1=(x1, y1), p2=(x2, y2), control_name=swipe.name)
  324. # 执行后,如果有限制时间,则重置限制时间
  325. if interval:
  326. # logger.info(f'Swipe {swipe.name}')
  327. self.interval_timer[swipe.name].reset()
  328. def click(self, click: Union[RuleClick, RuleLongClick] = None, interval: float = None) -> bool:
  329. """
  330. 点击或者长按
  331. :param interval:
  332. :param click:
  333. :return: 返回值不是click是否成功,而是interval是否设置以及是否到时间
  334. """
  335. if not click:
  336. return False
  337. if interval:
  338. if click.name in self.interval_timer:
  339. # 如果传入的限制时间不一样,则替换限制新的传入的时间
  340. if self.interval_timer[click.name].limit != interval:
  341. self.interval_timer[click.name] = Timer(interval)
  342. else:
  343. # 如果没有限制时间,则创建限制时间
  344. self.interval_timer[click.name] = Timer(interval)
  345. # 如果时间还没到达,则不执行
  346. if not self.interval_timer[click.name].reached():
  347. return False
  348. x, y = click.coord()
  349. if isinstance(click, RuleLongClick):
  350. self.device.long_click(x=x, y=y, duration=click.duration / 1000, control_name=click.name)
  351. elif isinstance(click, RuleClick) or isinstance(click, RuleImage) or isinstance(click, RuleOcr):
  352. self.device.click(x=x, y=y, control_name=click.name)
  353. # 执行后,如果有限制时间,则重置限制时间
  354. if interval:
  355. self.interval_timer[click.name].reset()
  356. return True
  357. return False
  358. def ocr_appear(self, target: RuleOcr, interval: float = None) -> bool:
  359. """
  360. ocr识别目标
  361. :param interval:
  362. :param target:
  363. :return: 如果target有keyword或者是keyword存在,返回是True,否则返回False
  364. 但是没有指定keyword,返回的是匹配到的值,具体取决于target的mode
  365. """
  366. if not isinstance(target, RuleOcr):
  367. return None
  368. if interval:
  369. if target.name in self.interval_timer:
  370. # 如果传入的限制时间不一样,则替换限制新的传入的时间
  371. if self.interval_timer[target.name].limit != interval:
  372. self.interval_timer[target.name] = Timer(interval)
  373. else:
  374. # 如果没有限制时间,则创建限制时间
  375. self.interval_timer[target.name] = Timer(interval)
  376. # 如果时间还没到达,则不执行
  377. if not self.interval_timer[target.name].reached():
  378. return None
  379. result = target.ocr(self.device.image)
  380. appear = False
  381. if not target.keyword or target.keyword == '':
  382. appear = False
  383. match target.mode:
  384. case OcrMode.FULL: # 全匹配
  385. appear = result != (0, 0, 0, 0)
  386. case OcrMode.SINGLE:
  387. appear = result == target.keyword
  388. case OcrMode.DIGIT:
  389. appear = result == int(target.keyword)
  390. case OcrMode.DIGITCOUNTER:
  391. appear = result == target.ocr_str_digit_counter(target.keyword)
  392. case OcrMode.DURATION:
  393. appear = result == target.parse_time(target.keyword)
  394. if interval and appear:
  395. self.interval_timer[target.name].reset()
  396. return appear
  397. def ocr_appear_click(self,
  398. target: RuleOcr,
  399. action: Union[RuleClick, RuleLongClick] = None,
  400. interval: float = None,
  401. duration: float = None) -> bool:
  402. """
  403. ocr识别目标,如果目标存在,则触发动作
  404. :param target:
  405. :param action:
  406. :param interval:
  407. :param duration:
  408. :return:
  409. """
  410. appear = self.ocr_appear(target, interval)
  411. if not appear:
  412. return False
  413. if action:
  414. x, y = action.coord()
  415. self.click(action, interval)
  416. else:
  417. x, y = target.coord()
  418. self.device.click(x=x, y=y, control_name=target.name)
  419. return True
  420. def list_find(self, target: RuleList, name: str | list[str], max_swipe: int = 10) -> bool | tuple:
  421. """
  422. 会一致在列表寻找目标,找到了就退出。
  423. 如果是图片列表会一直往下找
  424. 如果是纯文字的,会自动识别自己的位置,根据位置选择向前还是向后翻
  425. :param max_swipe: 最大滑动次数
  426. :param target:
  427. :param name:
  428. :return:
  429. """
  430. swipe_down = False
  431. swipe_distance_ratio = None
  432. result = None
  433. if not target:
  434. return False
  435. appear = False
  436. for _ in range(max_swipe):
  437. self.screenshot()
  438. if target.is_image:
  439. result = target.image_appear(self.device.image, name=name)
  440. swipe_down = True
  441. elif target.is_ocr:
  442. result = target.ocr_appear(self.device.image, name=name)
  443. swipe_down = result is not None and isinstance(result, int) and result > 0
  444. swipe_distance_ratio = 1
  445. # 结果是坐标证明找到了, 非坐标都是没找到
  446. if result is not None and isinstance(result, tuple):
  447. appear = True
  448. break
  449. if swipe_distance_ratio:
  450. x1, y1, x2, y2 = target.swipe_pos(number=swipe_distance_ratio, after=swipe_down)
  451. else:
  452. x1, y1, x2, y2 = target.swipe_pos(after=swipe_down)
  453. self.device.swipe(p1=(x1, y1), p2=(x2, y2))
  454. sleep(random.uniform(0.8, 1.3)) # 等待滑动完成, 待优化
  455. if appear:
  456. return result
  457. return False
  458. def list_appear_click(self, target: RuleList, interval: float = None) -> bool:
  459. if interval:
  460. if target.name in self.interval_timer:
  461. # 如果传入的限制时间不一样,则替换限制新的传入的时间
  462. if self.interval_timer[target.name].limit != interval:
  463. self.interval_timer[target.name] = Timer(interval)
  464. else:
  465. # 如果没有限制时间,则创建限制时间
  466. self.interval_timer[target.name] = Timer(interval)
  467. # 如果时间还没到达,则不执行
  468. if not self.interval_timer[target.name].reached():
  469. return False
  470. appear = self.list_find(target, name=target.array[0])
  471. if isinstance(appear, tuple) and interval:
  472. x, y = appear
  473. self.device.click(x, y)
  474. self.interval_timer[target.name].reset()
  475. return True
  476. return False
  477. def set_next_run(self, task: str, finish: bool = False,
  478. success: bool = None, server: bool = True, target: datetime = None) -> None:
  479. """
  480. 设置下次运行时间 当然这个也是可以重写的
  481. :param target: 可以自定义的下次运行时间
  482. :param server: True
  483. :param success: 判断是成功的还是失败的时间间隔
  484. :param task: 任务名称,大驼峰的
  485. :param finish: 是完成任务后的时间为基准还是开始任务的时间为基准
  486. :return:
  487. """
  488. if finish:
  489. start_time = datetime.now().replace(microsecond=0)
  490. else:
  491. start_time = self.start_time
  492. self.config.task_delay(task, start_time=start_time, success=success, server=server, target=target)
  493. def custom_next_run(self, task: str, custom_time: Time = None, time_delta: float = 1) -> None:
  494. """
  495. 设置下次自定义运行时间
  496. :param task: 任务名称,大驼峰的
  497. :param custom_time: 可以自定义的下次运行时间
  498. :param time_delta: 下次运行日期为几天后,默认为第二天
  499. :return:
  500. """
  501. target_time = (datetime.now() + timedelta(days=time_delta)).replace(hour=custom_time.hour,
  502. minute=custom_time.minute,
  503. second=custom_time.second)
  504. self.set_next_run(task, target=target_time)
  505. # ---------------------------------------------------------------------------------------------------------------
  506. #
  507. # ---------------------------------------------------------------------------------------------------------------
  508. def ui_reward_appear_click(self, screenshot=False) -> bool:
  509. """
  510. 如果出现 ‘获得奖励’ 就点击
  511. :return:
  512. """
  513. if screenshot:
  514. self.screenshot()
  515. return self.appear_then_click(self.I_UI_REWARD, action=self.C_UI_REWARD, interval=0.4, threshold=0.6)
  516. def ui_get_reward(self, click_image: RuleImage or RuleOcr or RuleClick, click_interval: float = 1):
  517. """
  518. 传进来一个点击图片 或是 一个ocr, 会点击这个图片,然后等待‘获得奖励’,
  519. 最后当获得奖励消失后 退出
  520. :param click_interval:
  521. :param click_image:
  522. :return:
  523. """
  524. _timer = Timer(10)
  525. _timer.start()
  526. while 1:
  527. self.screenshot()
  528. if self.ui_reward_appear_click():
  529. sleep(0.5)
  530. while 1:
  531. self.screenshot()
  532. # 等待动画结束
  533. if not self.appear(self.I_UI_REWARD, threshold=0.6):
  534. logger.info('Get reward success')
  535. break
  536. # 一直点击
  537. if self.ui_reward_appear_click():
  538. continue
  539. break
  540. if _timer.reached():
  541. logger.warning('Get reward timeout')
  542. break
  543. if isinstance(click_image, RuleImage):
  544. if self.appear_then_click(click_image, interval=click_interval):
  545. continue
  546. elif isinstance(click_image, RuleOcr):
  547. if self.ocr_appear_click(click_image, interval=click_interval):
  548. continue
  549. elif isinstance(click_image, RuleClick):
  550. if self.click(click_image, interval=click_interval):
  551. continue
  552. return True
  553. def ui_click(self, click, stop, interval=1):
  554. """
  555. 循环的一个操作,直到出现stop
  556. :param click:
  557. :param stop:
  558. :parm interval
  559. :return:
  560. """
  561. while 1:
  562. self.screenshot()
  563. if self.appear(stop):
  564. break
  565. if isinstance(click, RuleImage) and self.appear_then_click(click, interval=interval):
  566. continue
  567. if isinstance(click, RuleClick) and self.click(click, interval=interval):
  568. continue
  569. elif isinstance(click, RuleOcr) and self.ocr_appear_click(click, interval=interval):
  570. continue
  571. def ui_click_until_disappear(self, click, interval: float = 1):
  572. """
  573. 点击一个按钮直到消失
  574. :param interval:
  575. :param click:
  576. :return:
  577. """
  578. while 1:
  579. self.screenshot()
  580. if not self.appear(click):
  581. break
  582. elif self.appear_then_click(click, interval=interval):
  583. continue
  584. def ui_click_until_smt_disappear(self, click, stop, interval: float = 1):
  585. """
  586. 点击一个按钮/区域/文字直到stop消失
  587. """
  588. while 1:
  589. self.screenshot()
  590. if not self.appear(stop):
  591. break
  592. if isinstance(click, RuleImage) or isinstance(click, RuleGif):
  593. self.appear_then_click(click, interval=interval)
  594. continue
  595. if isinstance(click, RuleClick):
  596. self.click(click, interval)
  597. continue
  598. if isinstance(click, RuleOcr):
  599. self.click(click)
  600. continue
  601. def push_notify(self, content='', title=None, level=3):
  602. logger.info(f'Push notify: {content}')
  603. def save_image(self, task_name=None, content=None, wait_time=2, image_type=False, push_flag=False, level=3):
  604. logger.info(f'Save image: {task_name}')