From 9e719ece6ca97c6342e5ef84fe50993a96aa860e Mon Sep 17 00:00:00 2001 From: wongxy Date: Sun, 8 Nov 2020 16:11:38 +0800 Subject: [PATCH] more actions --- botoy/action.py | 48 +++++++++++++++++++++++++++++++++++++++++++++--- docs/action.md | 9 ++++----- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/botoy/action.py b/botoy/action.py index 88f35fd9..fab16a85 100644 --- a/botoy/action.py +++ b/botoy/action.py @@ -314,14 +314,46 @@ def replyFriendMsg( }, ) + def repostVideo2Group(self, group: int, forwordBuf: str) -> dict: + """转发视频到群聊 + :param group: 群号 + :param forwordBuf: 原视频的forwordBuf字段 + """ + return self.post( + 'SendMsg', + { + "toUser": group, + "sendToType": 2, + "sendMsgType": "ForwordMsg", + "forwordBuf": forwordBuf, + "forwordField": 19, + }, + ) + + def repostVideo2Friend(self, user: int, forwordBuf: str) -> dict: + """转发视频到好友 + :param user: 好友QQ + :param forwordBuf: 原视频的forwordBuf字段 + """ + return self.post( + 'SendMsg', + { + "toUser": user, + "sendToType": 1, + "sendMsgType": "ForwordMsg", + "forwordBuf": forwordBuf, + "forwordField": 19, + }, + ) + ############获取############ def getCookies(self) -> dict: """获取QQ相关cookie""" return self.get('GetUserCook') - def getUserInfo(self, UserID: int) -> dict: + def getUserInfo(self, user: int) -> dict: """获取任意用户信息昵称头像等""" - return self.post('GetUserInfo', {'UserID': UserID}) + return self.post('GetUserInfo', {'UserID': user}) def getUserList(self) -> List[dict]: # FIXME: 目前只适用于好友较少一次获取就可以的情况,好友较多需要循环获取 """获取好友列表""" @@ -350,7 +382,7 @@ def getGroupMembers(self, group: int) -> List[dict]: if 'LastUin' not in data or data['LastUin'] == 0: break lastUin = data['LastUin'] - time.sleep(0.5) + time.sleep(0.6) return members def getGroupAdminList(self, group: int, include_owner=True) -> List[dict]: @@ -511,6 +543,16 @@ def driveUserAway(self, group: int, user: int) -> dict: {"ActionType": 3, "GroupID": group, "ActionUserID": user, "Content": ""}, ) + def refreshKeys(self) -> dict: + """刷新key二次登陆""" + return self.get('', path='/v1/RefreshKeys') + + def logout(self, flag=False) -> bool: + """退出指定QQ + :param flag: 是否删除设备信息文件 + """ + return self.post('LogOut', {"Flag": flag}) + ############################################################################ def baseRequest( self, diff --git a/docs/action.md b/docs/action.md index 87a362bd..c23258a7 100644 --- a/docs/action.md +++ b/docs/action.md @@ -94,16 +94,15 @@ port 和 host 的含义和 Botoy 实例中的一致 | driveUserAway | 移出群聊 | | getClusterInfo | 获取当前集群信息 | | | 搜索群组 | -| | 获取包括群主在内的所有管理员列表 | -| | 刷新 key 二次登陆 | +| refreshKeys | 刷新 key 二次登陆 | | | 添加好友 | | | 处理好友请求 | -| | 退出 qq | +| logout | 退出指定 qq | | | 获取登录二维码的 base64 编码 | | | 获取好友文件下载链接 | | | 获取群文件下载链接 | -| | 转发视频到群聊 | -| | 转发视频给好友 | +| repostVideo2Group | 转发视频到群聊 | +| repostVideo2Friend | 转发视频给好友 | - 除特殊说明,API 返回的都是字典类型,如果出错则返回空字典 - 没有方法名的表示还未封装,说明前面带\*号的表示还不完善