GithubHelp home page GithubHelp logo

mrs4s / go-cqhttp Goto Github PK

View Code? Open in Web Editor NEW
10.2K 69.0 1.6K 2.96 MB

cqhttp的golang实现,轻量、原生跨平台.

License: GNU Affero General Public License v3.0

Go 99.42% Dockerfile 0.24% Shell 0.34%
bot qqbot qqrobot coolq coolq-http-api

go-cqhttp's Introduction

go-cqhttp's People

Contributors

01101sam avatar 1umine avatar akegarasu avatar arnie97 avatar fkx4-p avatar fumiama avatar fzls avatar github-actions[bot] avatar ink-33 avatar ishkong avatar kanrichan avatar komeidisanxian avatar maikotan avatar mnixry avatar mrs4s avatar nnnewb avatar povsister avatar purerosefallen avatar qianjunakasumi avatar remiliacn avatar sgpublic avatar shigma avatar synodriver avatar wdvxdr1123 avatar wfjsw avatar xiangxiangxiong9 avatar xuthus5 avatar xyenon avatar yukari316 avatar yume233 avatar

Stargazers

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

Watchers

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

go-cqhttp's Issues

特殊字符需要做转义处理

特殊字符需要转义,以避免处理时发生混淆。(图为QQ中发送的实际消息和go-cqhttp上报事件的解析结果)
image
image
根据nonebot源码推断,原cqhttp会将&、[、]分别转义为&、[、],并将出现在CQ码参数中的英文逗号转义为,。

消息接受有概率重复

在同时在配置文件中启用ws,ws_reverse和http时,通过ws_reverse会发出多条重复的消息

p.s.这个问题我没有测试,但是有几个人反映了

update.这个问题貌似复现方法不稳定但确实存在 @Kyomotoi 目前遇到了这个问题

收到一个xml消息后程序崩溃

[2020-08-04 16:49:54] [INFO]: 收到群 ***(******) 内 ***(******) 的消息: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="146" templateID="1" action="web" brief="[分享] 为ono写了一款HttpApi  " sourceMsgId="0" url="http://bbs.onoqq.com/thread-73.htm" flag="0" adverSign="0" multiMsgFlag="0"><item layout="2" advertiser_id="0" aid="0"><picture cover="https://cpic.url.cn/v1/glknrdgonv079nvff0p0ug2cqanctdtu20nfpksefpmrtio4m33cc48uun1h81rqkkfdbv9ls4a5k/4385epiiduf7qlgmuolh3louug" w="0" h="0" /><title>为ono写了一款HttpApi  </title><summary>为ono写了一款HttpApi</summary></item><source name="QQ浏览器" icon="https://url.cn/PWkhNu" url="https://url.cn/UQoBHn" action="app" a_actionData="com.tencent.mtt://http://bbs.onoqq.com/thread-73.htm" i_actionData="tencent100446242://http://bbs.onoqq.com/thread-73.htm" appid="-1" /></msg>http://bbs.onoqq.com/thread-73.htm (727142513)
panic: runtime error: slice bounds out of range [2:1]

goroutine 14 [running]:
github.com/Mrs4s/MiraiGo/utils.NewTTList.func1(0xc00000f040, 0x3c)
        /go/pkg/mod/github.com/!mrs4s/[email protected]/utils/ttl.go:28 +0x407
created by github.com/Mrs4s/MiraiGo/utils.NewTTList
        /go/pkg/mod/github.com/!mrs4s/[email protected]/utils/ttl.go:22 +0x8e
root@takayama:/mnt/d/ftp/go-cqhttp# 

Websocket Connect Issue

Server: [email protected]

http: panic serving 127.0.0.1:10562: runtime error: index out of range [1] with length 1
goroutine 279 [running]:
net/http.(*conn).serve.func1(0xc00011c280)
        /usr/local/go/src/net/http/server.go:1772 +0x140
panic(0xbdddc0, 0xc0009949a0)
        /usr/local/go/src/runtime/panic.go:973 +0x3a4
