Skip to content

Commit 0c964f3

Browse files
LaoLittleInitial-heart-1Him188
authored
允许使用 IPAD 协议发送戳一戳 (#1711)
* 修改注释 * IPAD协议发送戳一戳时不抛出UnsupportedOperationException * 修改注释 “安卓协议”的描述并不准确,ANDROID_PAD 也是安卓协议,但是完全不支持戳一戳 修改进行明确 * Apply suggestions from code review * Update Nudge.kt Co-authored-by: Initial-heart <[email protected]> Co-authored-by: Him188 <[email protected]>
1 parent d14261d commit 0c964f3

File tree

2 files changed

+6
-6
lines changed
  • mirai-core/src/commonMain/kotlin
  • mirai-core-api/src/commonMain/kotlin/message/action

2 files changed

+6
-6
lines changed

mirai-core-api/src/commonMain/kotlin/message/action/Nudge.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public sealed class Nudge {
3838
/**
3939
* 发送戳一戳消息到 [receiver].
4040
*
41-
* 需要 [使用协议][BotConfiguration.protocol] [MiraiProtocol.ANDROID_PHONE].
41+
* 需要使用支持的[协议][BotConfiguration.protocol] [MiraiProtocol.ANDROID_PHONE] 或 [MiraiProtocol.IPAD]. 自 2.10 起才支持使用 IPAD 协议发送.
4242
*
4343
* @param receiver 这条 "戳一戳" 消息的接收对象. (不是 "戳" 动作的对象, 而是接收 "A 戳了 B" 这条消息的对象)
4444
* @return 成功发送时为 `true`. 若对方禁用 "戳一戳" 功能, 返回 `false`.
45-
* @throws UnsupportedOperationException 当未使用 [安卓协议][MiraiProtocol.ANDROID_PHONE] 时抛出
45+
* @throws UnsupportedOperationException 当未使用 [ANDROID_PHONE 协议][MiraiProtocol.ANDROID_PHONE] 或 [IPAD 协议][MiraiProtocol.IPAD] 时抛出
4646
*
4747
* @see NudgeEvent 事件
4848
* @see Contact.sendNudge
@@ -57,11 +57,11 @@ public sealed class Nudge {
5757
/**
5858
* 发送戳一戳消息.
5959
*
60-
* 需要 [使用协议][BotConfiguration.protocol] [MiraiProtocol.ANDROID_PHONE].
60+
* 需要使用支持的[协议][BotConfiguration.protocol] [MiraiProtocol.ANDROID_PHONE] 或 [MiraiProtocol.IPAD]. 自 2.10 起才支持使用 IPAD 协议发送.
6161
*
6262
* @return 成功发送时为 `true`. 若对方禁用 "戳一戳" 功能, 返回 `false`.
6363
*
64-
* @throws UnsupportedOperationException 当未使用 [安卓协议][MiraiProtocol.ANDROID_PHONE] 时抛出
64+
* @throws UnsupportedOperationException 当未使用 [ANDROID_PHONE 协议][MiraiProtocol.ANDROID_PHONE] 或 [IPAD 协议][MiraiProtocol.IPAD] 时抛出
6565
*
6666
* @see NudgeEvent 事件
6767
*/

mirai-core/src/commonMain/kotlin/MiraiImpl.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
781781
}
782782

783783
override suspend fun sendNudge(bot: Bot, nudge: Nudge, receiver: Contact): Boolean {
784-
if (bot.configuration.protocol != BotConfiguration.MiraiProtocol.ANDROID_PHONE) {
785-
throw UnsupportedOperationException("nudge is supported only with protocol ANDROID_PHONE")
784+
if ((bot.configuration.protocol != BotConfiguration.MiraiProtocol.ANDROID_PHONE) && (bot.configuration.protocol != BotConfiguration.MiraiProtocol.IPAD)) {
785+
throw UnsupportedOperationException("nudge is supported only with protocol ANDROID_PHONE or IPAD")
786786
}
787787
bot.asQQAndroidBot()
788788

0 commit comments

Comments
 (0)