-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_test.py
94 lines (74 loc) · 2.27 KB
/
run_test.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
import json
from typing import TYPE_CHECKING, Set
import nonebot
import src.common_utils as common_utils
import asyncio
# def t_database():
# db = CDatabase()
# col = {
# "text1": "text",
# "text2": "text",
# "text3": "text",
# "text4": "text",
# "text5": "text",
# }
# db.init_table(table_name="test", table_key="id", table_col=col)
# db.is_key_exist(key=123456)
#
#
from pydantic import parse_obj_as
from enum import Enum
from typing import Any, List, Dict, Type, Iterable, Optional, Union
class MessageType(str, Enum):
"""消息类型枚举类"""
SOURCE = 'Source'
QUOTE = 'Quote'
AT = 'At'
AT_ALL = 'AtAll'
FACE = 'Face'
PLAIN = 'Plain'
IMAGE = 'Image'
FLASH_IMAGE = 'FlashImage'
VOICE = 'Voice'
XML = 'Xml'
JSON = 'Json'
APP = 'App'
DICE = 'Dice'
POKE = 'Poke'
MARKET_FACE = 'MarketFace'
MUSIC_SHARE = 'MusicShare'
FORWARD_MESSAGE = 'ForwardMessage'
FILE = 'File'
MIRAI_CODE = 'MiraiCode'
class MessageSegment(BaseMessageSegment["MessageChain"]):
type: MessageType
data: Dict[str, Any]
@classmethod
def get_message_class(cls) -> Type["MessageChain"]:
return MessageChain
async def t_genshin(cookie: str):
from src.plugins.genshin.api import API
from src.common_utils.database import Database
valin = "[{'type': 'Source', 'id': 3507, 'time': 1657075981}, {'type': 'Plain', 'text': 'l'}]"
value = [parse_obj_as(cls.get_segment_class(), v) for v in valin]
db = Database()
a = db.connect_table("genshin")
ys = API()
ret, user_role = await ys.init_user_role(cookie)
if ret is False:
raise Exception("init user role error")
ret, sign_info = await ys.get_sign_info()
if ret is False:
raise Exception("get sign info error")
ret, rewards_info = await ys.get_rewards_info()
if ret is False:
raise Exception("get rewards info error")
ret = await ys.act_sign()
if ret is False:
raise Exception("act sign error")
if __name__ == "__main__":
nonebot.init()
global_config = nonebot.get_driver().config
genshin_cookie = global_config.test_genshin_cookie
loop = asyncio.get_event_loop()
loop.run_until_complete(t_genshin(genshin_cookie))