Can-Chen / wrap-midjourney

获取discord服务器中midjourney AI生图的结果。一个中转服务,可以接入到任意第三方平台微信、飞书、QQ等/Obtain the midjourney AI image generation results from the Discord server. It is a transfer service that can be connected to any third-party platform, such as WeChat, Feishu, QQ, etc.
245 stars 58 forks source link

提交带图片链接的会导致崩溃 #11

Closed yoke1990 closed 1 year ago

yoke1990 commented 1 year ago

报错信息: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x863832] goroutine 78 [running]: wrap-midjourney/handlers.DiscordMsgUpdate(0xc000422380, 0xc0003a07a0) /www/golang/wrap-midjourney/handlers/discord.go:91 +0x92 github.com/bwmarrin/discordgo.messageUpdateEventHandler.Handle(0xc000392370?, 0x58eff6?, {0x8fa6e0?, 0xc0003a07a0?}) /root/go/pkg/mod/github.com/bwmarrin/discordgo@v0.27.1/eventhandlers.go:873 +0x38 created by github.com/bwmarrin/discordgo.(*Session).handle /root/go/pkg/mod/github.com/bwmarrin/discordgo@v0.27.1/event.go:171 +0x16a

报错的代码:

func DiscordMsgUpdate(s discord.Session, m discord.MessageUpdate) { //...... if m.Author.ID == s.State.User.ID { //报错地方 fmt.Println("zi ji fa song") return }

分析: 这条报错了。大概逻辑就是 1.发送带图片链接魔法指令后 接收到 wait start 。2.紧接着 discord update时候,会获得特殊的机器人消息,把这个图片链接转为dicord链接的消息(猜测当带链接时候,discord不会发给mj服务器,而是自己转了链接后再发给mj服务器)。这个特殊的估计没有m.Author.ID

CrewS commented 1 year ago

同样遇到这个问题

Can-Chen commented 1 year ago

https://github.com/Can-Chen/wrap-midjourney/commit/cf1b5b788330e472edd46fdf58456d5a955c3f33

已修复