GithubHelp home page GithubHelp logo

simple-robot / simbot-component-qq-guild Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 1.0 10.84 MB

一个基于 Kotlin 协程对QQ频道机器人API 进行实现的 API/SDK Kotlin 多平台库,Java 友好、高效异步,同时也是 Simple Robot 的组件库实现之一 😻😻😽

Home Page: http://component-qqguild.simbot.forte.love/

License: GNU Lesser General Public License v3.0

Kotlin 96.86% CSS 0.85% JavaScript 1.60% Java 0.58% HTML 0.11%
simbot simple-robot tencent qq kotlin qq-guild qqguild qqguildbot qq-bot qq-guild-bot

simbot-component-qq-guild's People

Contributors

dependabot[bot] avatar forliyscarlet avatar fortescarlet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hanhuafeng

simbot-component-qq-guild's Issues

没有支持multipart/form-data消息发送

官方API发送消息的接口支持,multipart/form-data file_image | file | 图片文件。form-data 支持直接通过文件上传的方式发送图片。
查看了一下本项目的 simbot-component-tencent-guild-api模块,在发送普通消息中没有实现,希望补充一下

为 `QGBot` 增加直接获取 `channel` 和直接发送消息的API

用于避免 bot 没有获取 guild 信息或 channel 信息而导致无法获取对应对象而无法发送消息的情况。

比如

val bot: QGBot = ...

val channel = bot.channel(channelId  = 1234567.ID) // 直接获取 channel

bot.sendTo(message, channelId = 1234567.ID) // 直接发送消息

这两种API可以 “绕过” 获取对象——也就是绕过获取频道/子频道详情而直接发送消息。

发送私信消息产生 `kotlinx.serialization.MissingFieldException` 异常

2023-06-01 15:09:21.040 DEBUG [DefaultDispatcher-worker-10] l.f.s.q.api.doRequestRaw$suspendImpl(226): [  POST /dms/4269654995097611668/messages] <===== status: 202 Accepted, body: {"code":304023,"message":"push message is waiting for audit now","data":{"message_audit":{"audit_id":"50db3d4b-xxxx-xxxx-xxxx-75e5532262ba"}}}

实际得到的响应:

{
	"code": 304023,
	"message": "push message is waiting for audit now",
	"data": {
		"message_audit": {
			"audit_id": "50db3d4b-9589-4497-9a1e-75e5532262ba"
		}
	}
}

完善事件同步

目前根据事件对内部实例缓存的机制尚不完善,可能存在一些预期内的错误

Unknown reason, bot will be closed

2023-04-29T01:22:59.628+08:00 ERROR 2482376 --- [tcher-worker-10] love.forte.simbot.qguild.bot.x : Unknown reason, bot will be closed

kotlinx.coroutines.channels.ClosedReceiveChannelException: Channel was closed
        at kotlinx.coroutines.channels.Closed.getReceiveException(AbstractChannel.kt:1108) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.channels.AbstractChannel$ReceiveElement.resumeReceiveClosed(AbstractChannel.kt:913) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.channels.AbstractSendChannel.helpClose(AbstractChannel.kt:342) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.channels.AbstractSendChannel.close(AbstractChannel.kt:271) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.channels.SendChannel$DefaultImpls.close$default(Channel.kt:93) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at io.ktor.websocket.DefaultWebSocketSessionImpl$runIncomingProcessor$1.invokeSuspend(DefaultWebSocketSession.kt:215) ~[ktor-websockets-jvm-2.2.3.jar!/:2.2.3]
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.8.10.jar!/:1.8.10-release-430(1.8.10)]
        at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:234) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:190) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:161) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.CancellableContinuationImpl.completeResume(CancellableContinuationImpl.kt:513) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.channels.AbstractChannel$ReceiveHasNext.resumeReceiveClosed(AbstractChannel.kt:958) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.channels.AbstractSendChannel.helpClose(AbstractChannel.kt:342) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.channels.AbstractSendChannel.close(AbstractChannel.kt:271) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.channels.SendChannel$DefaultImpls.close$default(Channel.kt:93) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at io.ktor.websocket.RawWebSocketJvm$1.invokeSuspend(RawWebSocketJvm.kt:78) ~[ktor-websockets-jvm-2.2.3.jar!/:2.2.3]
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.8.10.jar!/:1.8.10-release-430(1.8.10)]
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) ~[kotlinx-coroutines-core-jvm-1.6.4.jar!/:na]
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) ~[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]

实现帖子API

反馈内容类型

其他

相关链接

No response

内容描述

需要用到帖子API拉取帖子的内容

`TencentChannelInfoImpl` 反序列化失败

