|
52 | 52 | PBGetInfoFromUidReq, |
53 | 53 | PBGetGrpLastSeq, |
54 | 54 | GetGrpLastSeqRsp, |
| 55 | + PBGetInfoFromUinReq, |
55 | 56 | ) |
56 | 57 | from lagrange.pb.service.oidb import OidbRequest, OidbResponse |
57 | 58 | from lagrange.pb.highway.comm import IndexNode |
@@ -495,10 +496,31 @@ async def get_user_info(self, uid: str) -> UserInfo: ... |
495 | 496 | @overload |
496 | 497 | async def get_user_info(self, uid: list[str]) -> list[UserInfo]: ... |
497 | 498 |
|
498 | | - async def get_user_info(self, uid: Union[str, list[str]]) -> Union[UserInfo, list[UserInfo]]: |
499 | | - if isinstance(uid, str): |
500 | | - uid = [uid] |
501 | | - rsp = GetInfoFromUidRsp.decode((await self.send_oidb_svc(0xFE1, 8, PBGetInfoFromUidReq(uid=uid).encode())).data) |
| 499 | + @overload |
| 500 | + async def get_user_info(self, uin: int) -> UserInfo: |
| 501 | + ... |
| 502 | + |
| 503 | + @overload |
| 504 | + async def get_user_info(self, uin: list[int]) -> list[UserInfo]: |
| 505 | + ... |
| 506 | + |
| 507 | + async def get_user_info( |
| 508 | + self, |
| 509 | + uid: Union[str, list[str]] = None, |
| 510 | + uin: Union[int, list[int]] = None, |
| 511 | + ) -> Union[UserInfo, list[UserInfo]]: |
| 512 | + userid = uid or uin |
| 513 | + assert userid, "empty uid or uin" |
| 514 | + if not isinstance(userid, list): |
| 515 | + userid = [userid] |
| 516 | + if isinstance(userid[0], int): |
| 517 | + req, sc = PBGetInfoFromUinReq(uin=userid).encode(), 2 |
| 518 | + elif isinstance(userid[0], str): |
| 519 | + req, sc = PBGetInfoFromUidReq(uid=userid).encode(), 8 |
| 520 | + else: |
| 521 | + raise TypeError(userid[0]) |
| 522 | + |
| 523 | + rsp = GetInfoFromUidRsp.decode((await self.send_oidb_svc(0xFE1, sc, req)).data) |
502 | 524 | if not rsp.body: |
503 | 525 | raise AssertionError("Empty response") |
504 | 526 | elif len(rsp.body) == 1: |
|
0 commit comments