上传聊天系统公告

This commit is contained in:
liwei1dao 2022-11-28 14:05:29 +08:00
parent 6d38ab1255
commit f697811733
8 changed files with 31 additions and 25 deletions

View File

@ -541,14 +541,21 @@ const (
type ChatSystemType int8
const (
///定时公告
TimedNotice ChatSystemType = 1
///用户登录通告
UserLoginNotice ChatSystemType = 2
///装备强化公告
EquipmentUpgradeNotice ChatSystemType = 3
///爬塔通关公告
PagodaPassNotice ChatSystemType = 4
ChatSystem1 ChatSystemType = 1 ///定时公告
ChatSystem2 ChatSystemType = 2 ///登录公告
ChatSystem3 ChatSystemType = 3 ///装备升级公告
ChatSystem4 ChatSystemType = 4 ///爬塔公告
ChatSystem5 ChatSystemType = 5 ///停机维护公告
ChatSystem10 ChatSystemType = 6 ///通关了赛季塔 【玩家名称】通关了赛季塔50层
ChatSystem11 ChatSystemType = 7 ///英雄升级 【玩家名称】已将【英雄名称】培养至60级
ChatSystem12 ChatSystemType = 8 ///英雄升星 【玩家名称】已将【英雄名称】培养至6星
ChatSystem13 ChatSystemType = 9 ///英雄技能培养 【玩家名称】已将【英雄名称】技能培养至满级!
ChatSystem14 ChatSystemType = 10 ///英雄共鸣 【玩家名称】已将【英雄名称】共鸣至满级!
ChatSystem15 ChatSystemType = 11 ///英雄觉醒 【玩家名称】已将【英雄名称】觉醒至满级!
ChatSystem16 ChatSystemType = 12 ///玩家升级 【玩家名称】达到了60级
ChatSystem17 ChatSystemType = 13 ///英雄招募 【玩家名称】在招募中获得了【英雄名称】!
ChatSystem18 ChatSystemType = 14 ///维京远征 【玩家名称】通关了火焰泰坦难度16
ChatSystem24 ChatSystemType = 15 ///狩猎 【玩家名称】通关了巨型猩猩难度8!
)
// 巨兽列车

View File

@ -195,9 +195,9 @@ type (
//推送消息到用户
SendUserChat(msg *pb.DBChat) (code pb.ErrorCode)
//广播系统消息
SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value int32, agrs ...string) (code pb.ErrorCode)
SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value0, value1 int32, agrs ...string) (code pb.ErrorCode)
//广播系统消息
SendSysChatToUser(session IUserSession, ctype ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode)
SendSysChatToUser(session IUserSession, ctype ChatSystemType, value0, value1 int32, agrs ...string) (code pb.ErrorCode)
}
//战斗系统

View File

@ -147,13 +147,13 @@ func (this *configureComp) GetChannelReadRecordNum() (max int32, err error) {
}
///获取校验聊天系统推送
func (this *configureComp) GetCheckChatSystem(ctype int32, value int32) (sitem *cfg.GameChatSystemData, ok bool) {
func (this *configureComp) GetCheckChatSystem(ctype int32, value0 int32, value1 int32) (sitem *cfg.GameChatSystemData, ok bool) {
this.lock.RLock()
vs, ok := this.chatsystem[ctype]
this.lock.RUnlock()
if ok {
for _, v := range vs {
if v.Data == value {
if v.Data == value0 && v.Data2 == value1 {
return v, true
}
}

View File

@ -2,7 +2,6 @@ package chat
import (
"context"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
@ -217,12 +216,12 @@ func (this *Chat) SendUserChat(msg *pb.DBChat) (code pb.ErrorCode) {
}
//广播系统消息
func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value int32, agrs ...string) (code pb.ErrorCode) {
func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value0 int32, value1 int32, agrs ...string) (code pb.ErrorCode) {
var (
jsonStr []byte
err error
)
if st, ok := this.configure.GetCheckChatSystem(int32(ctype), value); ok {
if st, ok := this.configure.GetCheckChatSystem(int32(ctype), value0, value1); ok {
msg := &pb.DBChat{
Channel: pb.ChatChannel_System,
Ctype: pb.ChatType_Text,
@ -233,7 +232,7 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter
AppendInt: int64(st.Key),
AppendStrs: agrs,
}
if ctype == comm.EquipmentUpgradeNotice { //装备分享
if ctype == comm.ChatSystem3 { //装备分享
msg.Ctype = pb.ChatType_Share
if appenddata != nil {
if jsonStr, err = json.Marshal(appenddata); err != nil {
@ -274,12 +273,12 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter
}
//广播系统消息
func (this *Chat) SendSysChatToUser(session comm.IUserSession, ctype comm.ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode) {
if st, ok := this.configure.GetCheckChatSystem(int32(ctype), value); ok {
func (this *Chat) SendSysChatToUser(session comm.IUserSession, ctype comm.ChatSystemType, value0, value1 int32, agrs ...string) (code pb.ErrorCode) {
if st, ok := this.configure.GetCheckChatSystem(int32(ctype), value0, value1); ok {
msg := &pb.DBChat{
Channel: pb.ChatChannel_System,
Ctime: time.Now().Unix(),
Content: fmt.Sprintf(st.Text, agrs...),
Channel: pb.ChatChannel_System,
Ctime: time.Now().Unix(),
AppendInt: int64(st.Key),
}
session.SendMsg(string(this.GetType()), "message", &pb.ChatMessagePush{Chat: msg})
}

View File

@ -189,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, conf.Id)
this.module.chat.SendSysChatToWorld(comm.ChatSystem5, equipment, equipment.Lv, 0, user.Name, conf.Id)
// } else {
// this.module.Errorf("GetColor err:%s", err.Error())
// }

View File

@ -90,7 +90,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, nil, pagoda.PagodaId, user.Name)
this.chat.SendSysChatToWorld(comm.ChatSystem4, nil, pagoda.PagodaId, 0, user.Name)
} else {
this.module.Errorf("no found userdata uid:%s", session.GetUserId())
}

View File

@ -55,7 +55,7 @@ func (this *ChatComp) Start() (err error) {
confs := v.(*cfg.GameChatSystem)
for _, v1 := range confs.GetDataMap() {
if v1.Type == int32(comm.TimedNotice) { //处理定时任务
if v1.Type == int32(comm.ChatSystem1) { //处理定时任务
weekStr := ""
for _, w := range v1.Week {
weekStr += fmt.Sprintf("%d,", w)

View File

@ -151,7 +151,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
// 检查特权 并发送每日邮件
this.module.ModulePrivilege.QueryPrivilege(session)
//推送登录公告
this.chat.SendSysChatToUser(session, comm.UserLoginNotice, 0)
this.chat.SendSysChatToUser(session, comm.ChatSystem2, 0, 0)
mail := &pb.DBMailData{
ObjId: primitive.NewObjectID().Hex(),
Uid: user.Uid,