- 🔭 主要使用: C#, Java, Golang, Kotlin, Swift
- 🌱 单推的角色: 夏目藍
- 👯 Bangumi: Mrs4s
- 👯 Steam: Mrs4s
- 📫 有事联系: [email protected]
mrs4s / miraigo Goto Github PK
View Code? Open in Web Editor NEWqq协议的golang实现, 移植于mirai
License: GNU Affero General Public License v3.0
qq协议的golang实现, 移植于mirai
License: GNU Affero General Public License v3.0
bot正常运行几个小时后就出现下面的panic:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5bc3e5]
goroutine 16 [running]:
net.(*TCPConn).Write(0x0, 0xc0020c5680, 0x204, 0x280, 0x280, 0xb9b901, 0xc00203d1b0)
<autogenerated>:1 +0x5
github.com/Mrs4s/MiraiGo/client.(*QQClient).send(...)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:939
github.com/Mrs4s/MiraiGo/client.(*QQClient).registerClient(0xc000110dc0)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:911 +0x67
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop(0xc000110dc0)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:993 +0x4f1
created by github.com/Mrs4s/MiraiGo/client.(*QQClient).Login
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:186 +0x92
这个……不知道为什么大家都没有需求,这个功能是因为犯规了吗?
在代码中搜索正则表达式\d\.\d\.\d
,发现有很多不同版本QQ
QQ.client.onprivatemessage(func)
在A向bot发送信息后func未被调用
Planed应为Planned,Fixed in #148
尝试用SendPrivateMessage
发送几百字的消息,目标QQ完全没有收到消息,返回的*message.PrivateMessage
应该是没有问题的。
原版的Mirai没有用过,但酷Q可以发送字数较多的消息。
重启之后,第一次收到私聊消息的时候会把之前的收到过的消息再接受一遍(不确定范围)
包括一段时间以前的:其中一条fields.time="2021-02-24 19:23:28 +0800 CST""
目前是用msg.Time过滤了一下
OnPrivateMessage(func(qqClient *client.QQClient, msg *message.PrivateMessage) {
if msg.Time < int32(time.Now().Add(time.Minute*-1).Unix()) {
logger.WithField("Sender", msg.Sender.DisplayName()).
WithField("time", time.Unix(int64(msg.Time), 0)).
WithField("MessageID", msg.Id).
Debug("past private message got, skip.")
return
}
time="2021-03-05T13:00:01+08:00" level=debug msg="connect to server: 113.96.13.208:8080" module=miraigo type=INFO
time="2021-03-05T13:00:01+08:00" level=debug msg="rev pkt: wtlogin.login seq: 13878" module=miraigo type=DEBUG
time="2021-03-05T13:00:01+08:00" level=debug msg="rev pkt: wtlogin.login seq: 13879" module=miraigo type=DEBUG
time="2021-03-05T13:00:01+08:00" level=debug msg="rev pkt: StatSvc.register seq: 13880" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: OnlinePush.PbPushGroupMsg seq: 25312" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="sync group 824098832." module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: OidbSvc.0x88d_0 seq: 13882" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13881" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: friendlist.GetTroopMemberListReq seq: 13883" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13884" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: Heartbeat.Alive seq: 13887" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: RegPrxySvc.GetMsgV2 seq: 36408" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: RegPrxySvc.getOffMsg seq: 13886" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: RegPrxySvc.PushParam seq: 36409" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: RegPrxySvc.PbGetMsg seq: 36410" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: RegPrxySvc.NoticeEnd seq: 36411" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: friendlist.GetTroopMemberListReq seq: 13885" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: StatSvc.GetDevLoginInfo seq: 13888" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: friendlist.getFriendGroupList seq: 13889" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: friendlist.GetTroopMemberListReq seq: 13890" module=miraigo type=DEBUG
time="2021-03-05T13:00:02+08:00" level=debug msg="rev pkt: friendlist.GetTroopListReqV2 seq: 13891" module=miraigo type=DEBUG
...
time="2021-03-05T13:00:03+08:00" level=debug msg="rev pkt: friendlist.GetTroopMemberListReq seq: 13927" module=miraigo type=DEBUG
time="2021-03-05T13:00:04+08:00" level=debug msg="rev pkt: OnlinePush.PbPushGroupMsg seq: 31280" module=miraigo type=DEBUG
time="2021-03-05T13:00:04+08:00" level=debug msg="rev pkt: OnlinePush.PbPushGroupMsg seq: 16410" module=miraigo type=DEBUG
time="2021-03-05T13:00:04+08:00" level=debug msg="rev pkt: ConfigPushSvc.PushReq seq: 25992" module=miraigo type=DEBUG
time="2021-03-05T13:00:04+08:00" level=debug msg="got file storage svc push." module=miraigo type=DEBUG
time="2021-03-05T13:00:04+08:00" level=debug msg="rev pkt: ConfigPushSvc.PushDomain seq: 25994" module=miraigo type=DEBUG
time="2021-03-05T13:00:04+08:00" level=debug msg="Unhandled Command: ConfigPushSvc.PushDomain\nSeq: 25994\nThis message can be ignored." module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="rev pkt: OnlinePush.PbPushGroupMsg seq: 14624" module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="rev pkt: OnlinePush.PbPushGroupMsg seq: 51189" module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="rev pkt: MessageSvc.PushNotify seq: 26229" module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13930" module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13931" module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13932" module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13933" module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13934" module=miraigo type=DEBUG
time="2021-03-05T13:00:06+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13935" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13936" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13937" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13938" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13939" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13940" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13941" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13942" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13943" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13944" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13945" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13946" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13947" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: ProfileService.Pb.ReqSystemMsgNew.Group seq: 13948" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13949" module=miraigo type=DEBUG
time="2021-03-05T13:00:07+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:08+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13950" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13951" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13952" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13953" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13954" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13955" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13956" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13957" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13958" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13959" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13960" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13961" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13962" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13963" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13964" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13965" module=miraigo type=DEBUG
time="2021-03-05T13:00:09+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:10+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13966" module=miraigo type=DEBUG
time="2021-03-05T13:00:10+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13967" module=miraigo type=DEBUG
time="2021-03-05T13:00:10+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:10+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13968" module=miraigo type=DEBUG
time="2021-03-05T13:00:10+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13969" module=miraigo type=DEBUG
time="2021-03-05T13:00:10+08:00" level=debug msg="continue sync with flag: CONTINUME" module=miraigo type=DEBUG
time="2021-03-05T13:00:10+08:00" level=debug msg="rev pkt: MessageSvc.PbGetMsg seq: 13970" module=miraigo type=DEBUG
time="2021-03-05T13:00:10+08:00" level=debug msg="rev pkt: MessageSvc.PbDeleteMsg seq: 13971" module=miraigo type=DEBUG
感谢维护,目前关于支持设备信息自定义有一点建议。
由于最近众所周知的原因风声比较紧,因此想替代原CQHTTP继续进行服务。但是初始化后发现,设备的是基于AndriodPad给出的设备信息,同时其中含有大量MiRai字段,出于隐私和安全性的考虑,想对设备进行高度自定义。
看到源码中,在Global中进行了定义和生成,在Builders中进行了与QQ-Client的交互。
但是本身对通信协议和Go语言都不够熟悉,不知道可否对除了JSON中生成的字段的其他信息进行修改?
以及如果支持修改的话,有无具体格式和自定义要求/限制?
同时基于此,是否可以以本JSON作为绕过“未知设备登录”的手段?以规避设备锁等安全机制。
就只有一个群,有时候消息可以发到群里,有时候发不到群里,SendGroupMessage的返回值我看也没有异常
package main
import (
"github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/MiraiGo/message"
"log"
)
func main() {
c := client.NewClient(xxx, "xxxx")
r, err := c.Login()
if err != nil {
log.Fatalf("fail %s", err)
}
if !r.Success {
log.Fatalf("fail %s", r.ErrorMessage)
}
log.Println("ok")
gs, err := c.GetGroupList()
if err != nil {
log.Fatalf("fail %s", err)
}
for _, g := range gs {
t := message.NewText("xxxxx")
m := message.SendingMessage{Elements: []message.IMessageElement{t}}
c.SendGroupMessage(g.Code, &m)
}
log.Println(len(gs))
}
原mirai项目记得是实现了这个功能,但是该项目似乎定向访问腾讯的ipv4登录服务器。
所以想问一下,是否能实现通过ipv6地址登录的支持?
需要使用QueryGroupImage接口获取,不确定是否是feature?
使用 MiraiGo-Template 创建的项目,在调用 bot.Login() 方法之后收到错误提示“login failed: 当前版本过低,请升级到QQ最新版本“。已经尝试过切换各种协议、更改登录密码、关闭设备锁,均不能解决。
依赖的 MiraiGo 版本为:github.com/Mrs4s/MiraiGo v0.0.0-20210124201115-fb93c5c73169
{"bot":"internal","level":"info","msg":"initializing modules ...","time":"2021-01-25T00:15:28-08:00"}
{"level":"info","module":"daredemo_suki","msg":"DD enabled for group ******","time":"2021-01-25T00:15:28-08:00"}
{"level":"info","module":"daredemo_suki","msg":"DD enabled for group ******","time":"2021-01-25T00:15:28-08:00"}
{"bot":"internal","level":"info","msg":"all modules initialized","time":"2021-01-25T00:15:28-08:00"}
{"bot":"internal","level":"info","msg":"registering modules serve functions ...","time":"2021-01-25T00:15:28-08:00"}
{"bot":"internal","level":"info","msg":"all modules serve functions registered","time":"2021-01-25T00:15:28-08:00"}
{"bot":"internal","level":"info","msg":"starting modules tasks ...","time":"2021-01-25T00:15:28-08:00"}
{"bot":"internal","level":"info","msg":"tasks running","time":"2021-01-25T00:15:28-08:00"}
{"bot":"internal","level":"fatal","msg":"login failed: 当前版本过低,请升级到QQ最新版本。","time":"2021-01-25T00:15:29-08:00"}
是否增加百变气泡功能
panic: runtime error: slice bounds out of range [:7] with capacity 0
goroutine 170 [running]:
github.com/Mrs4s/MiraiGo/binary.(*TEA).Encrypt(0xc0005314a0, 0x13b70e0, 0x0, 0x0, 0xc0005e1108, 0xc000361c48, 0xc0005e11b8)
/home/xxx/go/pkg/mod/github.com/!mrs4s/[email protected]/binary/tea.go:48 +0x9b0
github.com/Mrs4s/MiraiGo/client.(*QQClient).highwayUploadByBDH(0xc00027aa80, 0xe707e0, 0xc000368060, 0x2, 0xc000630000, 0x80, 0x80, 0x13b70e0, 0x0, 0x0, ...)
/home/xxx/go/pkg/mod/github.com/!mrs4s/[email protected]/client/highway.go:108 +0x18f
github.com/Mrs4s/MiraiGo/client.(*QQClient).UploadGroupImage(0xc00027aa80, 0xbf3a8a, 0xe707e0, 0xc000368060, 0x7fe00, 0x1a4, 0x0)
/home/xxx/go/pkg/mod/github.com/!mrs4s/[email protected]/client/image.go:47 +0x59d
github.com/Sora233/Sora233-MiraiGo/lsp.(*LspGroupCommand).SetuCommand.func2(0xc000530ef0, 0xc0004c50a0, 0x1, 0x1, 0xc0004d0a70, 0x1, 0x1, 0xc0006021e0, 0xbf3a8a, 0xc0006a2390, ...)
/home/xxx/go/src/github.com/Sora233/Sora233-MiraiGo/lsp/groupCommand.go:213 +0x453
created by github.com/Sora233/Sora233-MiraiGo/lsp.(*LspGroupCommand).SetuCommand
/home/xxx/go/src/github.com/Sora233/Sora233-MiraiGo/lsp/groupCommand.go:199 +0x6c5
在升级了miraigo的版本之后,调用1~2次就会出现
- github.com/Mrs4s/MiraiGo v0.0.0-20201227141240-b569935970d8
+ github.com/Mrs4s/MiraiGo v0.0.0-20210107163750-ce4834c2ba71
MiraiGo提供了非常方便的定义事件,但是似乎不能取消订阅事件。
希望能在此基础上提供取消订阅的功能
下面是我不成熟的代码,通过订阅函数返回一个函数来实现取消订阅的功能。
func (c *QQClient) OnPrivateMessage(f func(*QQClient, *message.PrivateMessage)) func() {
c.eventHandlers.privateMessageHandlers = append(c.eventHandlers.privateMessageHandlers, f)
return func() {
var newHandlers []func(client *QQClient, privateMessage *message.PrivateMessage)
for _, i := range c.eventHandlers.privateMessageHandlers {
if reflect.ValueOf(i) != reflect.ValueOf(f) {
newHandlers = append(newHandlers, i)
}
}
c.eventHandlers.privateMessageHandlers = newHandlers
}
}
使用
unsub := c.OnPrivateMessage(func(client *QQClient, privateMessage *message.PrivateMessage) {
//... balabala
})
//once, I dont want to listen to this, event, just unsubscribe it
unsub()
之前都用coolq的,现在出了这码事,打算更换平台了。
mirai之前没怎么研究过,想知道这个怎么部署呢?
可以给我点相关资料么
如题,想让功能丰富一点
基本都是broken pipe
write conn error: write tcp X.X.X.X:35682->123.151.190.163:80: write: broken pipe
请问上传图片有什么限制?
应该是10月5日的更新导致的,4日的 43db052 没有问题。
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x9d6f25]
goroutine 1 [running, locked to thread]:
github.com/Mrs4s/MiraiGo/binary.(*TEA).encode(0x0, 0xc0001987e0, 0x8, 0xe0, 0xc0001987e0, 0x8, 0xe0)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/binary/tea.go:124 +0x45
github.com/Mrs4s/MiraiGo/binary.(*TEA).Encrypt(0x0, 0xc0003d7400, 0xd6, 0x121, 0xc000010578, 0xc000010578, 0xc0008879e0)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/binary/tea.go:44 +0x1ee
github.com/Mrs4s/MiraiGo/binary.(*Writer).EncryptAndWrite(0xc000010570, 0x0, 0x0, 0x0, 0xc0003d7400, 0xd6, 0x121)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/binary/writer.go:68 +0x71
github.com/Mrs4s/MiraiGo/protocol/packets.BuildUniPacket.func1(0xc000010570)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/protocol/packets/builders.go:35 +0x225
github.com/Mrs4s/MiraiGo/binary.(*Writer).WriteIntLvPacket(0xc00045d650, 0x4, 0xc00045d680)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/binary/writer.go:74 +0x7b
github.com/Mrs4s/MiraiGo/protocol/packets.BuildUniPacket(0x78ad861d, 0xc000123637, 0xc9dae3, 0x1d, 0xc00042c001, 0xc0001661c8, 0x4, 0x4, 0xc00045d7bc, 0x0, ...)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/protocol/packets/builders.go:29 +0x1a5
github.com/Mrs4s/MiraiGo/client.(*QQClient).buildFriendGroupListRequestPacket(0xc000172300, 0x960000, 0xc00045d8d0, 0xad0a98, 0x1273d20, 0x1273d28)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/builders.go:363 +0x54a
github.com/Mrs4s/MiraiGo/client.(*QQClient).GetFriendList(0xc000172300, 0x1, 0x1, 0x2)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:346 +0x85
github.com/Mrs4s/MiraiGo/client.(*QQClient).ReloadFriendList(...)
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:333
main.initMirai(0xc00045dca0)
/home/orzogc/src/go/acfunlive/mirai.go:107 +0x5e9
main.main()
/home/orzogc/src/go/acfunlive/main.go:343 +0xe8d
这是一个比较通用的需求,放在SDK更好一点
if i, ok := elem.(*message.ImageElement); ok {
gm, err := bot.Client.UploadGroupImage(groupId, i.Data)
if err != nil {
log.Warnf("警告: 群 %v 消息图片上传失败: %v", groupId, err)
continue
}
newElem = append(newElem, gm)
continue
}
if i, ok := elem.(*message.VoiceElement); ok {
gv, err := bot.Client.UploadGroupPtt(groupId, i.Data)
if err != nil {
log.Warnf("警告: 群 %v 消息语音上传失败: %v", groupId, err)
continue
}
newElem = append(newElem, gv)
continue
}
方便集成到各种不同语言、环境,也容易二次分发。
就是cgo要考虑的细节问题蛮多的,之前试过改 go-cqhttp ,用 JSON 当Go和C交换数据的格式,导出了 Login/Send/Recv,虽然能在 x86 下跑起来但树莓派上还会 panic。
先提个设想,看看有人感兴趣不。
考虑到以下场合:
有些消息群聊刷屏,需要私聊发送
很大一部分人懒得或者没这个意识加bot好友
一个小规模的群,有12个管理员,Permission为Administrator的只有8个,一些管理员的Permission为10(member),reload也没用。
编译失败,提示 undefined: io.ReadAll
可能是utils/http.go
中如下函数出错.
// HttpGetBytes 带 cookie 的 GET 请求
func HttpGetBytes(url, cookie string) ([]byte, error) {
body, err := HTTPGetReadCloser(url, cookie)
defer func() { _ = body.Close() }()
if err != nil {
return nil, err
}
return io.ReadAll(body)
}
将return io.ReadAll(body)
改为return ioutil.ReadAll(body)
后编译成功.
是某个库未引入还是单纯typo?😂
利用 Data Race Detector 发现MiraiGo存在data race:
2020/10/11 16:56:51 Mirai DEBUG: rev pkt: OnlinePush.SidTicketExpired seq: 14418
2020/10/11 16:56:55 Mirai DEBUG: rev pkt: OnlinePush.ReqPush seq: 63665
2020/10/11 16:57:04 Mirai DEBUG: rev pkt: OnlinePush.ReqPush seq: 63665
==================
WARNING: DATA RACE
Read at 0x00c0001d8ba8 by goroutine 126:
github.com/Mrs4s/MiraiGo/client.decodeOnlinePushReqPacket.func1()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/decoders.go:700 +0x53
github.com/Mrs4s/MiraiGo/client.decodeOnlinePushReqPacket()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/decoders.go:708 +0x794
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop.func1()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1136 +0x1b7
Previous write at 0x00c0001d8ba8 by goroutine 158:
github.com/Mrs4s/MiraiGo/client.decodeOnlinePushReqPacket()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/decoders.go:711 +0x88e
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop.func1()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1136 +0x1b7
Goroutine 126 (running) created at:
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1121 +0x59c
Goroutine 158 (finished) created at:
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1121 +0x59c
==================
==================
WARNING: DATA RACE
Read at 0x00c0005f6e68 by goroutine 126:
github.com/Mrs4s/MiraiGo/client.decodeOnlinePushReqPacket.func1()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/decoders.go:700 +0x96
github.com/Mrs4s/MiraiGo/client.decodeOnlinePushReqPacket()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/decoders.go:708 +0x794
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop.func1()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1136 +0x1b7
Previous write at 0x00c0005f6e68 by goroutine 158:
github.com/Mrs4s/MiraiGo/client.decodeOnlinePushReqPacket()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/decoders.go:711 +0x864
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop.func1()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1136 +0x1b7
Goroutine 126 (running) created at:
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1121 +0x59c
Goroutine 158 (finished) created at:
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1121 +0x59c
==================
2020/10/11 16:57:12 Mirai DEBUG: rev pkt: Heartbeat.Alive seq: 13887
2020/10/11 16:57:42 Mirai DEBUG: rev pkt: Heartbeat.Alive seq: 13888
2020/10/11 16:31:48 Mirai DEBUG: rev pkt: Heartbeat.Alive seq: 13885
2020/10/11 16:32:18 Mirai DEBUG: rev pkt: Heartbeat.Alive seq: 13886
==================
WARNING: DATA RACE
Write at 0x00c0003f05cc by goroutine 52:
github.com/Mrs4s/MiraiGo/client.(*QQClient).doHeartbeat()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1171 +0x79
github.com/Mrs4s/MiraiGo/client.(*QQClient).doHeartbeat-fm()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1160 +0x44
Previous write at 0x00c0003f05cc by goroutine 49:
github.com/Mrs4s/MiraiGo/client.(*QQClient).doHeartbeat()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1171 +0x79
github.com/Mrs4s/MiraiGo/client.(*QQClient).doHeartbeat-fm()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1160 +0x44
Goroutine 52 (running) created at:
time.goFunc()
/usr/lib/go/src/time/sleep.go:167 +0x51
Goroutine 49 (finished) created at:
time.goFunc()
/usr/lib/go/src/time/sleep.go:167 +0x51
==================
==================
WARNING: DATA RACE
Write at 0x00c0000e4f68 by main goroutine:
github.com/Mrs4s/MiraiGo/client.(*QQClient).Disconnect()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:991 +0x8b5
main.initMirai()
/home/orzogc/src/go/acfunlive/mirai.go:151 +0x83e
main.main()
/home/orzogc/src/go/acfunlive/main.go:343 +0x115c
Previous read at 0x00c0000e4f68 by goroutine 32:
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:1080 +0xe5
Goroutine 32 (running) created at:
github.com/Mrs4s/MiraiGo/client.(*QQClient).Login()
/home/orzogc/go/pkg/mod/github.com/!mrs4s/[email protected]/client/client.go:203 +0xd1
main.initMirai()
/home/orzogc/src/go/acfunlive/mirai.go:78 +0x2ba
main.main()
/home/orzogc/src/go/acfunlive/main.go:343 +0x115c
==================
目前看来,海外服务器连tx只有msfwifi.3g.qq.com这个地址是最稳定的。
其它固定ip都有一定程度的延迟和丢包。
(比如可以在启动的时候选定一个延迟最低的地址。或者让高级用户可以自己指定地址。)
预期:在Login之后不直接改变Online,在验证码处理完成之后改为true
// Login send login request
func (c *QQClient) Login() (*LoginResponse, error) {
if c.Online {
return nil, ErrAlreadyOnline
}
err := c.connect()
if err != nil {
return nil, err
}
c.Online = true // 把这个移动到下面3个位置
go c.netLoop()
seq, packet := c.buildLoginPacket()
rsp, err := c.sendAndWait(seq, packet)
if err != nil {
return nil, err
}
l := rsp.(LoginResponse)
if l.Success {
c.lastLostMsg = ""
c.registerClient()
if !c.heartbeatEnabled {
c.startHeartbeat()
}
c.Online = true // 位置1
}
return &l, nil
}
// SubmitCaptcha send captcha to server
func (c *QQClient) SubmitCaptcha(result string, sign []byte) (*LoginResponse, error) {
seq, packet := c.buildCaptchaPacket(result, sign)
rsp, err := c.sendAndWait(seq, packet)
if err != nil {
return nil, err
}
l := rsp.(LoginResponse)
if l.Success {
c.registerClient()
if !c.heartbeatEnabled {
c.startHeartbeat()
}
c.Online = true // 位置2
}
return &l, nil
}
func (c *QQClient) SubmitSMS(code string) (*LoginResponse, error) {
rsp, err := c.sendAndWait(c.buildSMSCodeSubmitPacket(code))
if err != nil {
return nil, err
}
l := rsp.(LoginResponse)
if l.Success {
c.registerClient()
if !c.heartbeatEnabled {
c.startHeartbeat()
}
c.Online = true // 位置3
}
return &l, nil
}
???
Hello,I would link to create a software auto publisher,but I cannot find the API to send a file.
Thank you for help.
登录成功后,怎么阻塞让它可以处理消息?而不是直接结束程序
以下问题均在调试滑块扫描二维码登录时检出
Lines 1026 to 1040 in 8f474db
Lines 932 to 947 in 8f474db
sendAndWait
时如果出现session expired
就会因收不到包而超时退出Lines 979 to 993 in b66d8a9
if errors.Is(err, packets.ErrSessionExpired) || errors.Is(err, packets.ErrPacketDropped) {
c.Disconnect()
go c.dispatchDisconnectEvent(&ClientDisconnectedEvent{Message: "session expired"})
c.Connect()
continue
}
则能暴力解决问题一。但需要等待接近15秒才能获取到二维码。且quickReconnect
返回register error时会打断netLoop
,导致正常的wtlogin.trans_emp
被打断,程序也不退出。
复现方法:滑块选择使用二维码。即使第一次成功,重启程序后必定失败
大佬,感谢你的奉献,我最近抓包发现QQ语音的朗读挺有意思的感觉还带感情?但似乎是加密的。看了你的代码有解密的方法,但我不会go语言,能说下这是什么操作吗?我对qq协议也有兴趣
macaddress和androidId使用随机值后会提示QQ版本过低?
2020/08/08 01:21:25 parse incoming packet error: return code unsuccessful: -10008
Packet Timed out
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8e1c45]
goroutine 2344 [running]:
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).InsertGroupMessage(0xc000094280, 0x0, 0xc0001a9c38)
/root/gocqhttp/go-cqhttp-3078884107/coolq/bot.go:141 +0x45
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).SendGroupMessage(0xc000094280, 0x44959988, 0xc0001a9c38, 0x1)
/root/gocqhttp/go-cqhttp-3078884107/coolq/bot.go:117 +0x120
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).CQSendGroupMessage(0xc000094280, 0x44959988, 0xc58ce0, 0xc0001a9da8, 0x0)
/root/gocqhttp/go-cqhttp-3078884107/coolq/api.go:124 +0x35d
github.com/Mrs4s/go-cqhttp/server.glob..func9(0xc000094280, 0x5, 0xc000539c24, 0x353, 0x0, 0x0, 0x0, 0x24, 0x6)
/root/gocqhttp/go-cqhttp-3078884107/server/websocket.go:339 +0x16d
github.com/Mrs4s/go-cqhttp/server.(*websocketServer).listenApi(0x12fae20, 0xc00063a2c0)
/root/gocqhttp/go-cqhttp-3078884107/server/websocket.go:277 +0x50a
created by github.com/Mrs4s/go-cqhttp/server.(*websocketServer).api
/root/gocqhttp/go-cqhttp-3078884107/server/websocket.go:241 +0x1c6
手机QQ通过其他App向好友分享一个链接,经过观察,其消息格式为
[LightAppElement]
LightAppElement是一段 JSON 数据,包含了jumpURL,以及 descr等等一系列必要信息
第一次分享后,记此分享卡片的消息ID为 A
回复该分享卡片,ReplyElement的ReplySeq字段被正确设置为A
转发该分享卡片,此时消息ID变为 B
经过观察,转发后的消息格式为 [TextElement, LightAppElement],但实际内容不变
其中TextElement代表一个Fallback msg,例如:”[分享] xxxx 请使用最新版手机QQ查看消息"
回复转发后的卡片,此时ReplyElement的ReplySeq字段却不是B,而是一个负数?
这样导致我无法定位到回复的消息原文究竟是什么
是我对功能理解有问题还是bug ?
// 第一次分享卡片
Message {
ID=47489
Elems=[LightAppElement]
}
// 回复上面的卡片
Message {
ID=....
Elems=[ReplyElement {
ReplySeq=47489 // OK. 可以通过47489这个ID查找到消息原文
}]
}
// 转发第一次分享的卡片
Message {
ID=54751
Elems=[TextElement, LightAppElement]
// 其中 LightAppElement 字段仍然完整保留
}
// 回复转发的卡片
Message {
ID=....
Elems=[ReplyElement {
ReplySeq=-10785 // ????
}]
}
github.com/Mrs4s/MiraiGo/utils/connection.go:60,看代码中也有提到这个问题
报错信息:
`[2021-07-21 04:19:47] [ERROR]: Protocol -> unexpected disconnect: read tcp 192.168.122.11:40208->120.232.18.180:443: read: connection reset by peer
[2021-07-21 04:19:47] [INFO]: Protocol -> connect to server: 111.30.179.171:80
[2021-07-21 04:19:51] [ERROR]: Protocol -> parse incoming packet error: invalid payload
[2021-07-21 04:19:51] [ERROR]: Protocol -> unexpected disconnect: unexpected EOF
[2021-07-21 04:19:51] [INFO]: Protocol -> connect to server: 36.155.229.218:80
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x47dd38]
goroutine 65 [running]:
io.ReadAtLeast(0x0, 0x0, 0xc0009e8000, 0x4854544c, 0x4854544c, 0x4854544c, 0x4, 0xc0003de11c, 0x4)
io/io.go:328 +0x58
io.ReadFull(...)
io/io.go:347
github.com/Mrs4s/MiraiGo/utils.(*TCPListener).ReadBytes(0xc0005853a0, 0x4854544c, 0x0, 0x0, 0x0, 0x1, 0x0)
github.com/Mrs4s/[email protected]/utils/connection.go:60 +0xb5
github.com/Mrs4s/MiraiGo/client.(*QQClient).netLoop(0xc00005fc00)
github.com/Mrs4s/[email protected]/client/client.go:1056 +0x90
created by github.com/Mrs4s/MiraiGo/client.NewClientMd5
github.com/Mrs4s/[email protected]/client/client.go:255 +0x78a`
现在想计算下图片的重复次数)表情包除外,因为表情包重复次数太多
然后看了消息体,但还是不知道怎么区分,可以询问下吗
如题,谢谢
speed++
size+
已经讨论过了,在这写点记录
gogo的protobuf有四种,其中
--gofast_out 需要换包名,+4M
--gogofast_out 需要换包名并改动现有代码,+3M
--gogofaster_out 需要换包名并把指针全部解引用,+2M,目前我那bot用的这,好像有变快但是内存没啥区别..
--gogoslick_out 同上一个,+4M
# find -name *.proto | xargs -I {} ./proto.sh {}
protoc --gogofaster_out=`dirname $1` $1
👆批量regen,也许可以扔到actions(大概率不用
mirai 使用 AGPLv3,因此请 miraigo 也是用同样的协议
c := client.NewClient(xxxxx, "xxxx")
r, err := c.Login()
if err != nil {
log.Fatalf("fail %s", err)
}
if !r.Success {
log.Fatalf("fail %s", r.ErrorMessage)
}
log.Println("ok")
邀请加群当需要管理员同意时,会触发OnGroupInvited, 有时候管理员同意之后没有触发OnJoinGroup(已经开始接受这个群的消息了),日志里没有关于这个callback的信息。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.