14
14
MemberJoinRequest ,
15
15
MemberRecallMsg ,
16
16
GroupSub20Head ,
17
+ PBBotGrayTip ,
17
18
PBGroupAlbumUpdate ,
19
+ PBGroupBotAdded ,
18
20
PBGroupInvite ,
21
+ PBSelfJoinInGroup ,
19
22
)
20
- from lagrange .pb .status .friend import (
21
- PBFriendRecall ,
22
- PBFriendRequest
23
- )
23
+ from lagrange .pb .status .friend import PBFriendRecall , PBFriendRequest
24
24
from lagrange .utils .binary .protobuf import proto_decode , ProtoStruct , proto_encode
25
25
from lagrange .utils .binary .reader import Reader
26
26
from lagrange .utils .operator import unpack_dict , timestamp
27
27
28
28
from ..events .group import (
29
+ BotGrayTip ,
30
+ GroupBotAdded ,
31
+ GroupBotJoined ,
29
32
GroupInvite ,
30
33
GroupMemberGotSpecialTitle ,
31
34
GroupMemberJoined ,
36
39
GroupRecall ,
37
40
GroupNudge ,
38
41
GroupReaction ,
42
+ GroupSelfJoined ,
43
+ GroupSelfRequireReject ,
39
44
GroupSign ,
40
45
GroupAlbumUpdate ,
41
- GroupMemberJoinedByInvite
42
- )
43
- from ..events .friend import (
44
- FriendRecall ,
45
- FriendRequest
46
+ GroupMemberJoinedByInvite ,
46
47
)
48
+ from ..events .friend import FriendRecall , FriendRequest
47
49
from ..wtlogin .sso import SSOPacket
48
50
from .log import logger
49
51
@@ -74,10 +76,9 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
74
76
elif typ == 33 : # member joined
75
77
pb = MemberChanged .decode (pkg .message .buf2 )
76
78
return GroupMemberJoined (
77
- grp_id = pkg .response_head .from_uin ,
78
- uin = pb .uin ,
79
- uid = pb .uid ,
80
- join_type = pb .join_type ,
79
+ grp_id = pb .uin ,
80
+ uid = pb .uid , # right u cant get uin
81
+ join_type = pb .join_type_new ,
81
82
)
82
83
elif typ == 34 : # member exit
83
84
pb = MemberChanged .decode (pkg .message .buf2 )
@@ -91,26 +92,35 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
91
92
elif typ == 84 :
92
93
pb = MemberJoinRequest .decode (pkg .message .buf2 )
93
94
return GroupMemberJoinRequest (grp_id = pb .grp_id , uid = pb .uid , answer = pb .request_field )
95
+ elif typ == 85 :
96
+ pb = PBSelfJoinInGroup .decode (pkg .message .buf2 )
97
+ return GroupSelfJoined (grp_id = pb .gid , op_uid = pb .operator_uid )
98
+ elif typ == 86 :
99
+ reader = Reader (pkg .message .buf2 )
100
+ grp_id = reader .read_u32 () # it should have more infomation,but i cant guess it
101
+ return GroupSelfRequireReject (grp_id , "" )
94
102
elif typ == 87 :
95
103
pb = PBGroupInvite .decode (pkg .message .buf2 )
96
104
return GroupInvite (grp_id = pb .gid , invitor_uid = pb .invitor_uid )
105
+ elif typ == 167 :
106
+ print (pkg .message .encode ().hex ())
97
107
elif typ == 525 :
98
108
pb = MemberInviteRequest .decode (pkg .message .buf2 )
99
109
if pb .cmd == 87 :
100
110
inn = pb .info .inner
101
111
return GroupMemberJoinRequest (grp_id = inn .grp_id , uid = inn .uid , invitor_uid = inn .invitor_uid )
102
112
elif typ == 0x210 : # friend event, 528 / group file upload notice event
103
- if sub_typ == 35 : # friend request
113
+ if sub_typ == 35 : # friend request
104
114
pb = PBFriendRequest .decode (pkg .message .buf2 )
105
115
return FriendRequest (
106
116
pkg .response_head .from_uin ,
107
117
pb .info .from_uid ,
108
118
pkg .response_head .to_uin ,
109
119
pb .info .to_uid ,
110
120
pb .info .verify ,
111
- pb .info .source
121
+ pb .info .source ,
112
122
)
113
- elif sub_typ == 138 : # friend recall
123
+ elif sub_typ == 138 : # friend recall
114
124
pb = PBFriendRecall .decode (pkg .message .buf2 )
115
125
return FriendRecall (
116
126
pkg .response_head .from_uin ,
@@ -119,10 +129,16 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
119
129
pb .info .to_uid ,
120
130
pb .info .seq ,
121
131
pb .info .random ,
122
- pb .info .time
132
+ pb .info .time ,
123
133
)
134
+ if sub_typ == 368 :
135
+ pass
136
+ # print(pkg.message.encode().hex())
124
137
logger .debug (f"unhandled friend event / group file upload notice event: { pkg } " ) # TODO: paste
125
138
elif typ == 0x2DC : # grp event, 732
139
+ if sub_typ == 1 :
140
+ # print(pkg.encode().hex())
141
+ pass
126
142
if sub_typ == 20 : # nudge and group_sign(群打卡)
127
143
if pkg .message :
128
144
grp_id , pb = unpack (pkg .message .buf2 , GroupSub20Head )
@@ -136,14 +152,19 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
136
152
attrs [k .decode ()] = int (v .decode ())
137
153
else :
138
154
attrs [k .decode ()] = v .decode ()
155
+ if pb .body .f2 == 19217 :
156
+ return GroupBotJoined (
157
+ grp_id ,
158
+ attrs ["mqq_uin" ],
159
+ attrs ["nick_name" ],
160
+ attrs ["robot_name" ],
161
+ attrs ["robot_schema" ],
162
+ attrs ["user_schema" ],
163
+ )
139
164
if pb .body .type == 1 :
140
165
if "invitor" in attrs :
141
166
# reserve: attrs["msg_nums"]
142
- return GroupMemberJoinedByInvite (
143
- grp_id ,
144
- attrs ["invitor" ],
145
- attrs ["invitee" ]
146
- )
167
+ return GroupMemberJoinedByInvite (grp_id , attrs ["invitor" ], attrs ["invitee" ])
147
168
elif "user" in attrs and "uin" in attrs :
148
169
# todo: 群代办
149
170
pass
@@ -169,13 +190,17 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
169
190
pb .body .attrs_xml ,
170
191
)
171
192
else :
172
- raise ValueError (f"unknown type({ pb .body .type } ) on GroupSub20: { attrs } " )
193
+ raise ValueError (f"unknown type({ pb .body .type } ) f2( { pb . body . f2 } ) on GroupSub20: { attrs } " )
173
194
else :
174
195
# print(pkg.encode().hex(), 2)
175
196
return
176
197
elif sub_typ == 16 : # rename & special_title & reaction
198
+ # print(sso.data.hex())
177
199
if pkg .message :
178
200
grp_id , pb = unpack (pkg .message .buf2 , GroupSub16Head )
201
+ if pb .flag is None :
202
+ _ , pb = unpack (pkg .message .buf2 , PBBotGrayTip ) # 傻逼tx,我13号位呢
203
+ return BotGrayTip (grp_id , pb .body .message )
179
204
if pb .flag == 6 : # special_title
180
205
body = MemberGotTitleBody .decode (pb .body )
181
206
for el in re .findall (r"<(\{.*?})>" , body .string ):
@@ -222,6 +247,9 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
222
247
timestamp = pb .timestamp ,
223
248
image_id = q ["i" ],
224
249
)
250
+ elif pb .flag == 38 :
251
+ _ , pb = unpack (pkg .message .buf2 , PBGroupBotAdded )
252
+ return GroupBotAdded (pb .body .grp_id , pb .body .bot_uid_1 or pb .body .bot_uid_2 )
225
253
else :
226
254
raise ValueError (f"Unknown subtype_12 flag: { pb .flag } : { pb .body .hex () if pb .body else pb } " )
227
255
elif sub_typ == 17 : # recall
0 commit comments