Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mirai-core-api/src/commonMain/kotlin/message/action/Nudge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 事件
*/
Expand Down
4 changes: 2 additions & 2 deletions mirai-core/src/commonMain/kotlin/MiraiImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down