允许使用 IPAD 协议发送戳一戳 (#1711)

* 修改注释

* IPAD协议发送戳一戳时不抛出UnsupportedOperationException

* 修改注释

“安卓协议”的描述并不准确,ANDROID_PAD 也是安卓协议,但是完全不支持戳一戳
修改进行明确

* Apply suggestions from code review

* Update Nudge.kt

Co-authored-by: Initial-heart <63091661+Initial-heart-1@users.noreply.github.com>
Co-authored-by: Him188 <Him188@mamoe.net>
This commit is contained in:
LaoLittle 2022-01-06 09:16:42 +08:00 committed by GitHub
parent d14261d5b0
commit 0c964f3144
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -38,11 +38,11 @@ public sealed class Nudge {
/**
* 发送戳一戳消息到 [receiver].
*
* 需要 [使用协议][BotConfiguration.protocol] [MiraiProtocol.ANDROID_PHONE].
* 需要使用支持的[协议][BotConfiguration.protocol] [MiraiProtocol.ANDROID_PHONE] [MiraiProtocol.IPAD]. 2.10 起才支持使用 IPAD 协议发送.
*
* @param receiver 这条 "戳一戳" 消息的接收对象. (不是 "" 动作的对象, 而是接收 "A 戳了 B" 这条消息的对象)
* @return 成功发送时为 `true`. 若对方禁用 "戳一戳" 功能, 返回 `false`.
* @throws UnsupportedOperationException 当未使用 [安卓协议][MiraiProtocol.ANDROID_PHONE] 时抛出
* @throws UnsupportedOperationException 当未使用 [ANDROID_PHONE 协议][MiraiProtocol.ANDROID_PHONE] [IPAD 协议][MiraiProtocol.IPAD] 时抛出
*
* @see NudgeEvent 事件
* @see Contact.sendNudge
@ -57,11 +57,11 @@ public sealed class Nudge {
/**
* 发送戳一戳消息.
*
* 需要 [使用协议][BotConfiguration.protocol] [MiraiProtocol.ANDROID_PHONE].
* 需要使用支持的[协议][BotConfiguration.protocol] [MiraiProtocol.ANDROID_PHONE] [MiraiProtocol.IPAD]. 2.10 起才支持使用 IPAD 协议发送.
*
* @return 成功发送时为 `true`. 若对方禁用 "戳一戳" 功能, 返回 `false`.
*
* @throws UnsupportedOperationException 当未使用 [安卓协议][MiraiProtocol.ANDROID_PHONE] 时抛出
* @throws UnsupportedOperationException 当未使用 [ANDROID_PHONE 协议][MiraiProtocol.ANDROID_PHONE] [IPAD 协议][MiraiProtocol.IPAD] 时抛出
*
* @see NudgeEvent 事件
*/

View File

@ -781,8 +781,8 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
}
override suspend fun sendNudge(bot: Bot, nudge: Nudge, receiver: Contact): Boolean {
if (bot.configuration.protocol != BotConfiguration.MiraiProtocol.ANDROID_PHONE) {
throw UnsupportedOperationException("nudge is supported only with protocol ANDROID_PHONE")
if ((bot.configuration.protocol != BotConfiguration.MiraiProtocol.ANDROID_PHONE) && (bot.configuration.protocol != BotConfiguration.MiraiProtocol.IPAD)) {
throw UnsupportedOperationException("nudge is supported only with protocol ANDROID_PHONE or IPAD")
}
bot.asQQAndroidBot()