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

ANDROID_PAD应支持发出戳一戳信息 #2771

Closed
EvolvedGhost opened this issue Aug 6, 2023 · 0 comments
Closed

ANDROID_PAD应支持发出戳一戳信息 #2771

EvolvedGhost opened this issue Aug 6, 2023 · 0 comments
Labels
N 优先级: 一般 s:core 子系统: mirai-core t:feature 类型: 新特性
Milestone

Comments

@EvolvedGhost
Copy link

EvolvedGhost commented Aug 6, 2023

问题描述

ANDROID_PAD协议是可以发出戳一戳信息的

问题来源

当Bot尝试在ANDROID_PAD协议下戳一戳时

override suspend fun sendNudge(bot: Bot, nudge: Nudge, receiver: Contact): Boolean {
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()

这一行代码阻止了非Ipad和手机QQ的戳一戳信息,但实际上8.9版本后的安卓平板QQ和安卓手机QQ其实并无什么差异(目前Mirai内置的ANDROID_PAD协议版本号为8.9.58,本人测试环境目前使用fix-protocol-version的ANDROID_PAD 8.9.63 协议),安卓平板上也能够正常使用戳一戳

于是客户端就会报错:

2023-08-07 01:XX:XX W/Bot.*****: An exception occurred when processing event. Subscriber scope: '<unnamed>'. Broadcaster scope: 'Bot *****.EventDispatcher'
java.lang.UnsupportedOperationException: nudge is supported only with protocol ANDROID_PHONE or IPAD
        at net.mamoe.mirai.internal.MiraiImpl.sendNudge$suspendImpl(MiraiImpl.kt:648)
        at net.mamoe.mirai.internal.MiraiImpl.sendNudge(MiraiImpl.kt)
        at net.mamoe.mirai.message.action.Nudge.sendTo(Nudge.kt:55)
        at net.mamoe.mirai.message.action.Nudge$sendTo$2.invoke(Nudge.kt)
        at net.mamoe.mirai.message.action.Nudge$sendTo$2.invoke(Nudge.kt)

尝试解决

我将以上代码改为了如下:

    override suspend fun sendNudge(bot: Bot, nudge: Nudge, receiver: Contact): Boolean {
        println(bot.configuration.protocol)

        if ((bot.configuration.protocol != BotConfiguration.MiraiProtocol.ANDROID_PHONE)
            && (bot.configuration.protocol != BotConfiguration.MiraiProtocol.IPAD)
            && (bot.configuration.protocol != BotConfiguration.MiraiProtocol.ANDROID_PAD))
        {
            throw UnsupportedOperationException("nudge is supported only with protocol ANDROID_PHONE or IPAD")
        }

        bot.asQQAndroidBot()

此时Bot是可以正常发出戳一戳信息的

2023-08-07 02:00:18 V/Bot.*****: [GROUP_NAME(7****)] USER_NAME(1*****) -> 拍
2023-08-07 02:00:18 I/stdout: ANDROID_PAD
2023-08-07 02:00:18 V/Bot.*****: Event: NudgeEvent(from=Bot(*****), target=NormalMember(1*****), subject=Group(736615843), acti
on=舔了舔, suffix=的�纸儿)
2023-08-07 02:00:18 V/Bot.*****: [GROUP_NAME(7****)] USER_NAME(1*****) -> 拍
2023-08-07 02:00:18 I/stdout: ANDROID_PAD
2023-08-07 02:00:19 V/Bot.*****: Event: NudgeEvent(from=Bot(*****), target=NormalMember(1*****), subject=Group(736615843), acti
on=舔了舔, suffix=的�纸儿)

72e516b008fe8250528c7c86fb55da8c

因此我认为在Mirai中,ANDROID_PAD也应该支持戳一戳信息

复现

  1. 使用ANDROID_PAD协议登录Mirai
  2. 让Bot触发戳一戳

mirai-core 版本

2.15.0

bot-protocol

ANDROID_PAD

其他组件版本

mirai-console: 2.15.0
fix-protocol-version: 1.9.10
PetPet: 5.4

系统日志

No response

网络日志

No response

补充信息

No response

@Him188 Him188 added t:feature 类型: 新特性 N 优先级: 一般 s:core 子系统: mirai-core labels Aug 6, 2023
@Him188 Him188 added this to the Backlog milestone Aug 6, 2023
@StageGuard StageGuard modified the milestones: Backlog, 2.16.0-RC Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
N 优先级: 一般 s:core 子系统: mirai-core t:feature 类型: 新特性
Projects
None yet
Development

No branches or pull requests

3 participants