1515 MemberRecallMsg ,
1616 GroupSub20Head ,
1717 PBGroupAlbumUpdate ,
18+ PBGroupInvite ,
1819)
1920from lagrange .utils .binary .protobuf import proto_decode , ProtoStruct , proto_encode
2021from lagrange .utils .binary .reader import Reader
2122from lagrange .utils .operator import unpack_dict , timestamp
2223
2324from ..events .group import (
25+ GroupInvite ,
2426 GroupMemberGotSpecialTitle ,
2527 GroupMemberJoined ,
2628 GroupMemberJoinRequest ,
@@ -58,7 +60,8 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
5860 if typ == 82 : # grp msg
5961 return await parse_grp_msg (client , pkg )
6062 elif typ in [166 , 208 , 529 ]: # frd msg
61- return await parse_friend_msg (client , pkg )
63+ if pkg .message :
64+ return await parse_friend_msg (client , pkg )
6265 elif typ == 33 : # member joined
6366 pb = MemberChanged .decode (pkg .message .buf2 )
6467 return GroupMemberJoined (
@@ -78,16 +81,15 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
7881 )
7982 elif typ == 84 :
8083 pb = MemberJoinRequest .decode (pkg .message .buf2 )
81- return GroupMemberJoinRequest (
82- grp_id = pb .grp_id , uid = pb .uid , answer = pb .request_field
83- )
84+ return GroupMemberJoinRequest (grp_id = pb .grp_id , uid = pb .uid , answer = pb .request_field )
85+ elif typ == 87 :
86+ pb = PBGroupInvite .decode (pkg .message .buf2 )
87+ return GroupInvite (grp_id = pb .gid , invitor_uid = pb .invitor_uid )
8488 elif typ == 525 :
8589 pb = MemberInviteRequest .decode (pkg .message .buf2 )
8690 if pb .cmd == 87 :
8791 inn = pb .info .inner
88- return GroupMemberJoinRequest (
89- grp_id = inn .grp_id , uid = inn .uid , invitor_uid = inn .invitor_uid
90- )
92+ return GroupMemberJoinRequest (grp_id = inn .grp_id , uid = inn .uid , invitor_uid = inn .invitor_uid )
9193 elif typ == 0x210 : # friend event / group file upload notice event
9294 logger .debug (f"unhandled friend event / group file upload notice event: { pkg } " ) # TODO: paste
9395 elif typ == 0x2DC : # grp event, 732
@@ -109,9 +111,7 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
109111 grp_id ,
110112 attrs ["uin_str1" ],
111113 attrs ["uin_str2" ],
112- attrs ["action_str" ]
113- if "action_str" in attrs
114- else attrs ["alt_str1" ], # ?
114+ attrs ["action_str" ] if "action_str" in attrs else attrs ["alt_str1" ], # ?
115115 attrs ["suffix_str" ],
116116 attrs ,
117117 pb .body .attrs_xml ,
@@ -126,9 +126,7 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
126126 pb .body .attrs_xml ,
127127 )
128128 else :
129- raise ValueError (
130- f"unknown type({ pb .body .type } ) on GroupSub20: { attrs } "
131- )
129+ raise ValueError (f"unknown type({ pb .body .type } ) on GroupSub20: { attrs } " )
132130 else :
133131 # print(pkg.encode().hex(), 2)
134132 return
@@ -174,19 +172,15 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
174172 elif pb .flag == 23 : # 群幸运字符?
175173 pass
176174 elif pb .flag == 37 : # 群相册上传(手Q专用:()
177- _ , pb = unpack (
178- pkg .message .buf2 , PBGroupAlbumUpdate
179- ) # 塞 就硬塞,可以把你的顾辉盒也给塞进来
175+ _ , pb = unpack (pkg .message .buf2 , PBGroupAlbumUpdate ) # 塞 就硬塞,可以把你的顾辉盒也给塞进来
180176 q = dict (parse_qsl (pb .body .args ))
181177 return GroupAlbumUpdate (
182178 grp_id = pb .grp_id ,
183179 timestamp = pb .timestamp ,
184180 image_id = q ["i" ],
185181 )
186182 else :
187- raise ValueError (
188- f"Unknown subtype_12 flag: { pb .flag } : { pb .body .hex () if pb .body else pb } "
189- )
183+ raise ValueError (f"Unknown subtype_12 flag: { pb .flag } : { pb .body .hex () if pb .body else pb } " )
190184 elif sub_typ == 17 : # recall
191185 grp_id , pb = unpack (pkg .message .buf2 , MemberRecallMsg )
192186
@@ -214,9 +208,7 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
214208 "unknown sub_type %d: %s"
215209 % (
216210 sub_typ ,
217- pkg .message .buf2 .hex ()
218- if getattr (pkg .message , "buf2" , None )
219- else pkg ,
211+ pkg .message .buf2 .hex () if getattr (pkg .message , "buf2" , None ) else pkg ,
220212 )
221213 )
222214 else :
0 commit comments