Skip to content

Commit 7251769

Browse files
committed
send group temp member message support
1 parent 1d190de commit 7251769

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

overflow-core/src/main/kotlin/cn/evolvefield/onebot/client/core/Bot.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class Bot(
9292
* 发送私聊消息
9393
*
9494
* @param userId 对方 QQ 号
95+
* @param groupId 主动发起临时会话时的来源群号 (可选,机器人本身必须是管理员/群主)
9596
* @param msg 要发送的内容,请使用CQ码或json数组消息
9697
* @param autoEscape 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
9798
* @param context Onebot 主动操作的上下文
@@ -101,13 +102,15 @@ class Bot(
101102
@JvmOverloads
102103
suspend fun sendPrivateMsg(
103104
userId: Long,
105+
groupId: Long?,
104106
msg: String,
105107
autoEscape: Boolean,
106108
context: Context = {},
107109
): ActionData<MsgId> {
108110
val action = context.build(ActionPathEnum.SEND_PRIVATE_MSG)
109111
val params = JsonObject()
110112
params.addProperty("user_id", userId)
113+
if (groupId != null) params.addProperty("group_id", groupId)
111114
params.addMessage("message", msg)
112115
params.addProperty("auto_escape", autoEscape)
113116
val result = actionHandler.action(this, action, params)

overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/FriendWrapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ internal class FriendWrapper(
9696
}
9797

9898
override suspend fun sendToOnebot(message: String): MsgId? {
99-
val resp = bot.impl.sendPrivateMsg(id, message, false) {
99+
val resp = bot.impl.sendPrivateMsg(id, null, message, false) {
100100
throwExceptions(true)
101101
}
102102
return resp.data

overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/MemberWrapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ internal class MemberWrapper(
204204
}
205205

206206
override suspend fun sendToOnebot(message: String): MsgId? {
207-
val resp = bot.impl.sendPrivateMsg(id, message, false) {
207+
val resp = bot.impl.sendPrivateMsg(id, group.id, message, false) {
208208
throwExceptions(true)
209209
}
210210
return resp.data

overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/StrangerWrapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ internal class StrangerWrapper(
7777
}
7878

7979
override suspend fun sendToOnebot(message: String): MsgId? {
80-
val resp = bot.impl.sendPrivateMsg(id, message, false) {
80+
val resp = bot.impl.sendPrivateMsg(id, null, message, false) {
8181
throwExceptions(true)
8282
}
8383
return resp.data

0 commit comments

Comments
 (0)