fix: update watch command help to bot api style id, close #151

This commit is contained in:
krau
2025-12-08 10:22:43 +08:00
parent c974791dc0
commit 32cc1e4b5a
4 changed files with 10 additions and 6 deletions

View File

@@ -34,7 +34,7 @@ func (m matchedStorName) String() string {
} }
// can we use this storage name directly? // can we use this storage name directly?
func (m matchedStorName) IsUsable() bool { func (m matchedStorName) Usable() bool {
return m != "" && m != rule.RuleStorNameChosen return m != "" && m != rule.RuleStorNameChosen
} }

View File

@@ -41,7 +41,7 @@ func CreateAndAddTGFileTaskWithEdit(ctx *ext.Context, userID int64, stor storage
if matchedDirPath != "" { if matchedDirPath != "" {
dirPath = matchedDirPath.String() dirPath = matchedDirPath.String()
} }
if matchedStorageName.IsUsable() { if matchedStorageName.Usable() {
stor, err = storage.GetStorageByUserIDAndName(ctx, user.ChatID, matchedStorageName.String()) stor, err = storage.GetStorageByUserIDAndName(ctx, user.ChatID, matchedStorageName.String())
if err != nil { if err != nil {
logger.Errorf("Failed to get storage by user ID and name: %s", err) logger.Errorf("Failed to get storage by user ID and name: %s", err)
@@ -111,7 +111,7 @@ func CreateAndAddBatchTGFileTaskWithEdit(ctx *ext.Context, userID int64, stor st
return stor.Name(), ruleutil.MatchedDirPath(dirPath) return stor.Name(), ruleutil.MatchedDirPath(dirPath)
} }
storname := storName.String() storname := storName.String()
if !storName.IsUsable() { if !storName.Usable() {
storname = stor.Name() storname = stor.Name()
} }
return storname, dirP return storname, dirP

View File

@@ -228,7 +228,7 @@ func listenMediaMessageEvent(ch chan userclient.MediaMessageEvent) {
goto startCreateTask goto startCreateTask
} }
dirPath = matchedDirPath.String() dirPath = matchedDirPath.String()
if matchedStorageName.IsUsable() { if matchedStorageName.Usable() {
stor, err = storage.GetStorageByUserIDAndName(ctx, user.ChatID, matchedStorageName.String()) stor, err = storage.GetStorageByUserIDAndName(ctx, user.ChatID, matchedStorageName.String())
if err != nil { if err != nil {
logger.Errorf("Failed to get storage by user ID and name: %s", err) logger.Errorf("Failed to get storage by user ID and name: %s", err)

View File

@@ -32,6 +32,10 @@ bot:
/save [自定义文件名] - 保存文件 /save [自定义文件名] - 保存文件
/dir - 管理存储目录 /dir - 管理存储目录
/rule - 管理规则 /rule - 管理规则
/config - 修改配置
/fnametmpl - 设置文件自定义命名模板
/parser - 管理解析器插件
/watch - 监听聊天并自动保存 (UserBot)
/update - 检查更新并升级 /update - 检查更新并升级
使用帮助: https://sabot.unv.app/usage 使用帮助: https://sabot.unv.app/usage
@@ -57,6 +61,6 @@ bot:
- [filter]: 可选, 格式为 过滤器类型:表达式 , 所有支持类型的过滤器请查看文档 - [filter]: 可选, 格式为 过滤器类型:表达式 , 所有支持类型的过滤器请查看文档
命令示例: 命令示例:
/watch 2229835658 msgre:.*plana.* /watch -1002229835658 msgre:.*plana.*
这将监听 ID 为 2229835658 的聊天, 并转存所有包含 "plana" 的媒体消息 这将监听 ID 为 -1002229835658 的聊天, 并转存所有包含 "plana" 的媒体消息