github.com/Mrs4s/go-cqhttp/server.(*websocketServer).any(0x128a360, 0xd66ee0, 0xc00032c380, 0xc000a3e000)
        /github/workspace/server/websocket.go:241 +0x531
net/http.HandlerFunc.ServeHTTP(0xc00008a1c0, 0xd66ee0, 0xc00032c380, 0xc000a3e000)
        /usr/local/go/src/net/http/server.go:2012 +0x4b
net/http.(*ServeMux).ServeHTTP(0x128a320, 0xd66ee0, 0xc00032c380, 0xc000a3e000)
        /usr/local/go/src/net/http/server.go:2387 +0x1ac
net/http.serverHandler.ServeHTTP(0xc000a00000, 0xd66ee0, 0xc00032c380, 0xc000a3e000)
        /usr/local/go/src/net/http/server.go:2807 +0xaa
net/http.(*conn).serve(0xc00011c280, 0xd68ca0, 0xc000428040)
        /usr/local/go/src/net/http/server.go:1895 +0x873
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2933 +0x363

Client: [email protected]

Error: socket hang up
    at createHangUpError (_http_client.js:332:15)
    at Socket.socketOnEnd (_http_client.js:435:23)
    at Socket.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at ClientRequest.req.on (bot/node_modules/ws/lib/websocket.js:551:15)
    at ClientRequest.emit (events.js:198:13)
    at Socket.socketOnEnd (_http_client.js:435:9)
    at Socket.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

程序运行失败

初次使用,想请问一下 release 的可执行文件是还有什么依赖需要安装吗?
账号密码检查过可以正常登陆QQ,配置完 config 后再次运行 go-cqhttp.exe
每次都到这里窗口就自动关闭,就没有后续了,也没有报错信息,看起来像是闪退
QQ图片20200806020627

Is this project allowed for commercial use?

We want to make QQ bots for a text RPG game, using this project as the bot backend, making profits. Now I wonder if this project is allowed for commercial use. If not for free, how would I be able to purchase a license?
In addition, I noticed that you changed the license to AGPLv3 from a specific commit. May I use the code before that commit as MIT?

登录失败

账号密码均无误,登陆失败,麻烦师傅帮忙看下,谢谢师傅
图片

登录密码明文储存不安全

目前qq的登录密码明文储存在config中,在多用户共用服务器、服务器受外部攻击、所用软件有安全漏洞等情况下可能会被窃取。

考虑到自动重新登录的feature,建议:

  • 首次登录时询问密码
  • 使用密文存储密码

获取群组成员信息超时导致的崩溃

错误报告

[2020-08-05 06:41:17] [DEBUG]: 反向WS接收到API调用: get_group_member_info 参数: {"self_id":2044450237,"group_id":708157568,"user_id":1363634305,"no_cache":true}
Packet Timed out
[2020-08-05 06:41:32] [WARNING]: 刷新群 708157568 成员列表失败: time out
Packet Timed out
panic: EOF

goroutine 8 [running]:
github.com/Mrs4s/MiraiGo/binary.(*Reader).ReadBytes(...)
        /go/pkg/mod/github.com/!mrs4s/[email protected]/binary/reader.go:39
github.com/Mrs4s/MiraiGo/binary.(*Reader).ReadInt32(0xc000011ed8, 0x1)
        /go/pkg/mod/github.com/!mrs4s/[email protected]/binary/reader.go:58 +0x142
github.com/Mrs4s/MiraiGo/protocol/packets.ParseIncomingPacket(0x0, 0x0, 0x0, 0xc0003fb190, 0x10, 0x10, 0xc00026e320, 0x0, 0x0)
        /go/pkg/mod/github.com/!mrs4s/[email protected]/protocol/packets/global.go:87 +0x90
github.com/Mrs4s/MiraiGo/client.(*QQClient).loop(0xc0001a1340)
        /go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:743 +0x18b
created by github.com/Mrs4s/MiraiGo/client.(*QQClient).Login
        /go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:151 +0x8d

Request for a Dockerfile

