feat 初始化

This commit is contained in:
2026-10-29 10:12:22 +08:00
parent 332d812347
commit 09c1df8a22
81 changed files with 2211 additions and 7821 deletions

View File

@@ -0,0 +1,85 @@
package notice
import "git.hlsq.asia/alex/proto/topic"
const (
// 在线比赛通知
onlineMatchNoticeStart = iota // 在线比赛开始提醒
// 锦标赛通知
tournamentMatchRemind // 比赛提醒
tournamentMatchScoreAnnouncementPromoted // 成绩公告-晋级决赛
tournamentMatchScoreAnnouncementNotPromoted // 成绩公告-未晋级决赛
tournamentMatchScoreAnnouncementFinalEnd // 成绩公告-决赛结束后
tournamentMatchRewardDistribute // 奖励发放
tournamentMatchViolateNotice // 违规通报
)
type TemplateNoticeLang string
const (
ZhCN TemplateNoticeLang = "zh-CN"
)
var defaultLang = ZhCN
var noticeTemplate = map[int32]map[TemplateNoticeLang]topic.TemplateNoticeData{
onlineMatchNoticeStart: {
ZhCN: topic.TemplateNoticeData{
Title: "",
Msg: "您的队友正在等待您开局,点击返回>>",
XiaomiTemplateId: "P20513",
CustomParam: `{"type":1, "param":[]}`,
},
},
tournamentMatchRemind: {
ZhCN: topic.TemplateNoticeData{
Title: "比赛提醒",
Msg: "%v锦标赛第%v轮将于明天开启,记得前来参赛!",
XiaomiTemplateId: "P20086",
CustomParam: `{"type":2, "param":["%v", "1", "%v"]}`,
},
},
tournamentMatchScoreAnnouncementPromoted: {
ZhCN: topic.TemplateNoticeData{
Title: "成绩公告",
Msg: "恭喜您在%v锦标赛晋级赛获得第%v名,成功晋级决赛!",
XiaomiTemplateId: "P20088",
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
},
},
tournamentMatchScoreAnnouncementNotPromoted: {
ZhCN: topic.TemplateNoticeData{
Title: "成绩公告",
Msg: "很遗憾,您在%v锦标赛晋级赛中未能进入下一阶段比赛。感谢您的参与!",
XiaomiTemplateId: "P20088",
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
},
},
tournamentMatchScoreAnnouncementFinalEnd: {
ZhCN: topic.TemplateNoticeData{
Title: "成绩公告",
Msg: "恭喜您在%v锦标赛决赛获得第%v名!",
XiaomiTemplateId: "P20088",
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
},
},
tournamentMatchRewardDistribute: {
ZhCN: topic.TemplateNoticeData{
Title: "奖励发放",
Msg: "%v锦标赛于%v月%v日成功完赛,点击查看最终排名!",
XiaomiTemplateId: "P20084",
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
},
},
tournamentMatchViolateNotice: {
ZhCN: topic.TemplateNoticeData{
Title: "违规通报",
Msg: "后台检测到您在%v锦标赛第%v轮比赛中存在违规情况,本次比赛成绩无效,有任何疑问请联系客服。",
XiaomiTemplateId: "P20085",
CustomParam: `{"type":0, "param":[]}`,
},
},
}

120
template/notice/notice.go Normal file
View File

@@ -0,0 +1,120 @@
package notice
import (
"fmt"
"git.hlsq.asia/alex/proto/topic"
)
// GetOnlineMatchNoticeStart 在线比赛开始通知
// lang 语言
func GetOnlineMatchNoticeStart(lang ...TemplateNoticeLang) topic.TemplateNoticeData {
if len(lang) != 0 {
defaultLang = lang[0]
}
return noticeTemplate[onlineMatchNoticeStart][defaultLang]
}
// GetTournamentMatchRemind 比赛提醒
// name 锦标赛名称
// wheel 锦标赛轮次
// sn 锦标赛sn
// channel 频道名称
func GetTournamentMatchRemind(name string, wheel int32, sn int64, channelName string,
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
if len(lang) != 0 {
defaultLang = lang[0]
}
data := noticeTemplate[tournamentMatchRemind][defaultLang]
data.Msg = fmt.Sprintf(data.Msg, name, wheel)
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
return data
}
// GetTournamentMatchScoreAnnouncementPromoted 成绩公告-晋级决赛
// name 锦标赛名称
// ranking 排名
// sn 锦标赛sn
// channel 频道名称
func GetTournamentMatchScoreAnnouncementPromoted(name string, ranking int32, sn int64, channelName string,
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
if len(lang) != 0 {
defaultLang = lang[0]
}
data := noticeTemplate[tournamentMatchScoreAnnouncementPromoted][defaultLang]
data.Msg = fmt.Sprintf(data.Msg, name, ranking)
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
return data
}
// GetTournamentMatchScoreAnnouncementNotPromoted 成绩公告-未晋级决赛
// name 锦标赛名称
// sn 锦标赛sn
// channel 频道名称
func GetTournamentMatchScoreAnnouncementNotPromoted(name string, sn int64, channelName string,
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
if len(lang) != 0 {
defaultLang = lang[0]
}
data := noticeTemplate[tournamentMatchScoreAnnouncementNotPromoted][defaultLang]
data.Msg = fmt.Sprintf(data.Msg, name)
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
return data
}
// GetTournamentMatchScoreAnnouncementFinalEnd 成绩公告-决赛结束后
// name 锦标赛名称
// ranking 排名
// sn 锦标赛sn
// channel 频道名称
func GetTournamentMatchScoreAnnouncementFinalEnd(name string, ranking int32, sn int64, channelName string,
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
if len(lang) != 0 {
defaultLang = lang[0]
}
data := noticeTemplate[tournamentMatchScoreAnnouncementFinalEnd][defaultLang]
data.Msg = fmt.Sprintf(data.Msg, name, ranking)
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
return data
}
// GetTournamentMatchRewardDistribute 奖励发放
// name 锦标赛名称
// month 月份
// day 日
// sn 锦标赛sn
// channel 频道名称
func GetTournamentMatchRewardDistribute(name string, month, day int32, sn int64, channelName string,
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
if len(lang) != 0 {
defaultLang = lang[0]
}
data := noticeTemplate[tournamentMatchRewardDistribute][defaultLang]
data.Msg = fmt.Sprintf(data.Msg, name, month, day)
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
return data
}
// GetTournamentMatchViolateNotice 违规通报
// name 锦标赛名称
// wheel 锦标赛轮次
func GetTournamentMatchViolateNotice(name string, wheel int32, lang ...TemplateNoticeLang) topic.TemplateNoticeData {
if len(lang) != 0 {
defaultLang = lang[0]
}
data := noticeTemplate[tournamentMatchViolateNotice][defaultLang]
data.Msg = fmt.Sprintf(data.Msg, name, wheel)
return data
}

