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

OneBotPokeEvent及其它戳一戳事件无法监听私聊戳一戳,Field 'group_id' is required for type with serial name 'love.forte.simbot.component.onebot.v11.event.notice.RawNotifyEvent', but it was missing #928

Closed
xiao200301 opened this issue Aug 27, 2024 · 2 comments · Fixed by simple-robot/simbot-component-onebot#99
Assignees
Labels
组件:OneBot 与 OneBot 组件相关 缺陷 一些存在不影响正常结果的缺陷

Comments

@xiao200301
Copy link

是否会提供贡献?

版本号

4.5.0

附加版本

love.forte.simbot simbot-core-jvm 4.5.0 love.forte.simbot simbot-core-spring-boot-starter 4.5.0 love.forte.simbot.component simbot-component-onebot-v11-core-jvm 1.1.0 io.ktor ktor-client-okhttp-jvm 2.3.12 runtime org.jetbrains.kotlinx kotlinx-serialization-json 1.7.1

涉及的编程语言

Java

项目构建工具

Maven

涉及的组件库

OneBot

问题描述

问题描述:服务端使用的napcat,监听群聊成员离开的方法可以正常监听,无论是踢的还是主动离开的成员,但是监听群聊成员添加无法监听,直接报错

复现方式

/**
* 监听群聊群成员添加
/
@Listener
public void listeningMemberIncrease(OneBotGroupMemberIncreaseEvent event) {
event.getContent().sendAsync(event.getUserId() + "已加入群聊");
}
/
*
* 监听群聊群成员离开
*/
@Listener
public void listeningMemberDecrease(OneBotGroupMemberDecreaseEvent event) {
event.getContent().sendAsync(event.getUserId() + "已退出群聊");
}

相关日志

2024-08-27T12:45:11.491+08:00 ERROR 3476 --- [atcher-worker-6] l.f.s.c.o.v.c.bot.OneBotBot.3879759045   : Received raw event '{"time":1724733912,"self_id":3879759045,"post_type":"notice","notice_type":"notify","sub_type":"poke","target_id":3879759045,"user_id":3045302701,"raw_info":[{"col":"1","nm":"","type":"qq","uid":"u_NSg7VcsJL8bimdCICVKypg"},{"col":"1","nm":"","tp":"0","type":"qq","uid":"u_pu3x_VjKJMNnhMPQ0lkJCw"}]}' decode failed because of serialization: Field 'group_id' is required for type with serial name 'love.forte.simbot.component.onebot.v11.event.notice.RawNotifyEvent', but it was missingIt will be pushed as an UnknownEvent

kotlinx.serialization.MissingFieldException: Field 'group_id' is required for type with serial name 'love.forte.simbot.component.onebot.v11.event.notice.RawNotifyEvent', but it was missing
	at kotlinx.serialization.internal.PluginExceptionsKt.throwMissingFieldException(PluginExceptions.kt:20) ~[kotlinx-serialization-core-jvm-1.7.1.jar:1.7.1]
	at love.forte.simbot.component.onebot.v11.event.notice.RawNotifyEvent.<init>(RawNotifyEvent.kt:44) ~[simbot-component-onebot-v11-event-jvm-1.1.0.jar:na]
	at love.forte.simbot.component.onebot.v11.event.notice.RawNotifyEvent$$serializer.deserialize(RawNotifyEvent.kt:44) ~[simbot-component-onebot-v11-event-jvm-1.1.0.jar:na]
	at love.forte.simbot.component.onebot.v11.event.notice.RawNotifyEvent$$serializer.deserialize(RawNotifyEvent.kt:44) ~[simbot-component-onebot-v11-event-jvm-1.1.0.jar:na]
	at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeSerializableValue(TreeJsonDecoder.kt:337) ~[kotlinx-serialization-json-jvm-1.7.1.jar:na]
	at kotlinx.serialization.json.internal.TreeJsonDecoderKt.readJson(TreeJsonDecoder.kt:26) ~[kotlinx-serialization-json-jvm-1.7.1.jar:na]
	at kotlinx.serialization.json.Json.decodeFromJsonElement(Json.kt:186) ~[kotlinx-serialization-json-jvm-1.7.1.jar:na]
	at love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImplKt.resolveRawEvent(OneBotBotImpl.kt:682) ~[simbot-component-onebot-v11-core-jvm-1.1.0.jar:na]
	at love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl$WsEventSession.receiveEvent(OneBotBotImpl.kt:486) ~[simbot-component-onebot-v11-core-jvm-1.1.0.jar:na]
	at love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl$WsEventSession.access$receiveEvent(OneBotBotImpl.kt:303) ~[simbot-component-onebot-v11-core-jvm-1.1.0.jar:na]
	at love.forte.simbot.component.onebot.v11.core.bot.internal.OneBotBotImpl$WsEventSession$receiveEvent$1.invokeSuspend(OneBotBotImpl.kt) ~[simbot-component-onebot-v11-core-jvm-1.1.0.jar:na]
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-2.0.0.jar:2.0.0-release-341]
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:na]

其他补充

No response

@xiao200301 xiao200301 added the bug? 疑似为bug、存在普遍性问题、待确认 label Aug 27, 2024
@ForliyScarlet ForliyScarlet added the 等待确认 等待负责人员的确认 label Aug 27, 2024
@ForteScarlet ForteScarlet added 缺陷 一些存在不影响正常结果的缺陷 组件:OneBot 与 OneBot 组件相关 and removed bug? 疑似为bug、存在普遍性问题、待确认 等待确认 等待负责人员的确认 labels Aug 27, 2024
@ForteScarlet
Copy link
Member

你的问题描述与复现代码似乎跟标题和相关日志并无关联,还是说是会在新成员加入群聊时收到一个没有 group_id 的戳一戳事件

@xiao200301
Copy link
Author

你的问题描述与复现代码似乎跟标题和相关日志并无关联,还是说是会在新成员加入群聊时收到一个没有 group_id 的戳一戳事件

弄错了,代码是这个:
/**
* 监听机器人被戳一戳
*/
@Listener
public void listeningBotSelfPoke(OneBotBotSelfPokeEvent event) {
OneBotBot bot = event.getBot();
String botId = bot.getId().toString();
if (botId.equals(event.getTargetId().toString())) {
OneBotGroup group = bot.getGroupRelation().getGroup(event.getGroupId());
group.sendAsync(Messages.builder().add("疼~").build());
}
}

是在和机器人的私聊中,戳一戳机器人会收到一个没有group_id的戳一戳事件导致报错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
组件:OneBot 与 OneBot 组件相关 缺陷 一些存在不影响正常结果的缺陷
Projects
None yet
3 participants