Skip to content

Commit

Permalink
feat(action): reply msg
Browse files Browse the repository at this point in the history
  • Loading branch information
xiyaowong committed Oct 18, 2020
1 parent 04f1570 commit 6affc44
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 2 deletions.
2 changes: 1 addition & 1 deletion botoy/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.4'
__version__ = '0.0.5'
67 changes: 67 additions & 0 deletions botoy/action.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
import traceback
from typing import List, Union

Expand Down Expand Up @@ -247,6 +248,72 @@ def sendPhoneText(self, content: str):
{"SendToType": 2, "SendMsgType": "PhoneMsg", "Content": content},
)

def replyGroupMsg(
self,
group: int,
content: str,
msgSeq: int,
msgTime: int = None,
user: int = 0,
rawContent: str = '',
):
"""发送回复消息, 回复群消息
下面的原消息表示需要回复的消息
:param group: 原消息的群号
:param content: 回复内容
:param msgSeq: 原消息的msgSeq, 点击跳转到该条消息位置
:param msgTime: 原消息的msgTime, 如果不指定,默认为当前时间戳
:param user: 原消息的人的qq号,也可以是其他人,该用户收到消息会提示“有新回复”, 默认为0
:param rawContent: 原消息内容,可以任意指定,默认为空
"""
return self.post(
"SendMsg",
{
"toUser": group,
"sendToType": 2,
"sendMsgType": "ReplayMsg",
"content": content,
"replayInfo": {
"MsgSeq": msgSeq,
"MsgTime": msgTime or int(time.time()),
"UserID": user,
"RawContent": rawContent,
},
},
)

def replyFriendMsg(
self,
user: int,
content: str,
msgSeq: int,
msgTime: int = None,
rawContent: str = '',
):
"""发送回复消息, 回复好友消息
下面的原消息表示需要回复的消息
:param user: 原消息发送人
:param content: 回复内容
:param msgSeq: 原消息的msgSeq, 点击跳转到该条消息位置
:param msgTime: 原消息的msgTime, 如果不指定,默认为当前时间戳
:param rawContent: 原消息内容,可以任意指定,默认为空
"""
return self.post(
"SendMsg",
{
"toUser": user,
"sendToType": 1,
"sendMsgType": "ReplayMsg",
"content": content,
"replayInfo": {
"MsgSeq": msgSeq,
"MsgTime": msgTime or int(time.time()),
"UserID": user,
"RawContent": rawContent,
},
},
)

############获取############
def getCookies(self):
"""获取QQ相关cookie"""
Expand Down
67 changes: 67 additions & 0 deletions botoy/async_action.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
import traceback
from typing import List, Union

Expand Down Expand Up @@ -247,6 +248,72 @@ async def sendPhoneText(self, content: str) -> dict:
{"SendToType": 2, "SendMsgType": "PhoneMsg", "Content": content},
)

async def replyGroupMsg(
self,
group: int,
content: str,
msgSeq: int,
msgTime: int = None,
user: int = 0,
rawContent: str = '',
):
"""发送回复消息, 回复群消息
下面的原消息表示需要回复的消息
:param group: 原消息的群号
:param content: 回复内容
:param msgSeq: 原消息的msgSeq, 点击跳转到该条消息位置
:param msgTime: 原消息的msgTime, 如果不指定,默认为当前时间戳
:param user: 原消息的人的qq号,也可以是其他人,该用户收到消息会提示“有新回复”, 默认为0
:param rawContent: 原消息内容,可以任意指定,默认为空
"""
return await self.post(
"SendMsg",
{
"toUser": group,
"sendToType": 2,
"sendMsgType": "ReplayMsg",
"content": content,
"replayInfo": {
"MsgSeq": msgSeq,
"MsgTime": msgTime or int(time.time()),
"UserID": user,
"RawContent": rawContent,
},
},
)

async def replyFriendMsg(
self,
user: int,
content: str,
msgSeq: int,
msgTime: int = None,
rawContent: str = '',
):
"""发送回复消息, 回复好友消息
下面的原消息表示需要回复的消息
:param user: 原消息发送人
:param content: 回复内容
:param msgSeq: 原消息的msgSeq, 点击跳转到该条消息位置
:param msgTime: 原消息的msgTime, 如果不指定,默认为当前时间戳
:param rawContent: 原消息内容,可以任意指定,默认为空
"""
return await self.post(
"SendMsg",
{
"toUser": user,
"sendToType": 1,
"sendMsgType": "ReplayMsg",
"content": content,
"replayInfo": {
"MsgSeq": msgSeq,
"MsgTime": msgTime or int(time.time()),
"UserID": user,
"RawContent": rawContent,
},
},
)

async def setUniqueTitle(self, user: int, group: int, title: str):
"""设置群头衔"""
return await self.post(
Expand Down
2 changes: 1 addition & 1 deletion botoy/decorators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""一些用于接收函数的装饰器"""
from ._ensure_tempMsg import ensure_tempMsg
from ._equal_content import equal_content
from ._from_botself import from_botself
from ._from_these_groups import from_these_groups
Expand All @@ -10,4 +11,3 @@
from ._startswith import startswith
from ._these_msgtypes import these_msgtypes
from ._with_pattern import with_pattern
from ._ensure_tempMsg import ensure_tempMsg
2 changes: 2 additions & 0 deletions docs/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ port 和 host 的含义和 Botoy 实例中的一致
| setGroupAnnounce | 设置群公告 |
| toggleGroupAdmin | 设置或取消群管理员 |
| revokeGroupMsg | 撤回群消息 |
| replyGroupMsg | 发送回复消息,回复群消息 |
| replyFriendMsg | 发送回复消息,回复好友消息,不好用 |
| | 搜索群组 |
| | 获取群管理列表 |
| | 获取包括群主在内的所有管理员列表 |
Expand Down

0 comments on commit 6affc44

Please sign in to comment.