mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-11 17:29:40 +08:00
feat: add import command and batch import functionality
- Implemented the `/import` command to allow users to import files from storage to Telegram. - Added support for listing files in storage and filtering based on regex patterns. - Created a batch import task to handle multiple file uploads concurrently. - Introduced progress tracking for batch imports, providing real-time updates to users. - Enhanced storage interfaces to support file listing and reading capabilities. - Updated localization files for the new import command and its usage instructions. - Added utility functions for file size formatting and speed calculation. - Refactored Telegram storage handling to support reading from non-seekable streams.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
"github.com/krau/SaveAny-Bot/config"
|
||||
storenum "github.com/krau/SaveAny-Bot/pkg/enums/storage"
|
||||
)
|
||||
|
||||
var UserStorages = make(map[int64][]Storage)
|
||||
@@ -79,3 +80,14 @@ func LoadStorages(ctx context.Context) {
|
||||
UserStorages[int64(user)] = GetUserStorages(ctx, int64(user))
|
||||
}
|
||||
}
|
||||
|
||||
// GetTelegramStorageByUserID returns the first enabled Telegram storage for the user
|
||||
func GetTelegramStorageByUserID(ctx context.Context, chatID int64) (Storage, error) {
|
||||
storages := GetUserStorages(ctx, chatID)
|
||||
for _, stor := range storages {
|
||||
if stor.Type() == storenum.Telegram {
|
||||
return stor, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("no telegram storage found for user %d", chatID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user