diff --git a/Processor/ProcessC2CMessage.go b/Processor/ProcessC2CMessage.go index 2b62b304..2c32f196 100644 --- a/Processor/ProcessC2CMessage.go +++ b/Processor/ProcessC2CMessage.go @@ -50,7 +50,7 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error { //将真实id转为int userid64 _, userid64, err = idmap.StoreIDv2Pro("group_private", data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //当参数不全 _, _ = idmap.StoreIDv2(data.Author.ID) @@ -65,7 +65,7 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error { //将真实id转为int userid64 userid64, err = idmap.StoreIDv2(data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } } @@ -199,7 +199,7 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error { magic, userid64, err = idmap.StoreIDv2Pro("group_private", data.Author.ID) mylog.Printf("魔法数字:%v", magic) //690426430 if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //当参数不全,降级时 _, _ = idmap.StoreIDv2(data.Author.ID) @@ -209,7 +209,7 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error { //将真实id转为int userid64 userid64, err = idmap.StoreIDv2(data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } } //转换at diff --git a/Processor/ProcessChannelDirectMessage.go b/Processor/ProcessChannelDirectMessage.go index 6a0845f7..ebd1ed42 100644 --- a/Processor/ProcessChannelDirectMessage.go +++ b/Processor/ProcessChannelDirectMessage.go @@ -47,12 +47,12 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) //将真实id转为int userid64 _, _, err = idmap.StoreIDv2Pro(data.ChannelID, data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //将真实id转为int userid64 userid64, err = idmap.StoreIDv2(data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } ChannelID64, err = idmap.StoreIDv2(data.ChannelID) if err != nil { @@ -74,7 +74,7 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) //将真实id转为int userid64 userid64, err = idmap.StoreIDv2(data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //将channelid写入数据库,可取出guild_id ChannelID64, err = idmap.StoreIDv2(data.ChannelID) @@ -299,12 +299,12 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) //将真实id转为int userid64 ChannelID64, userid64, err = idmap.StoreIDv2Pro(data.ChannelID, data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //将真实id转为int userid64 _, err = idmap.StoreIDv2(data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } _, err = idmap.StoreIDv2(data.ChannelID) if err != nil { @@ -322,7 +322,7 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData) //将真实id转为int userid64 userid64, err = idmap.StoreIDv2(data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //将真实channelid和虚拟做映射 ChannelID64, err = idmap.StoreIDv2(data.ChannelID) diff --git a/Processor/ProcessGroupAddBot.go b/Processor/ProcessGroupAddBot.go index d0348b6a..90621d27 100644 --- a/Processor/ProcessGroupAddBot.go +++ b/Processor/ProcessGroupAddBot.go @@ -68,7 +68,7 @@ func (p *Processors) ProcessGroupAddBot(data *dto.GroupAddBotEvent) error { if config.GetIdmapPro() { GroupID64, userid64, err = idmap.StoreIDv2Pro(data.GroupOpenID, data.OpMemberOpenID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } } else { GroupID64, err = idmap.StoreIDv2(data.GroupOpenID) diff --git a/Processor/ProcessGroupDelBot.go b/Processor/ProcessGroupDelBot.go index b0dfa77e..96ca9cab 100644 --- a/Processor/ProcessGroupDelBot.go +++ b/Processor/ProcessGroupDelBot.go @@ -20,7 +20,7 @@ func (p *Processors) ProcessGroupDelBot(data *dto.GroupAddBotEvent) error { if config.GetIdmapPro() { GroupID64, userid64, err = idmap.StoreIDv2Pro(data.GroupOpenID, data.OpMemberOpenID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } } else { GroupID64, err = idmap.StoreIDv2(data.GroupOpenID) diff --git a/Processor/ProcessGroupMessage.go b/Processor/ProcessGroupMessage.go index 127ce343..f1e0f6e9 100644 --- a/Processor/ProcessGroupMessage.go +++ b/Processor/ProcessGroupMessage.go @@ -45,7 +45,7 @@ func (p *Processors) ProcessGroupMessage(data *dto.WSGroupATMessageData) error { //将真实id转为int userid64 GroupID64, userid64, err = idmap.StoreIDv2Pro(data.GroupID, data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //当参数不全 _, _ = idmap.StoreIDv2(data.GroupID) diff --git a/Processor/ProcessGroupMsgReceive.go b/Processor/ProcessGroupMsgReceive.go index a0d27b40..fd8c9cc6 100644 --- a/Processor/ProcessGroupMsgReceive.go +++ b/Processor/ProcessGroupMsgReceive.go @@ -43,7 +43,7 @@ func (p *Processors) ProcessGroupMsgRecive(data *dto.GroupMsgReceiveEvent) error //将真实id转为int userid64 GroupID64, userid64, err = idmap.StoreIDv2Pro(fromgid, fromuid) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } // 当哈希碰撞 因为获取时候是用的非idmap的get函数 diff --git a/Processor/ProcessGroupMsgReject.go b/Processor/ProcessGroupMsgReject.go index c3f72d96..e681d8aa 100644 --- a/Processor/ProcessGroupMsgReject.go +++ b/Processor/ProcessGroupMsgReject.go @@ -45,7 +45,7 @@ func (p *Processors) ProcessGroupMsgReject(data *dto.GroupMsgRejectEvent) error //将真实id转为int userid64 GroupID64, userid64, err = idmap.StoreIDv2Pro(fromgid, fromuid) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } // 当哈希碰撞 因为获取时候是用的非idmap的get函数 LongGroupID64, _ = idmap.StoreIDv2(fromgid) diff --git a/Processor/ProcessGuildATMessage.go b/Processor/ProcessGuildATMessage.go index 266923fb..318ec81a 100644 --- a/Processor/ProcessGuildATMessage.go +++ b/Processor/ProcessGuildATMessage.go @@ -146,7 +146,7 @@ func (p *Processors) ProcessGuildATMessage(data *dto.WSATMessageData) error { //将真实id转为int userid64 ChannelID64, userid64, err = idmap.StoreIDv2Pro(data.ChannelID, data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //当参数不全时 _, _ = idmap.StoreIDv2(data.ChannelID) diff --git a/Processor/ProcessGuildNormalMessage.go b/Processor/ProcessGuildNormalMessage.go index fd3125ff..d5fa8db1 100644 --- a/Processor/ProcessGuildNormalMessage.go +++ b/Processor/ProcessGuildNormalMessage.go @@ -145,7 +145,7 @@ func (p *Processors) ProcessGuildNormalMessage(data *dto.WSMessageData) error { //将真实id转为int userid64 ChannelID64, userid64, err = idmap.StoreIDv2Pro(data.ChannelID, data.Author.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //当参数不全时 _, _ = idmap.StoreIDv2(data.ChannelID) diff --git a/Processor/ProcessInlineSearch.go b/Processor/ProcessInlineSearch.go index ef0ccdbe..bc74f22d 100644 --- a/Processor/ProcessInlineSearch.go +++ b/Processor/ProcessInlineSearch.go @@ -79,7 +79,7 @@ func (p *Processors) ProcessInlineSearch(data *dto.WSInteractionData) error { //将真实id转为int userid64 GroupID64, userid64, err = idmap.StoreIDv2Pro(fromgid, fromuid) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } // 当哈希碰撞 因为获取时候是用的非idmap的get函数 LongGroupID64, _ = idmap.StoreIDv2(fromgid) diff --git a/Processor/ProcessThreadMessage.go b/Processor/ProcessThreadMessage.go index 9bc30546..7e657ecd 100644 --- a/Processor/ProcessThreadMessage.go +++ b/Processor/ProcessThreadMessage.go @@ -271,7 +271,7 @@ func (p *Processors) ProcessThreadMessage(data *dto.WSThreadData) error { //将真实id转为int userid64 ChannelID64, userid64, err = idmap.StoreIDv2Pro(data.ChannelID, data.AuthorID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } //当参数不全时 _, _ = idmap.StoreIDv2(data.ChannelID) diff --git a/Processor/Processor.go b/Processor/Processor.go index e6b8a66a..07246242 100644 --- a/Processor/Processor.go +++ b/Processor/Processor.go @@ -1042,7 +1042,7 @@ func (p *Processors) Autobind(data interface{}) error { //将真实id转为int userid64 GroupID64, userid64, err = idmap.StoreIDv2Pro(groupID, realID) if err != nil { - mylog.Fatalf("Error storing ID689: %v", err) + mylog.Errorf("Error storing ID689: %v", err) } } // 单独检查vuin和gid的绑定状态 @@ -1058,7 +1058,7 @@ func (p *Processors) Autobind(data interface{}) error { // idmaps pro也更新 err = idmap.UpdateVirtualValuev2Pro(GroupID64, idValue, userid64, vuinValue) if err != nil { - mylog.Fatalf("Error storing ID703: %v", err) + mylog.Errorf("Error storing ID703: %v", err) } } else if !vuinBound { // 只有vuin未绑定,更新vuin映射 diff --git a/handlers/get_friend_list.go b/handlers/get_friend_list.go index b3b344b1..70022c11 100644 --- a/handlers/get_friend_list.go +++ b/handlers/get_friend_list.go @@ -28,7 +28,7 @@ func HandleGetFriendList(client callapi.Client, api openapi.OpenAPI, apiv2 opena // 从数据库获取所有用户信息 users, err := idmap.ListAllUsers() if err != nil { - mylog.Fatalf("Failed to list users: %v", err) + mylog.Errorf("Failed to list users: %v", err) } // 添加数据库中读取的用户数据到output.Data diff --git a/handlers/get_group_member_list.go b/handlers/get_group_member_list.go index 05069f31..60f817eb 100644 --- a/handlers/get_group_member_list.go +++ b/handlers/get_group_member_list.go @@ -256,7 +256,7 @@ func GetGroupMemberList(client callapi.Client, api openapi.OpenAPI, apiv2 openap //将真实id转为int userid64 _, userIDInt64, err = idmap.StoreIDv2Pro(message.Params.ChannelID.(string), memberFromAPI.User.ID) if err != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } } else { //映射str的userid到int diff --git a/handlers/message_parser.go b/handlers/message_parser.go index d7190533..ee778759 100644 --- a/handlers/message_parser.go +++ b/handlers/message_parser.go @@ -81,7 +81,7 @@ func SendResponse(client callapi.Client, err error, message *callapi.ActionMessa //将真实id转为int userid64 GroupID64, _, errr = idmap.StoreIDv2Pro(message.Params.GroupID.(string), message.Params.UserID.(string)) if errr != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } } else { // 映射str的GroupID到int @@ -98,7 +98,7 @@ func SendResponse(client callapi.Client, err error, message *callapi.ActionMessa //将真实id转为int userid64 channelID64, _, errr = idmap.StoreIDv2Pro(message.Params.ChannelID.(string), message.Params.UserID.(string)) if errr != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } } else { // 映射str的GroupID到int @@ -115,7 +115,7 @@ func SendResponse(client callapi.Client, err error, message *callapi.ActionMessa //将真实id转为int userid64 guildID64, _, errr = idmap.StoreIDv2Pro(message.Params.GuildID.(string), message.Params.UserID.(string)) if errr != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } } else { // 映射str的GroupID到int @@ -132,7 +132,7 @@ func SendResponse(client callapi.Client, err error, message *callapi.ActionMessa //将真实id转为int userid64 userID64, _, errr = idmap.StoreIDv2Pro("group_private", message.Params.UserID.(string)) if errr != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } } else { // 映射str的GroupID到int @@ -344,7 +344,7 @@ func SendC2CResponse(client callapi.Client, err error, message *callapi.ActionMe //将真实id转为int userid64 userid64, errr := idmap.StoreIDv2(message.Params.UserID.(string)) if errr != nil { - mylog.Fatalf("Error storing ID: %v", err) + mylog.Errorf("Error storing ID: %v", err) } response.UserID = userid64 response.Echo = message.Echo diff --git a/handlers/send_msg.go b/handlers/send_msg.go index cc06add9..0f8d5eb7 100644 --- a/handlers/send_msg.go +++ b/handlers/send_msg.go @@ -313,19 +313,19 @@ func GetMessageIDByUseridAndGroupid(appID string, userID interface{}, groupID in //将真实id转为int userid64 groupid64, userid64, err = idmap.StoreIDv2Pro(GroupIDStr, userIDStr) if err != nil { - mylog.Fatalf("Error storing ID 210: %v", err) + mylog.Errorf("Error storing ID 210: %v", err) } } else { //将真实id转为int userid64, err = idmap.StoreIDv2(userIDStr) if err != nil { - mylog.Fatalf("Error storing ID 241: %v", err) + mylog.Errorf("Error storing ID 241: %v", err) return "" } //将真实id转为int groupid64, err = idmap.StoreIDv2(GroupIDStr) if err != nil { - mylog.Fatalf("Error storing ID 256: %v", err) + mylog.Errorf("Error storing ID 256: %v", err) return "" } } diff --git a/main.go b/main.go index 3dc697e1..fc2f12d4 100644 --- a/main.go +++ b/main.go @@ -282,6 +282,9 @@ func main() { log.Printf("注册 intents: %v\n", intent) + // 确保p包含conf + p = Processor.NewProcessorV2(api, apiV2, &conf.Settings) + // 启动session manager以管理websocket连接 // 指定需要启动的分片数为 2 的话可以手动修改 wsInfo if conf.Settings.ShardCount == 1 {