From 8451fabe5d54aa257e96e76b84eff8a324a92334 Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 30 Jan 2020 23:49:43 +0800 Subject: [PATCH] Add response check --- .../net/mamoe/mirai/qqandroid/ContactImpl.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt index 3d26048fd..d0f50beff 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt @@ -18,7 +18,13 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin override suspend fun sendMessage(message: MessageChain) { bot.network.run { - MessageSvc.PbSendMsg.ToFriend(bot.client, id, message).sendAndExpect() + check( + MessageSvc.PbSendMsg.ToFriend( + bot.client, + id, + message + ).sendAndExpect() is MessageSvc.PbSendMsg.Response.SUCCESS + ) { "send message failed" } } } @@ -90,7 +96,15 @@ internal class GroupImpl(bot: QQAndroidBot, override val coroutineContext: Corou override val bot: QQAndroidBot by bot.unsafeWeakRef() override suspend fun sendMessage(message: MessageChain) { - TODO("not implemented") + bot.network.run { + check( + MessageSvc.PbSendMsg.ToGroup( + bot.client, + id, + message + ).sendAndExpect() is MessageSvc.PbSendMsg.Response.SUCCESS + ) { "send message failed" } + } } override suspend fun uploadImage(image: ExternalImage): ImageId {