forked from cc004/autopcr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_task.py
96 lines (76 loc) · 2.84 KB
/
_task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from abc import abstractclassmethod, abstractmethod, abstractproperty
import traceback
from .autopcr.module.accountmgr import instance as accountmgr
from ._util import draw
class callback:
@abstractmethod
async def send(self, msg: str = '', img: str = ''): ...
@abstractmethod
async def request_validate(self, url: str): ...
@abstractproperty
def qid(self) -> int: ...
class Task():
def __init__(self, token, callback: callback, config={}):
_, target = token
self.callback = callback
self.config = config
self.token = token
self.username = accountmgr.load(target, readonly=True).username
@abstractclassmethod
async def do_task(self): ...
class TaskList(Task):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@abstractclassmethod
def do_module_list(self) -> list: ...
async def do_task(self):
alian, target = self.token
try:
async with accountmgr.load(target) as mgr:
resp = await mgr.do_from_key(self.config, self.do_module_list())
img = await draw(resp, alian + '_' + '_'.join(self.do_module_list()), self.callback.qid)
await self.callback.send(img = img)
except Exception as e:
traceback.print_exc()
await self.callback.send(msg = str(e))
class ClanBattleSupport(TaskList):
def do_module_list(self) -> list:
return ["get_clan_support_unit"]
class JJCBack(TaskList):
def do_module_list(self) -> list:
return ["jjc_back"]
class PJJCBack(TaskList):
def do_module_list(self) -> list:
return ["pjjc_back"]
class QuestRecommand(TaskList):
def do_module_list(self) -> list:
return ["get_normal_quest_recommand"]
class FindEquip(TaskList):
def do_module_list(self) -> list:
return ["get_need_equip"]
class GetLibraryImport(TaskList):
def do_module_list(self) -> list:
return ["get_library_import_data"]
class FindXinsui(TaskList):
def do_module_list(self) -> list:
return ["get_need_xinsui"]
class FindMemory(TaskList):
def do_module_list(self) -> list:
return ["get_need_memory"]
class Gacha(TaskList):
def do_module_list(self) -> list:
return ["gacha_start"]
class DailyClean(Task):
async def do_task(self):
alian, target = self.token
try:
await self.callback.send(msg = f"开始为{alian}清理日常")
except Exception as e: # 风控,怕report_to_su还失败,就不整了
print(e)
try:
async with accountmgr.load(target) as mgr:
resp = await mgr.do_daily()
img = await draw(resp, alian, self.callback.qid)
await self.callback.send(msg = alian, img = img)
except Exception as e:
await self.callback.send(msg = f'{alian}: {e}')