|
| 1 | +from typing import List, Optional |
| 2 | + |
| 3 | +from lagrange.utils.binary.protobuf import ProtoStruct, proto_field |
| 4 | + |
| 5 | + |
| 6 | +class FriendProperty(ProtoStruct): |
| 7 | + code: int = proto_field(1) |
| 8 | + value: Optional[str] = proto_field(2, default=None) |
| 9 | + |
| 10 | + |
| 11 | +class FriendLayer1(ProtoStruct): |
| 12 | + properties: List[FriendProperty] = proto_field(2, default=None) |
| 13 | + |
| 14 | + |
| 15 | +class FriendAdditional(ProtoStruct): |
| 16 | + type: int = proto_field(1) |
| 17 | + layer1: FriendLayer1 = proto_field(2) |
| 18 | + |
| 19 | + |
| 20 | +class FriendInfo(ProtoStruct): |
| 21 | + uid: str = proto_field(1) |
| 22 | + custom_group: Optional[int] = proto_field(2, default=None) |
| 23 | + uin: int = proto_field(3) |
| 24 | + additional: List[FriendAdditional] = proto_field(10001) |
| 25 | + |
| 26 | + |
| 27 | +class GetFriendNumbers(ProtoStruct): |
| 28 | + f1: List[int] = proto_field(1) |
| 29 | + |
| 30 | + |
| 31 | +class GetFriendBody(ProtoStruct): |
| 32 | + type: int = proto_field(1) |
| 33 | + f2: GetFriendNumbers = proto_field(2) |
| 34 | + |
| 35 | + |
| 36 | +class GetFriendListUin(ProtoStruct): |
| 37 | + uin: int = proto_field(1) |
| 38 | + |
| 39 | + |
| 40 | +class PBGetFriendListRequest(ProtoStruct): |
| 41 | + friend_count: int = proto_field(2, default=300) # paging get num |
| 42 | + f4: int = proto_field(4, default=0) |
| 43 | + next_uin: Optional[GetFriendListUin] = proto_field(5, default=None) |
| 44 | + f6: int = proto_field(6, default=1) |
| 45 | + f7: int = proto_field(7, default=2147483647) # MaxValue |
| 46 | + body: List[GetFriendBody] = proto_field( |
| 47 | + 10001, |
| 48 | + default=[ |
| 49 | + GetFriendBody(type=1, f2=GetFriendNumbers(f1=[103, 102, 20002, 27394])), |
| 50 | + GetFriendBody(type=4, f2=GetFriendNumbers(f1=[100, 101, 102])), |
| 51 | + ], |
| 52 | + ) |
| 53 | + f10002: List[int] = proto_field(10002, default=[13578, 13579, 13573, 13572, 13568]) |
| 54 | + f10003: int = proto_field(10003, default=4051) |
| 55 | + """ |
| 56 | + * GetFriendNumbers里是要拿到的东西 |
| 57 | + * 102:个性签名 |
| 58 | + * 103:备注 |
| 59 | + * 20002:昵称 |
| 60 | + * 27394:QID |
| 61 | + """ |
| 62 | + |
| 63 | + |
| 64 | +class GetFriendListRsp(ProtoStruct): |
| 65 | + next: Optional[GetFriendListUin] = proto_field(2, default=None) |
| 66 | + display_friend_count: int = proto_field(3) |
| 67 | + timestamp: int = proto_field(6) |
| 68 | + self_uin: int = proto_field(7) |
| 69 | + friend_list: List[FriendInfo] = proto_field(101) |
| 70 | + |
| 71 | + |
| 72 | +def propertys(properties: List[FriendProperty]): |
| 73 | + return {prop.code: prop.value for prop in properties} |
0 commit comments