In the past we deploy CoolQ HTTP API with this docker image: https://cqhttp.cc/docs/4.15/#/Docker
We were used to deploying it with Docker, with the app itself and QQ robot part in the same docker-compose.yml file. As for CoolQ came down, we would like to move to this project instead.
Could you spend a little time to make a similar Docker image, configuring the QQ robot with environment variables, to help us move to this project? Thanks.

使用正整数作为消息ID

目前go-cqhttp的消息ID似乎为int32,但是由于cqhttp原有的消息ID是递增的正整数
为了保证兼容性,是否可以考虑把消息ID全部改为正整数?(递增就不用了)

关于机器人断线后的自动重连

bot连续挂了4天左右,今天下午突然没反应了,一看是后台没了,回去查log,最后的log显示如下

[2020-08-08 12:23:07] [WARNING]: Bot已离线,将在 0 秒后尝试重连.
[2020-08-08 12:23:07] [FATAL]: 重连失败: already online

目前不知道是什么原因导致了离线。
可能是我需要增加一下重连的延时?
或者是否可以增加重连尝试的次数,以保证bot的稳定性呢?

暂时找到的bug

1.好友私聊消息撤回失败
image
image
2.群单独禁言的时长默认值为0,取消禁言,而不是文档所写的30*60
image
3.群全体禁言无法关闭
image
暂时就找到这几个....

被服务端踢下线后 ws没有断开

版本 0.9.15
Q1 采用反向ws, 被服务端踢下线后(因为冻结或其他原因) ws没有断开, 导致后端写的断线监控未起作用.
Q2 ctrl+v强制关闭后docker没有被清理, 再次启动docker映射必定失败一次, log日志为端口8080被占用. windows环境
Q3 连上ws之后希望加一个推送事件. 方便ws后端进行连接处理. 连接ws后端的除了bot外还有浏览器的websocket服务, 因此需要鉴别.

邀请bot进群时事件错误

邀请bot进群时,日志显示为“群 (被邀请加入的群) 收到来自用户 (bot账号) 的加群请求.”
另外这条日志中群号的位置显示的是群名()

如何判断后端是否使用go-cqhttp

因为go-cqhttp具有自己的一些增强API,下游开发者可能需要通过判断后端类型来自动选择是否启用一些功能
请问目前有办法实现嘛

群用户权限判断失真

发现新的问题了,不能临时聊天,临时聊天失败。
发现判断群用户权限失真,用户识别信息以及权限好像与CQ的有差异,不知道是否有颠倒字段顺序。

[bug] CQ回复和at卡片不能使用

在nonebot使用CQ:reply卡片得到:
转换CQ码到MiraiGo Element时出现错误: unsupported cq code: reply 将忽略本段CQ码.
使用at卡片[CQ:at,qq=123456]在qq群显示@123456(而不是at昵称)
使用[CQ:at,qq={123456}]或[CQ:at,123456]偶尔可以正常发送(经常发送不出来)
通过Array上报亦然
go-cqhttp 版本v0.9.13
OS: Arch Linux ARM armv7l
Kernel: 5.4.51-1-ARCH

现在能否发送其他类型消息?

类似于xml,json,app这种类型的,我看cqhttp好像没有支持,还有什么闪照什么的,还有一点你readme中的api的链接最好换成国内的那个地址.

[Not-Bug] 程序进程阻塞

在使用的时候有些图片接受后会卡住整个程序(表现形式为不在接受并处理新的群/好友消息),之后必须在控制台中进行键盘操作才能继续接收新的信息(比如ctrl+z)。

使用config:

{
  "uin": 123123,
  "password": "",
  "enable_db": true,
  "access_token": "",
  "relogin": false,
  "relogin_delay": 0,
  "http_config": {
    "enabled": true,
    "host": "[::]",
    "port": 5700,
    "post_urls": {}
  },
  "ws_config": {
    "enabled": false,
    "host": "127.0.0.1",
    "port": 6700
  },
  "ws_reverse_servers": [
    {
      "enabled": true,
      "reverse_url": "",
      "reverse_api_url": "ws://127.0.0.1:5700/ws/api/",
      "reverse_event_url": "ws://127.0.0.1:5700/ws/event/",
      "reverse_reconnect_interval": 3000
    }
  ],
  "debug": false
}

