mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-17 05:29:25 +08:00
Add low level APIs for recalling message
This commit is contained in:
parent
a7dabd63aa
commit
564c961d3f
@ -11,10 +11,7 @@ package net.mamoe.mirai
|
||||
|
||||
import kotlinx.coroutines.Job
|
||||
import net.mamoe.kjbb.JvmBlockingBridge
|
||||
import net.mamoe.mirai.contact.AnonymousMember
|
||||
import net.mamoe.mirai.contact.Friend
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.Stranger
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.data.*
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.WeakRef
|
||||
@ -58,6 +55,48 @@ public interface LowLevelApiAccessor {
|
||||
@LowLevelApi
|
||||
public fun newStranger(bot: Bot, strangerInfo: StrangerInfo): Stranger
|
||||
|
||||
/**
|
||||
* 撤回这条消息. 不会广播事件, 不会有安全性检查.
|
||||
* @see recallMessage
|
||||
*/
|
||||
@LowLevelApi
|
||||
@JvmBlockingBridge
|
||||
public suspend fun recallGroupMessageRaw(
|
||||
bot: Bot,
|
||||
groupCode: Long,
|
||||
messageIds: IntArray,
|
||||
messageInternalIds: IntArray,
|
||||
): Boolean
|
||||
|
||||
/**
|
||||
* 撤回这条消息. 不会广播事件, 不会有安全性检查.
|
||||
* @see recallMessage
|
||||
*/
|
||||
@LowLevelApi
|
||||
@JvmBlockingBridge
|
||||
public suspend fun recallFriendMessageRaw(
|
||||
bot: Bot,
|
||||
targetId: Long,
|
||||
messageIds: IntArray,
|
||||
messageInternalIds: IntArray,
|
||||
time: Int,
|
||||
): Boolean
|
||||
|
||||
/**
|
||||
* 撤回这条消息. 不会广播事件, 不会有安全性检查.
|
||||
* @see recallMessage
|
||||
*/
|
||||
@LowLevelApi
|
||||
@JvmBlockingBridge
|
||||
public suspend fun recallGroupTempMessageRaw(
|
||||
bot: Bot,
|
||||
groupUin: Long,
|
||||
targetId: Long,
|
||||
messageIds: IntArray,
|
||||
messageInternalIds: IntArray,
|
||||
time: Int,
|
||||
): Boolean
|
||||
|
||||
/**
|
||||
* 向服务器查询群列表. 返回值高 32 bits 为 uin, 低 32 bits 为 groupCode
|
||||
*/
|
||||
|
@ -331,6 +331,66 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
|
||||
return sequence
|
||||
}
|
||||
|
||||
override suspend fun recallGroupMessageRaw(
|
||||
bot: Bot,
|
||||
groupCode: Long,
|
||||
messageIds: IntArray,
|
||||
messageInternalIds: IntArray,
|
||||
): Boolean = bot.asQQAndroidBot().run {
|
||||
val response = network.run {
|
||||
PbMessageSvc.PbMsgWithDraw.createForGroupMessage(
|
||||
client,
|
||||
groupCode,
|
||||
messageIds,
|
||||
messageInternalIds
|
||||
).sendAndExpect<PbMessageSvc.PbMsgWithDraw.Response>()
|
||||
}
|
||||
|
||||
response is PbMessageSvc.PbMsgWithDraw.Response.Success
|
||||
}
|
||||
|
||||
override suspend fun recallFriendMessageRaw(
|
||||
bot: Bot,
|
||||
targetId: Long,
|
||||
messageIds: IntArray,
|
||||
messageInternalIds: IntArray,
|
||||
time: Int,
|
||||
): Boolean = bot.asQQAndroidBot().run {
|
||||
val response = network.run {
|
||||
PbMessageSvc.PbMsgWithDraw.createForFriendMessage(
|
||||
client,
|
||||
targetId,
|
||||
messageIds,
|
||||
messageInternalIds,
|
||||
time,
|
||||
).sendAndExpect<PbMessageSvc.PbMsgWithDraw.Response>()
|
||||
}
|
||||
|
||||
response is PbMessageSvc.PbMsgWithDraw.Response.Success
|
||||
}
|
||||
|
||||
override suspend fun recallGroupTempMessageRaw(
|
||||
bot: Bot,
|
||||
groupUin: Long,
|
||||
targetId: Long,
|
||||
messageIds: IntArray,
|
||||
messageInternalIds: IntArray,
|
||||
time: Int
|
||||
): Boolean = bot.asQQAndroidBot().run {
|
||||
val response = network.run {
|
||||
PbMessageSvc.PbMsgWithDraw.createForTempMessage(
|
||||
client,
|
||||
groupUin,
|
||||
targetId,
|
||||
messageIds,
|
||||
messageInternalIds,
|
||||
time,
|
||||
).sendAndExpect<PbMessageSvc.PbMsgWithDraw.Response>()
|
||||
}
|
||||
|
||||
response is PbMessageSvc.PbMsgWithDraw.Response.Success
|
||||
}
|
||||
|
||||
@Suppress("RemoveExplicitTypeArguments") // false positive
|
||||
override suspend fun recallMessage(bot: Bot, source: MessageSource) = bot.asQQAndroidBot().run {
|
||||
check(source is MessageSourceInternal)
|
||||
|
Loading…
Reference in New Issue
Block a user