diff --git a/bot/handlers.go b/bot/handlers.go index 3aee5c0..7d2bb7f 100644 --- a/bot/handlers.go +++ b/bot/handlers.go @@ -415,7 +415,7 @@ func AddToQueue(ctx *ext.Context, update *ext.Update) error { ReplyMessageID: record.ReplyMessageID, FileMessageID: record.MessageID, ReplyChatID: record.ReplyChatID, - UserID: update.EffectiveUser().GetID(), + UserID: update.GetUserChat().GetID(), }) entityBuilder := entity.Builder{} diff --git a/bot/utils.go b/bot/utils.go index 4bc65e5..7b59386 100644 --- a/bot/utils.go +++ b/bot/utils.go @@ -49,6 +49,9 @@ func getSelectStorageMarkup(userChatID int64, fileChatID, fileMessageID int) (*t return nil, err } storages := storage.GetUserStorages(user.ChatID) + if len(storages) == 0 { + return nil, ErrNoStorages + } buttons := make([]tg.KeyboardButtonClass, 0) for _, storage := range storages { @@ -199,7 +202,7 @@ func ProvideSelectMessage(ctx *ext.Context, update *ext.Update, file *types.File } else { text, entities = entityBuilder.Complete() } - markup, err := getSelectStorageMarkup(update.EffectiveUser().GetID(), int(chatID), fileMsgID) + markup, err := getSelectStorageMarkup(update.GetUserChat().GetID(), int(chatID), fileMsgID) if errors.Is(err, ErrNoStorages) { logger.L.Errorf("Failed to get select storage markup: %s", err) ctx.EditMessage(update.EffectiveChat().GetID(), &tg.MessagesEditMessageRequest{ diff --git a/config.example.toml b/config.example.toml index 5b0a1e9..d64e2a8 100644 --- a/config.example.toml +++ b/config.example.toml @@ -21,6 +21,7 @@ url = "socks5://127.0.0.1:7890" name = "本机1" # 存储类型, 目前可用: local , alist , webdav type = "local" +# 启用存储 enable = true base_path = "./downloads" @@ -33,7 +34,7 @@ base_path = "./downloads/2" [[storages]] name = "MyAlist" type = "alist" -enable = true +enable = false base_path = '/' url = 'https://alist.com' username = 'admin' @@ -48,7 +49,7 @@ token_exp = 86400 name = "MyWebdav" type = "webdav" base_path = '/path/telegram' -enable = true +enable = false url = 'https://example.com/dav' username = 'username' password = 'password' @@ -59,7 +60,7 @@ password = 'password' # user id id = 123456 # 存储名称过滤列表 -storages = ["MyAlist", "本机1"] +storages = ["本机1"] # 开启黑名单模式, 过滤列表中的存储将无法使用, 默认为白名单模式 blacklist = false