网络断线导致的程序崩溃

[2020-08-04 16:36:40] [INFO]: 收到好友 **(*******) 的消息: qqhead()
Packet Timed out
Packet Timed out
Packet Timed out
[2020-08-04 16:37:11] [WARNING]: 警告: 好友 *******消息图片上传失败.
panic: EOF

goroutine 7 [running]:
github.com/Mrs4s/MiraiGo/binary.(*Reader).ReadBytes(...)
        /go/pkg/mod/github.com/!mrs4s/[email protected]/binary/reader.go:39
github.com/Mrs4s/MiraiGo/binary.(*Reader).ReadInt32(0xc000068ed8, 0x1)
        /go/pkg/mod/github.com/!mrs4s/[email protected]/binary/reader.go:58 +0x13b
github.com/Mrs4s/MiraiGo/protocol/packets.ParseIncomingPacket(0x0, 0x0, 0x0, 0xc000480ba0, 0x10, 0x10, 0xc000032050, 0x0, 0x0)
        /go/pkg/mod/github.com/!mrs4s/[email protected]/protocol/packets/global.go:87 +0x89
github.com/Mrs4s/MiraiGo/client.(*QQClient).loop(0xc0001b9340)
        /go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:743 +0x184
created by github.com/Mrs4s/MiraiGo/client.(*QQClient).Login
        /go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:151 +0x86
root@takayama:/mnt/d/ftp/go-cqhttp#

ws断线问题

http: panic serving 127.0.0.1:60754: concurrent write to websocket connection
 goroutine 20021 [running]:
 net/http.(*conn).serve.func1(0xc000222a00)
     /usr/local/go/src/net/http/server.go:1772 +0x139
 panic(0xb13340, 0xd43060)
      /usr/local/go/src/runtime/panic.go:973 +0x396
 github.com/gorilla/websocket.(*messageWriter).flushFrame(0xc000e33800, 0x1, 0x0, 0x0, 0x0, 0xc000c4d500, 0x7f8a80157130)
      /go/pkg/mod/github.com/gorilla/[email protected]/conn.go:610 +0x5e9
 github.com/gorilla/websocket.(*messageWriter).Close(0xc000e33800, 0xb77060, 0xc000e33710)
      /go/pkg/mod/github.com/gorilla/[email protected]/conn.go:724 +0x62
 github.com/gorilla/websocket.(*Conn).WriteJSON(0xc001ba26e0, 0xb77060, 0xc000e33710, 0x4, 0xc001d2b978)
     /go/pkg/mod/github.com/gorilla/[email protected]/json.go:29 +0x12e
 github.com/Mrs4s/go-cqhttp/server.(*websocketServer).listenApi(0x128be60, 0xc001ba26e0)
     /github/workspace/server/websocket.go:276 +0x572
 github.com/Mrs4s/go-cqhttp/server.(*websocketServer).any(0x128be60, 0xd62fa0, 0xc000c69340, 0xc000167600)
      /github/workspace/server/websocket.go:256 +0x254
 net/http.HandlerFunc.ServeHTTP(0xc0006e0810, 0xd62fa0, 0xc000c69340, 0xc000167600)
     /usr/local/go/src/net/http/server.go:2012 +0x44
 net/http.(*ServeMux).ServeHTTP(0x128be20, 0xd62fa0, 0xc000c69340, 0xc000167600)
     /usr/local/go/src/net/http/server.go:2387 +0x1a5
 net/http.serverHandler.ServeHTTP(0xc0002a7880, 0xd62fa0, 0xc000c69340, 0xc000167600)
      /usr/local/go/src/net/http/server.go:2807 +0xa3
 net/http.(*conn).serve(0xc000222a00, 0xd65060, 0xc0001935c0)
      /usr/local/go/src/net/http/server.go:1895 +0x86c
 created by net/http.(*Server).Serve
      /usr/local/go/src/net/http/server.go:2933 +0x35c

panic: runtime error: slice bounds out of range

不确定是哪部分代码的问题

panic: runtime error: slice bounds out of range [148:146]

