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

对于napcat docker下的onebot协议适配存在问题 #125

Open
sdutwsl opened this issue Nov 13, 2024 · 2 comments
Open

对于napcat docker下的onebot协议适配存在问题 #125

sdutwsl opened this issue Nov 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@sdutwsl
Copy link

sdutwsl commented Nov 13, 2024

使用 napcat-docker 部署onebot协议的服务后 使用-gocq参数启用petpet服务,在连接成功后,会出现如下问题:

  1. 私聊消息 会抛出警告 kotlinx.serialization.SerializationException: moe.dituon.petpet.websocket.gocq.GoCQMessageType does not contain element with name 'private' 同时插件没有效果 机器人没有回复
  2. 群消息 只有一条 INFO日志出来 同时插件没有效果 机器人没有回复

日志如下 前两个warning是私聊消息 后两个INFO是群消息

root@fedoac:~/bots/petpet# java -jar petpet-6.2.jar -gocq
[2024-11-13 09:31:51] INFO: 

    ooooooooo.                 .                            .   
    `888   `Y88.             .o8                          .o8   
     888   .d88'  .ooooo.  .o888oo oo.ooooo.   .ooooo.  .o888oo 
     888ooo88P'  d88' `88b   888    888' `88b d88' `88b   888   
     888         888ooo888   888    888   888 888ooo888   888   
     888         888    .o   888 .  888   888 888    .o   888 . 
    o888o        `Y8bod8P'   "888"  888bod8P' `Y8bod8P'   "888" 
                                    888                         
                                   o888o                        
                                                                     v6.2

[2024-11-13 09:31:51] INFO: Petpet GifMakerThreadPoolSize: 5
[2024-11-13 09:31:51] INFO: ヾ(≧▽≦*)o Petpet 初始化成功,使用 pet 以获取keyList!
[2024-11-13 09:31:51] INFO: GifMakerThreadPoolSize: 5
[2024-11-13 09:31:51] INFO: 注册字体成功: [MiSans-Bold.ttf, Handel-Gothic.ttf, Aller-Bold.ttf]
[2024-11-13 09:31:51] INFO: 
---Key List---
#此处省略

[2024-11-13 09:31:51] INFO: PetpetWebServer started in port 2333
[2024-11-13 09:31:51] INFO: WebUI-URL: http://127.0.0.1:2333/
[2024-11-13 09:31:51] WARNING: WebUI preview is disabled
[2024-11-13 09:31:51] INFO: API-URL: http://127.0.0.1:2333/petpet
123
[2024-11-13 09:31:51] INFO: WebSocket API URL: ws://127.0.0.1:3001/api
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[2024-11-13 09:31:52] INFO: GoCQ API WebSocket 连接成功
[2024-11-13 09:31:52] INFO: GoCQ Event WebSocket 连接成功
[2024-11-13 09:32:02] WARNING: {"self_id":1047838187,"user_id":212917140,"time":1731461521,"message_id":1533067081,"message_seq":1533067081,"real_id":1533067081,"message_type":"private","sender":{"user_id":212917140,"nickname":"xxx","card":""},"raw_message":"pet","font":14,"sub_type":"friend","message":[{"type":"text","data":{"text":"pet"}}],"message_format":"array","post_type":"message"}
kotlinx.serialization.SerializationException: moe.dituon.petpet.websocket.gocq.GoCQMessageType does not contain element with name 'private'
[2024-11-13 09:33:06] WARNING: {"self_id":1047838187,"user_id":212917140,"time":1731461585,"message_id":1685504494,"message_seq":1685504494,"real_id":1685504494,"message_type":"private","sender":{"user_id":212917140,"nickname":"xxx","card":""},"raw_message":"喜报 114514","font":14,"sub_type":"friend","message":[{"type":"text","data":{"text":"喜报 114514"}}],"message_format":"array","post_type":"message"}
kotlinx.serialization.SerializationException: moe.dituon.petpet.websocket.gocq.GoCQMessageType does not contain element with name 'private'
[2024-11-13 09:37:45] INFO: {}   id: 1047838187
[2024-11-13 09:38:04] INFO: {}   id: 1047838187
@Dituon
Copy link
Owner

Dituon commented Nov 13, 2024

感谢反馈, 本插件的 onebot 适配器支持两年前的 gocq 协议 (onebot 协议的前身)。

对新版协议可能无法正确解析; 近期更新的新版本会解决此问题。

@Dituon Dituon added the bug Something isn't working label Nov 13, 2024
@sdutwsl
Copy link
Author

sdutwsl commented Nov 13, 2024

简单研究了下之后发现,群聊消息其实在某种程度上是可以用的,其原因在于 napcat-docker 运行在docker容器之中,但是 java -jar petpet.jar -gocq所发送的消息段中,图片的地址指向了http://127.0.0.1:2333,因此访问到了容器本身的的2333端口。

petpet返回的消息段如下所示

{
  type: 'image',
  data: {
    file: 'http://127.0.0.1:2333/petpet?key=hypnotize&fromAvatar=省略...'
  }
}

此时napcat-docker输出如下log

2024-11-13 11:29:48 [ERROR] Botxxx(1047xxxxxx) | 发生错误 Error: connect ECONNREFUSED 127.0.0.1:2333
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1606:16) 

希望可以作为解决问题的参考,感谢开源。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants