-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
Milestone
Description
问题描述
ANDROID_PAD协议是可以发出戳一戳信息的
问题来源
当Bot尝试在ANDROID_PAD协议下戳一戳时
mirai/mirai-core/src/commonMain/kotlin/MiraiImpl.kt
Lines 646 to 651 in fca4a3c
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=的�纸儿)
因此我认为在Mirai中,ANDROID_PAD也应该支持戳一戳信息
复现
- 使用ANDROID_PAD协议登录Mirai
- 让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