37
template/sms/lianlu.go Normal file
View File

@@ -0,0 +1,37 @@
package sms
//
//import "git.hlsq.asia/alex/proto/topic"
//
//type CountryCode string
//
//const (
// CountryCodeChina CountryCode = "+86" // 中国
// CountryCodeHongKong CountryCode = "+852" // 中国香港
// CountryCodeMacau CountryCode = "+853" // 中国澳门
// CountryCodeTaiwan CountryCode = "+886" // 中国台湾
// CountryCodeJapan CountryCode = "+81" // 日本
// CountryCodeSouthKorea CountryCode = "+82" // 韩国
//)
//
//const (
// TemplateCodeVerificationCodeChinese topic.SmsTemplateCode = "70630138" // 验证码(中文)
// TemplateCodeVerificationCodeEnglish topic.SmsTemplateCode = "54236" // 验证码(英文)
// TemplateCodeVerificationCodeJapanese topic.SmsTemplateCode = "54270" // 验证码(日文)
// TemplateCodeVerificationCodeKorean topic.SmsTemplateCode = "54271" // 验证码(韩文)
// TemplateCodeVerificationCodeChineseTraditional topic.SmsTemplateCode = "54272" // 验证码(繁体中文)
//)
//
//func GetTemplateCodeVerificationCodeByCountryCode(countryCode CountryCode) topic.SmsTemplateCode {
// switch countryCode {
// case CountryCodeChina:
// return TemplateCodeVerificationCodeChinese
// case CountryCodeHongKong, CountryCodeMacau, CountryCodeTaiwan:
// return TemplateCodeVerificationCodeChineseTraditional
// case CountryCodeJapan:
// return TemplateCodeVerificationCodeJapanese
// case CountryCodeSouthKorea:
// return TemplateCodeVerificationCodeKorean
// }
// return TemplateCodeVerificationCodeEnglish
//}

36
template/sms/zhongtian.go Normal file
View File

@@ -0,0 +1,36 @@
package sms
import "git.hlsq.asia/alex/proto/topic"
type CountryCode string
const (
CountryCodeChina CountryCode = "+86" // 中国
CountryCodeHongKong CountryCode = "+852" // 中国香港
CountryCodeMacau CountryCode = "+853" // 中国澳门
CountryCodeTaiwan CountryCode = "+886" // 中国台湾
CountryCodeJapan CountryCode = "+81" // 日本
CountryCodeSouthKorea CountryCode = "+82" // 韩国
)
const (
TemplateCodeVerificationCodeChinese topic.SmsTemplateCode = "【巢云互动】您的验证码是:%v,该验证码5分钟内有效,请勿泄漏于他人!" // 验证码(中文)
TemplateCodeVerificationCodeEnglish topic.SmsTemplateCode = "[NEXQUB] Your verification code is %v. It is valid for 5 minutes. Please do not share it with anyone." // 验证码(英文)
TemplateCodeVerificationCodeJapanese topic.SmsTemplateCode = "[NEXQUB] 認証コード:%v 有効期限5分。このコードを他人に教えないでください。" // 验证码(日文)
TemplateCodeVerificationCodeKorean topic.SmsTemplateCode = "[NEXQUB] 인증번호 %v 유효시간 5분. 타인과 공유하지 마세요." // 验证码(韩文)
TemplateCodeVerificationCodeChineseTraditional topic.SmsTemplateCode = "[NEXQUB] 您的驗證碼是:%v,5分鐘內有效,請勿向他人提供。" // 验证码(繁体中文)
)
func GetTemplateCodeVerificationCodeByCountryCode(countryCode CountryCode) topic.SmsTemplateCode {
switch countryCode {
case CountryCodeChina:
return TemplateCodeVerificationCodeChinese
case CountryCodeHongKong, CountryCodeMacau, CountryCodeTaiwan:
return TemplateCodeVerificationCodeChineseTraditional
case CountryCodeJapan:
return TemplateCodeVerificationCodeJapanese
case CountryCodeSouthKorea:
return TemplateCodeVerificationCodeKorean
}
return TemplateCodeVerificationCodeEnglish
}