2022-07-27T05:11:11.536Z ERROR  --- [tDispatcher-worker-9]                   l.f.s.t.b.1.[0,1]  : Pre processing failed.
kotlinx.serialization.MissingFieldException: Fields [position, parent_id] are required for type with serial name 'love.forte.simbot.tencentguild.internal.TencentChannelInfoImpl', but they were missing
        at kotlinx.serialization.internal.PluginExceptionsKt.throwMissingFieldException(PluginExceptions.kt:20)
        at love.forte.simbot.tencentguild.internal.TencentChannelInfoImpl.<init>(TencentChannelInfoImpl.kt:28)
        at love.forte.simbot.tencentguild.internal.TencentChannelInfoImpl.<init>(TencentChannelInfoImpl.kt)
        at love.forte.simbot.tencentguild.internal.TencentChannelInfoImpl$$serializer.deserialize(TencentChannelInfoImpl.kt:28)
        at love.forte.simbot.tencentguild.internal.TencentChannelInfoImpl$$serializer.deserialize(TencentChannelInfoImpl.kt:28)
        at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:59)
        at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeSerializableValue(TreeJsonDecoder.kt:51)
        at kotlinx.serialization.json.internal.TreeJsonDecoderKt.readJson(TreeJsonDecoder.kt:24)
        at kotlinx.serialization.json.Json.decodeFromJsonElement(Json.kt:119)
        at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$3$lazy$1.invoke(TencentGuildBotImpl.kt:443)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$3$lazyDecoded$1.get(TencentGuildBotImpl.kt:444)
        at kotlin.jvm.internal.PropertyReference0.invoke(PropertyReference0.java:35)
        at love.forte.simbot.component.tencentguild.internal.TencentGuildComponentBotEventProcessKt.onChannelDelete(TencentGuildComponentBotEventProcess.kt:141)
        at love.forte.simbot.component.tencentguild.internal.TencentGuildComponentBotEventProcessKt.access$onChannelDelete(TencentGuildComponentBotEventProcess.kt:1)
        at love.forte.simbot.component.tencentguild.internal.TencentGuildComponentBotEventProcessKt$registerEventPreProcessor$1.invokeSuspend(TencentGuildComponentBotEventProcess.kt:47)
        at love.forte.simbot.component.tencentguild.internal.TencentGuildComponentBotEventProcessKt$registerEventPreProcessor$1.invoke(TencentGuildComponentBotEventProcess.kt)
        at love.forte.simbot.component.tencentguild.internal.TencentGuildComponentBotEventProcessKt$registerEventPreProcessor$1.invoke(TencentGuildComponentBotEventProcess.kt)
        at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$3.invokeSuspend(TencentGuildBotImpl.kt:447)
        at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$3.invoke(TencentGuildBotImpl.kt)
        at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$3.invoke(TencentGuildBotImpl.kt)
        at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit(Emitters.kt:223)
        at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$$inlined$mapNotNull$1$2.emit(Emitters.kt:245)
        at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:62)
        at kotlinx.coroutines.flow.FlowKt__ChannelsKt.access$emitAllImpl$FlowKt__ChannelsKt(Channels.kt:1)
        at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Channels.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

重构

需要进行重构,尤其是基础API模块方面

事件类型 `PUBLIC_MESSAGE_DELETE` 解析错误

love.forte.simbot.SimbotIllegalStateException: Unknown event type: PUBLIC_MESSAGE_DELETE. data: Dispatch(data={"message":{"author":{"bot":false,"id":"xxx","username":"xxx"},"channel_id":"xxx","guild_id":"xxx","id":"xxx"},"op_user":{"id":"14072671896854096427"}}, type=PUBLIC_MESSAGE_DELETE, seq=3)
	at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$3.invokeSuspend(TencentGuildBotImpl.kt:438)
	at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$3.invoke(TencentGuildBotImpl.kt)
	at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$3.invoke(TencentGuildBotImpl.kt)
	at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit(Emitters.kt:223)
	at love.forte.simbot.tencentguild.core.internal.TencentGuildBotImpl$processEvent$$inlined$mapNotNull$1$2.emit(Emitters.kt:245)
	at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:62)
	at kotlinx.coroutines.flow.FlowKt__ChannelsKt.access$emitAllImpl$FlowKt__ChannelsKt(Channels.kt:1)
	at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Channels.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

`TencentMemberInfoImpl` 反序列化异常

Caused by: kotlinx.serialization.MissingFieldException: Field 'roles' is required for type with serial name 'love.forte.simbot.tencentguild.internal.TencentMemberInfoImpl', but it was missing
	at kotlinx.serialization.internal.PluginExceptionsKt.throwMissingFieldException(PluginExceptions.kt:20)
	at love.forte.simbot.tencentguild.internal.TencentMemberInfoImpl.<init>(TencentMemberInfoImpl.kt:28)
	at love.forte.simbot.tencentguild.internal.TencentMemberInfoImpl$$serializer.deserialize(TencentMemberInfoImpl.kt:28)
	at love.forte.simbot.tencentguild.internal.TencentMemberInfoImpl$$serializer.deserialize(TencentMemberInfoImpl.kt:28)
	at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:59)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:38)
	... 53 more

成员信息同步时权限不足

此问题类似于 #34

需要特殊处理。

01:54:50.619 [DefaultDispatcher-worker-7] ERROR love.forte.simbot.component.tencentguild.internal.TencentGuildImpl[***] - Sync members data for guild TencentGuildImpl(bot=love.forte.simbot.component.tencentguild.internal.TencentGuildComponentBotImpl@301940c6, guildInfo=TencentGuildInfoImpl(id=***, name=***, icon=***, ownerId=***, isBotOwner=false, memberCount=129, maxMembers=1200, description=***, joinedAt=InstantTimestamp(millisecond=***), unionWorldId=null, unionOrgId=null)) failed.
love.forte.simbot.tencentguild.TencentApiException: 401: Unauthorized; response info: ErrInfo(code=11264, message=check guild auth not pass)
	at love.forte.simbot.tencentguild.api.TencentApi.doRequest$suspendImpl(TencentApi.kt:169)
	at love.forte.simbot.tencentguild.api.TencentApi$doRequest$1.invokeSuspend(TencentApi.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:178)
	at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)
	at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:328)
	at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke(JobSupport.kt:1412)
	at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1519)
	at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:323)
	at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:240)
	at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:906)
	at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:863)
	at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:828)
	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.