Skip to content

Commit

Permalink
feat(event): add GroupAlbumUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
wyapx committed Aug 19, 2024
1 parent 91848d4 commit 949ea78
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lagrange/client/events/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,11 @@ def is_increase(self) -> bool:
@property
def is_emoji(self) -> bool:
return self.emoji_type == 2


@dataclass
class GroupAlbumUpdate(GroupEvent):
"""群相册更新(上传)"""

timestamp: int
image_id: str
13 changes: 13 additions & 0 deletions lagrange/client/server_push/msg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import re
from urllib.parse import parse_qsl
from typing import TYPE_CHECKING, Type, Tuple, TypeVar, Union, Dict

from lagrange.client.message.decoder import parse_grp_msg, parse_friend_msg
Expand All @@ -13,6 +14,7 @@
MemberJoinRequest,
MemberRecallMsg,
GroupSub20Head,
PBGroupAlbumUpdate,
)
from lagrange.utils.binary.protobuf import proto_decode, ProtoStruct, proto_encode
from lagrange.utils.binary.reader import Reader
Expand All @@ -29,6 +31,7 @@
GroupNudge,
GroupReaction,
GroupSign,
GroupAlbumUpdate,
)
from ..wtlogin.sso import SSOPacket
from .log import logger
Expand Down Expand Up @@ -169,6 +172,16 @@ async def msg_push_handler(client: "Client", sso: SSOPacket):
)
elif pb.flag == 23: # 群幸运字符?
pass
elif pb.flag == 37: # 群相册上传(手Q专用:()
_, pb = unpack(
pkg.message.buf2, PBGroupAlbumUpdate
) # 塞 就硬塞,可以把你的顾辉盒也给塞进来
q = dict(parse_qsl(pb.body.args))
return GroupAlbumUpdate(
grp_id=pb.grp_id,
timestamp=pb.timestamp,
image_id=q["i"],
)
else:
raise ValueError(
f"Unknown subtype_12 flag: {pb.flag}: {pb.body.hex() if pb.body else pb}"
Expand Down
17 changes: 15 additions & 2 deletions lagrange/pb/status/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class GroupReactionInner(ProtoStruct):
body: GroupReactionBody = proto_field(1)


class GroupReaction(ProtoStruct):
class PBGroupReaction(ProtoStruct):
inner: GroupReactionInner = proto_field(1)


Expand All @@ -110,7 +110,7 @@ class GroupSub16Head(ProtoStruct):
13
) # 12: renamed, 6: set special_title, 13: unknown, 35: set reaction
operator_uid: str = proto_field(21, default="")
f44: Optional[GroupReaction] = proto_field(44, default=None) # set reaction only
f44: Optional[PBGroupReaction] = proto_field(44, default=None) # set reaction only


class GroupSub20Body(ProtoStruct):
Expand All @@ -128,3 +128,16 @@ class GroupSub20Head(ProtoStruct):
grp_id: int = proto_field(4)
f13: int = proto_field(13) # 19
body: GroupSub20Body = proto_field(26)


class PBGroupAlbumUpdateBody(ProtoStruct):
# f1: 6
args: str = proto_field(2)


class PBGroupAlbumUpdate(ProtoStruct):
# f1: 38
timestamp: int = proto_field(2)
grp_id: int = proto_field(4)
# f13: 37
body: PBGroupAlbumUpdateBody = proto_field(46)

0 comments on commit 949ea78

Please sign in to comment.