diff --git a/comm/imodule.go b/comm/imodule.go index cc7aeec7b..3953a0657 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -143,7 +143,7 @@ type ( //推送消息到用户 SendUserChat(msg *pb.DBChat) (code pb.ErrorCode) //广播系统消息 - SendSysChatToWorld(ctype ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode) + SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (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 339679b8c..cdd3478b2 100644 --- a/modules/chat/module.go +++ b/modules/chat/module.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/event" + "go_dreamfactory/lego/utils/codec/json" "go_dreamfactory/modules" "go_dreamfactory/pb" "time" @@ -93,14 +94,29 @@ func (this *Chat) SendUserChat(msg *pb.DBChat) (code pb.ErrorCode) { } //广播系统消息 -func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode) { +func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (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: time.Now().Unix(), Content: fmt.Sprintf(st.Text, agrs...), } + if ctype == comm.EquipmentUpgradeNotice { //装备分享 + msg.Ctype = pb.ChatType_EquipmentShare + } + if appenddata != nil { + if jsonStr, err = json.Marshal(appenddata); err != nil { + this.Errorf("err:%v", err) + } else { + msg.AppendStr = string(jsonStr) + } + } code = this.modelChat.sendSystemChat(msg) } return diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index 32bd4d971..32220652f 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -172,7 +172,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade this.module.ModuleRtask.SendToRtask(session, comm.Rtype47, 1) //聊天系统通知 if user = this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { - this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment.Lv, user.Name, conf.Name) + this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, user.Name, conf.Name) } else { this.module.Errorf("no found userdata uid:%s", session.GetUserId()) } diff --git a/modules/pagoda/api_challengeover.go b/modules/pagoda/api_challengeover.go index 04d5627a9..b88acfccb 100644 --- a/modules/pagoda/api_challengeover.go +++ b/modules/pagoda/api_challengeover.go @@ -82,7 +82,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal session.SendMsg(string(this.module.GetType()), PagodaChallengeOverResp, &pb.PagodaChallengeOverResp{Data: pagoda}) if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { - this.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, pagoda.PagodaId, user.Name) + this.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, nil, pagoda.PagodaId, user.Name) } else { this.module.Errorf("no found userdata uid:%s", session.GetUserId()) } diff --git a/pb/chat_db.pb.go b/pb/chat_db.pb.go index c3276f476..5e08ad401 100644 --- a/pb/chat_db.pb.go +++ b/pb/chat_db.pb.go @@ -79,8 +79,10 @@ func (ChatChannel) EnumDescriptor() ([]byte, []int) { type ChatType int32 const ( - ChatType_Text ChatType = 0 //文泵聊天消息 - ChatType_Moonfantasy ChatType = 1 //月子秘境消息 + ChatType_Text ChatType = 0 //文泵聊天消息 + ChatType_Moonfantasy ChatType = 1 //月子秘境消息 + ChatType_HeroShare ChatType = 2 //英雄分享 + ChatType_EquipmentShare ChatType = 3 //装备分享 ) // Enum value maps for ChatType. @@ -88,10 +90,14 @@ var ( ChatType_name = map[int32]string{ 0: "Text", 1: "Moonfantasy", + 2: "HeroShare", + 3: "EquipmentShare", } ChatType_value = map[string]int32{ - "Text": 0, - "Moonfantasy": 1, + "Text": 0, + "Moonfantasy": 1, + "HeroShare": 2, + "EquipmentShare": 3, } ) @@ -324,10 +330,13 @@ var file_chat_chat_db_proto_rawDesc = []byte{ 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x6e, 0x69, 0x6f, 0x6e, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x53, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x10, 0x04, 0x2a, 0x25, 0x0a, 0x08, 0x43, 0x68, 0x61, 0x74, 0x54, + 0x79, 0x73, 0x74, 0x65, 0x6d, 0x10, 0x04, 0x2a, 0x48, 0x0a, 0x08, 0x43, 0x68, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x65, 0x78, 0x74, 0x10, 0x00, 0x12, 0x0f, 0x0a, - 0x0b, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x10, 0x01, 0x42, 0x06, - 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0b, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x10, 0x01, 0x12, 0x0d, + 0x0a, 0x09, 0x48, 0x65, 0x72, 0x6f, 0x53, 0x68, 0x61, 0x72, 0x65, 0x10, 0x02, 0x12, 0x12, 0x0a, + 0x0e, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x68, 0x61, 0x72, 0x65, 0x10, + 0x03, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var (