goroutine 1 [running]:
github.com/Mrs4s/go-cqhttp/server.(*websocketServer).onBotPushEvent(0x12fae20, 0xc000756150)
/root/gocqhttp/go-cqhttp-3078884107/server/websocket.go:298 +0x51f
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).dispatchEventMessage(0xc000096280, 0xc000756150)
/root/gocqhttp/go-cqhttp-3078884107/coolq/bot.go:178 +0x52
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).StartHeartbeat(0xc000096280)
/root/gocqhttp/go-cqhttp-3078884107/coolq/bot.go:70 +0x6c
main.main()
/root/gocqhttp/go-cqhttp-3078884107/main.go:184 +0xc91

挂的时间长了(几小时),群聊无法发送3个以上字节

只能发送1-2个字节,1个汉字也无法发送(大概占3字节的原因),私聊没有问题。
用mirai-native的cqhttp也出现过这个问题,怀疑是协议里的bug。
控制台一切正常(没开debug)。mirai-native的控制台也是一切正常,并且提示发送成功。
D AEE YMW}0T7_PD 8%@Z7F
暂时没有更多的情报了。
还有一些零碎的,整理好了发上来。

建议对http协议发送的图片进行缓存

多次发送同一个url的图片时,进行本地缓存可起到加速的作用,避免重复的网络请求。

cqhttp的实现方法是:对url进行md5作为文件名,如果存在则直接发送,如果不存在则下载保存后再发送。
或许可以作为参考。

特殊字符处理问题?

我有个测试机器人是否死机的命令会让机器人回复¿?¿?
但是机器人对命令进行处理的时候出现了下面的报错

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x28 pc=0x8c3381]

goroutine 87 [running]:
github.com/xujiajun/nutsdb.(*Tx).getTxID(0xc00040c880, 0xc00040c880, 0x20, 0x37d0413a)
        /go/pkg/mod/github.com/xujiajun/[email protected]/tx.go:112 +0x31
github.com/xujiajun/nutsdb.newTx(0x0, 0x1, 0x20, 0xc037d0413a, 0xc00007f9b8)
        /go/pkg/mod/github.com/xujiajun/[email protected]/tx.go:100 +0x9b
github.com/xujiajun/nutsdb.(*DB).Begin(0x0, 0x1, 0x11, 0xc000266478, 0xb4e7e0)
        /go/pkg/mod/github.com/xujiajun/[email protected]/tx.go:74 +0x3f
github.com/xujiajun/nutsdb.(*DB).managed(0x0, 0xc00004df01, 0xc00007fa40, 0x7, 0xc00014a208)
        /go/pkg/mod/github.com/xujiajun/[email protected]/db.go:847 +0x3f
github.com/xujiajun/nutsdb.(*DB).Update(...)
        /go/pkg/mod/github.com/xujiajun/[email protected]/db.go:262
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).InsertGroupMessage(0xc0003c9ae0, 0xc0000addb0, 0xc00007fbe8)
        /github/workspace/coolq/bot.go:139 +0x430
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).SendGroupMessage(0xc0003c9ae0, 0x3c11d49f, 0xc00007fbe8, 0x30)
        /github/workspace/coolq/bot.go:106 +0x127
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).CQSendGroupMessage(0xc0003c9ae0, 0x3c11d49f, 0xc5e500, 0xc0005b1d78, 0x0)
        /github/workspace/coolq/api.go:104 +0x7be
github.com/Mrs4s/go-cqhttp/server.glob..func8(0xc0003c9ae0, 0x5, 0xc0002f601e, 0x7d, 0x0, 0x0, 0x0, 0x1e, 0x6)
        /github/workspace/server/websocket.go:331 +0x3fa
github.com/Mrs4s/go-cqhttp/server.(*websocketClient).listenApi(0xc00040c740, 0xc00053c3f0, 0xc0000cfa00)
        /github/workspace/server/websocket.go:169 +0x54b
created by github.com/Mrs4s/go-cqhttp/server.(*websocketClient).connectApi
        /github/workspace/server/websocket.go:102 +0x5ec

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.