Skip to content

Commit

Permalink
feat(log): sn回复语自定义
Browse files Browse the repository at this point in the history
  • Loading branch information
MX-fox committed Aug 12, 2024
1 parent 15358a8 commit f75360e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
27 changes: 27 additions & 0 deletions dice/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,19 @@ func setupBaseTextTemplate(d *Dice) {
"记录_上传_失败": {
{`跑团日志上传失败:{$t错误原因}\n若未出现线上日志地址,可换时间重试,或联系骰主在data/default/log-exports路径下取出日志\n文件名: 群号_日志名_随机数.zip\n注意此文件log end/get后才会生成`, 1},
},
// 1.5.0+
"名片_coc": {
{`已自动设置名片为COC7格式: {$t名片格式}\n如有权限会持续自动改名片。使用.sn off可关闭`, 1},
},
"名片_dnd": {
{`已自动设置名片为DND5E格式: {$t名片格式}\n如有权限会持续自动改名片。使用.sn off可关闭`, 1},
},
"名片_none": {
{`已自动设置名片为空白格式: {$t名片格式}\n如有权限会持续自动改名片。使用.sn off可关闭`, 1},
},
"名片_expr": {
{`应用玩家自设,预览文本: {$t名片格式}`, 1},
},
},
}

Expand Down Expand Up @@ -1822,6 +1835,20 @@ func setupBaseTextTemplate(d *Dice) {
SubType: ".log end",
Vars: []string{"$t错误原因"},
},

// 1.5.0+
"名片_coc": {
SubType: ".sn",
},
"名片_dnd": {
SubType: ".sn",
},
"名片_none": {
SubType: ".sn",
},
"名片_expr": {
SubType: ".sn",
},
},
}
d.TextMapRaw = texts
Expand Down
12 changes: 8 additions & 4 deletions dice/ext_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,9 @@ func RegisterBuiltinExtLog(self *Dice) {
if errors.Is(err, ErrGroupCardOverlong) {
return handleOverlong(ctx, msg, text)
}
VarSetValueStr(ctx, "$t名片格式", text)
// 玩家 SAN60 HP10/10 DEX65
ReplyToSender(ctx, msg, "已自动设置名片为COC7格式: "+text+"\n如有权限会持续自动改名片。使用.sn off可关闭")
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_coc"))
case "dnd", "dnd5e":
// PW{pw}
ctx.Player.AutoSetNameTemplate = "{$t玩家_RAW} HP{hp}/{hpmax} AC{ac} DC{dc} PP{pp}"
Expand All @@ -623,16 +624,18 @@ func RegisterBuiltinExtLog(self *Dice) {
if errors.Is(err, ErrGroupCardOverlong) {
return handleOverlong(ctx, msg, text)
}
VarSetValueStr(ctx, "$t名片格式", text)
// 玩家 HP10/10 AC15 DC15 PW10
ReplyToSender(ctx, msg, "已自动设置名片为DND5E格式: "+text+"\n如有权限会持续自动改名片。使用.sn off可关闭")
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_dnd"))
case "none":
ctx.Player.AutoSetNameTemplate = "{$t玩家_RAW}"
ctx.Player.UpdatedAtTime = time.Now().Unix()
text, err := SetPlayerGroupCardByTemplate(ctx, "{$t玩家_RAW}")
if errors.Is(err, ErrGroupCardOverlong) { // 大约不至于会走到这里,但是为了统一也这样写了
return handleOverlong(ctx, msg, text)
}
ReplyToSender(ctx, msg, "已自动设置名片为空白格式: "+text+"\n如有权限会持续自动改名片。使用.sn off可关闭")
VarSetValueStr(ctx, "$t名片格式", text)
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_none"))
case "off", "cancel":
_, _ = SetPlayerGroupCardByTemplate(ctx, "{$t玩家_RAW}")
ctx.Player.AutoSetNameTemplate = ""
Expand All @@ -659,7 +662,8 @@ func RegisterBuiltinExtLog(self *Dice) {
return handleOverlong(ctx, msg, text)
} else {
ctx.Player.UpdatedAtTime = time.Now().Unix()
ReplyToSender(ctx, msg, "应用玩家自设,预览文本: "+text)
VarSetValueStr(ctx, "$t名片格式", text)
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:名片_expr"))
}
}
default:
Expand Down

0 comments on commit f75360e

Please sign in to comment.