forked from LagrangeDev/lagrange-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
142 lines (128 loc) · 3.49 KB
/
Copy pathapp.py
File metadata and controls
142 lines (128 loc) · 3.49 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import re
from dataclasses import dataclass
from typing import TypedDict, TypeVar, Union
from .serialize import JsonSerializer
_T = TypeVar("_T", bound=dict[str, Union[int, str]])
_trans_map = {
"SsoVersion": "pt_os_version",
"WtLoginSdk": "wtlogin_sdk",
"AppIdQrCode": "app_id_qrcode",
"MainSigMap": "main_sigmap",
"SubSigMap": "sub_sigmap",
}
def _translate_appinfo(s: _T) -> _T:
out: _T = {}
for k, v in s.items():
if k in _trans_map:
out[_trans_map[k]] = v
else:
k = re.sub(
r"([A-Z])([^A-Z]+)",
r"_\1\2",
k
).lstrip("_").lower()
out[k] = v
return out
@dataclass
class AppInfo(JsonSerializer):
os: str
kernel: str
vendor_os: str
current_version: str
# build_version: int
misc_bitmap: int
pt_version: str
pt_os_version: int
package_name: str
wtlogin_sdk: str
app_id: int
sub_app_id: int
app_id_qrcode: int
app_client_version: int
main_sigmap: int
sub_sigmap: int
nt_login_type: int
@property
def build_version(self) -> int:
return int(self.current_version.split("-")[1])
@property
def package_sign(self) -> str:
# QUA?
if self.os == "Windows":
kernel = "WIN"
elif self.os == "Linux":
kernel = "LNX"
elif self.os == "Mac":
kernel = "MAC"
else:
raise NotImplementedError(self.os)
return f"V1_{kernel}_NQ_{self.current_version}_RDM_B"
@classmethod
def load_custom(cls, d: _T) -> "AppInfo":
return cls(**_translate_appinfo(d))
class AppInfoDict(TypedDict):
linux: AppInfo
macos: AppInfo
windows: AppInfo
app_list: AppInfoDict = {
"linux": AppInfo(
os="Linux",
kernel="Linux",
vendor_os="linux",
current_version="3.2.10-25765",
# build_version=25765,
misc_bitmap=32764,
pt_version="2.0.0",
pt_os_version=19,
package_name="com.tencent.qq",
wtlogin_sdk="nt.wtlogin.0.0.1",
# package_sign="V1_LNX_NQ_3.1.2-13107_RDM_B",
app_id=1600001615,
sub_app_id=537234773,
app_id_qrcode=13697054,
app_client_version=13172,
main_sigmap=169742560,
sub_sigmap=0,
nt_login_type=1,
),
"macos": AppInfo(
os="Mac",
kernel="Darwin",
vendor_os="mac",
current_version="6.9.20-17153",
# build_version=17153,
misc_bitmap=32764,
pt_version="2.0.0",
pt_os_version=23,
package_name="com.tencent.qq",
wtlogin_sdk="nt.wtlogin.0.0.1",
# package_sign="V1_MAC_NQ_6.9.20-17153_RDM_B",
app_id=1600001602,
sub_app_id=537162356,
app_id_qrcode=537162356,
app_client_version=13172,
main_sigmap=169742560,
sub_sigmap=0,
nt_login_type=5,
),
"windows": AppInfo(
os="Windows",
kernel="Windows_NT",
vendor_os="win32",
current_version="9.9.2-15962",
# build_version=15962,
pt_version="2.0.0",
misc_bitmap=32764,
pt_os_version=23,
package_name="com.tencent.qq",
wtlogin_sdk="nt.wtlogin.0.0.1",
# package_sign="V1_WIN_NQ_9.9.2-15962_RDM_B",
app_id=1600001604,
sub_app_id=537138217,
app_id_qrcode=537138217,
app_client_version=13172,
main_sigmap=169742560,
sub_sigmap=0,
nt_login_type=5
)
}