* refactor: a big refactor. wip * refactor: port handle file * refactor: place all handlers * fix: task info nil pointer * feat: enhance task progress tracking and context management * feat: cancel task * feat: stream mode * feat: silent mode * feat: dir cmd * refactor: remove unused old file * feat: rule cmd * feat: handle silent mode * feat: batch task * fix: batch task progress and temp file cleanup * refactor: update file creation and cleanup methods for better resource management * feat: add save command with silent mode handling * feat: message link * feat: update message prompts to include file count in storage selection * feat: slient save links * refactor: reduce dup code * feat: rule type * feat: chose dir * feat: refactor file handling and storage rules, improve error handling and logging * feat: rule mode * feat: telegraph pics * fix: tphpics nil pointer and inaccurate dirpath * feat: silent save telegraph * feat: add suffix to avoid file overwrite * feat: new storage telegram * chore: tidy go mod
33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package msgelem
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/gotd/td/telegram/message/styling"
|
|
"github.com/krau/SaveAny-Bot/database"
|
|
)
|
|
|
|
func BuildRuleHelpStyling(enabled bool, rules []database.Rule) []styling.StyledTextOption {
|
|
return []styling.StyledTextOption{
|
|
styling.Bold("使用方法: /rule <操作> <参数...>"),
|
|
styling.Bold(fmt.Sprintf("\n当前已%s规则模式", map[bool]string{true: "启用", false: "禁用"}[enabled])),
|
|
styling.Plain("\n\n可用操作:\n"),
|
|
styling.Code("switch"),
|
|
styling.Plain(" - 开关规则模式\n"),
|
|
styling.Code("add"),
|
|
styling.Plain(" <类型> <数据> <存储名> <路径> - 添加规则\n"),
|
|
styling.Code("del"),
|
|
styling.Plain(" <规则ID> - 删除规则\n"),
|
|
styling.Plain("\n当前已添加的规则:\n"),
|
|
styling.Blockquote(func() string {
|
|
var sb strings.Builder
|
|
for _, rule := range rules {
|
|
ruleText := fmt.Sprintf("%s %s %s %s", rule.Type, rule.Data, rule.StorageName, rule.DirPath)
|
|
sb.WriteString(fmt.Sprintf("%d: %s\n", rule.ID, ruleText))
|
|
}
|
|
return sb.String()
|
|
}(), true),
|
|
}
|
|
}
|