diff --git a/comm/imodule.go b/comm/imodule.go index b44876301..7d570d645 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -195,7 +195,7 @@ type ( //推送消息到用户 SendUserChat(msg *pb.DBChat) (code pb.ErrorCode) //广播系统消息 - SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (code pb.ErrorCode) + SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value int32, agrs ...string) (code pb.ErrorCode) //广播系统消息 SendSysChatToUser(session IUserSession, ctype ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode) } diff --git a/modules/chat/module.go b/modules/chat/module.go index c6f7010f9..b7c0d592f 100644 --- a/modules/chat/module.go +++ b/modules/chat/module.go @@ -217,19 +217,21 @@ func (this *Chat) SendUserChat(msg *pb.DBChat) (code pb.ErrorCode) { } //广播系统消息 -func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (code pb.ErrorCode) { +func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value int32, agrs ...string) (code pb.ErrorCode) { var ( jsonStr []byte err error ) if st, ok := this.configure.GetCheckChatSystem(int32(ctype), value); ok { msg := &pb.DBChat{ - Channel: pb.ChatChannel_System, - Ctype: pb.ChatType_Text, - Stag: this.service.GetTag(), - Ctime: configure.Now().Unix(), - Content: fmt.Sprintf(st.Text, agrs...), - Display: st.Display, + Channel: pb.ChatChannel_System, + Ctype: pb.ChatType_Text, + Stag: this.service.GetTag(), + Ctime: configure.Now().Unix(), + Content: "", + Display: st.Display, + AppendInt: int64(st.Key), + AppendStrs: agrs, } if ctype == comm.EquipmentUpgradeNotice { //装备分享 msg.Ctype = pb.ChatType_Share @@ -238,8 +240,8 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter this.Errorf("err:%v", err) } else { data := map[string]interface{}{ - agrs[1].(string): map[string]interface{}{ - "key": agrs[1].(string), + agrs[1]: map[string]interface{}{ + "key": agrs[1], "appendStr": string(jsonStr), "itemType": pb.ChatType_EquipmentShare, }, diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index ff0450b17..6a5f70ec8 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -2,7 +2,6 @@ package equipment import ( "crypto/rand" - "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" @@ -190,7 +189,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade if user = this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { // var color *cfg.GameGameColorData // if color, err = this.module.configure.GetColor(conf.Color); err == nil { - this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, user.Name, fmt.Sprintf("[%s]", conf.Name)) + this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, user.Name, conf.Id) // } else { // this.module.Errorf("GetColor err:%s", err.Error()) // } diff --git a/modules/timer/chat.go b/modules/timer/chat.go index 12cf51423..331f8ea61 100644 --- a/modules/timer/chat.go +++ b/modules/timer/chat.go @@ -68,7 +68,7 @@ func (this *ChatComp) Start() (err error) { cronStr := fmt.Sprintf("0 %d %d ? * %s", v1.TimeM, v1.TimeH, weekStr) this.module.Debug("注册Chat广播公告消息", log.Fields{"cronStr": cronStr, "text": v1.Text}) - if id, err = cron.AddFunc(cronStr, this.chatNoticen(v1.Text)); err != nil { + if id, err = cron.AddFunc(cronStr, this.chatNoticen(v1)); err != nil { this.module.Errorf("cron.AddFunc:%s err:%v", cronStr, err) continue } @@ -80,16 +80,18 @@ func (this *ChatComp) Start() (err error) { return } -func (this *ChatComp) chatNoticen(content string) func() { +func (this *ChatComp) chatNoticen(sys *cfg.GameChatSystemData) func() { return func() { msg := &pb.DBChat{ - Channel: pb.ChatChannel_System, - Stag: this.service.GetTag(), - Ctime: configure.Now().Unix(), - Content: content, + Channel: pb.ChatChannel_System, + Stag: this.service.GetTag(), + Ctime: configure.Now().Unix(), + Content: "", + Display: sys.Display, + AppendInt: int64(sys.Key), } data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg}) - this.module.Debug("广播公告消息", log.Fields{"chat": content}) + this.module.Debug("广播公告消息", log.Fields{"chat": sys.Text}) if err := this.module.service.RpcBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{ MainType: string(comm.ModuleChat), SubType: "message",