Skip to content

Commit

Permalink
Implement feature
Browse files Browse the repository at this point in the history
  • Loading branch information
oissevalt committed Oct 15, 2024
1 parent ec9673e commit bd13a15
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dice/ext_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,15 @@ func RegisterBuiltinExtLog(self *Dice) {

VarSetValueStr(ctx, "$t记录名称", name)
VarSetValueInt64(ctx, "$t当前记录条数", lines)
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:记录_开启_成功"))

logEnabledPrompt := DiceFormatTmpl(ctx, "日志:记录_开启_成功")
// TODO: 到这里相当于全文 query 了两遍日志。可以优化吗?
lastRecord, err := model.LogGetLastLine(ctx.Dice.DBLogs, group.GroupID, name)
if err == nil {
logEnabledPrompt = fmt.Sprintf("[CQ:reply,id=%v] %s", lastRecord.RawMsgID, logEnabledPrompt)
}

ReplyToSender(ctx, msg, logEnabledPrompt)
} else {
VarSetValueStr(ctx, "$t记录名称", name)
ReplyToSender(ctx, msg, DiceFormatTmpl(ctx, "日志:记录_开启_失败_无此记录"))
Expand Down

0 comments on commit bd13a15

Please sign in to comment.