mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-07-09 06:21:52 +08:00
feat: add ForceFile option to TelegramStorageConfig and update Save method
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
type TelegramStorageConfig struct {
|
type TelegramStorageConfig struct {
|
||||||
BaseConfig
|
BaseConfig
|
||||||
ChatID int64 `toml:"chat_id" mapstructure:"chat_id" json:"chat_id"`
|
ChatID int64 `toml:"chat_id" mapstructure:"chat_id" json:"chat_id"`
|
||||||
|
ForceFile bool `toml:"force_file" mapstructure:"force_file" json:"force_file"`
|
||||||
RateLimit int `toml:"rate_limit" mapstructure:"rate_limit" json:"rate_limit"`
|
RateLimit int `toml:"rate_limit" mapstructure:"rate_limit" json:"rate_limit"`
|
||||||
RateBurst int `toml:"rate_burst" mapstructure:"rate_burst" json:"rate_burst"`
|
RateBurst int `toml:"rate_burst" mapstructure:"rate_burst" json:"rate_burst"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (t *Telegram) Save(ctx context.Context, r io.Reader, storagePath string) er
|
|||||||
// ==1, 视作只有文件名, 存储到配置文件中的 chat_id
|
// ==1, 视作只有文件名, 存储到配置文件中的 chat_id
|
||||||
// ==2, parts[0]: 视作要存储到的 chat_id, parts[1]: filename
|
// ==2, parts[0]: 视作要存储到的 chat_id, parts[1]: filename
|
||||||
|
|
||||||
parts := slice.Compact(strings.SplitN(strings.TrimPrefix(storagePath, "/"), "/", 4))
|
parts := slice.Compact(strings.Split(strings.TrimPrefix(storagePath, "/"), "/"))
|
||||||
filename := ""
|
filename := ""
|
||||||
chatID := t.config.ChatID
|
chatID := t.config.ChatID
|
||||||
if len(parts) >= 1 {
|
if len(parts) >= 1 {
|
||||||
@@ -136,7 +136,7 @@ func (t *Telegram) Save(ctx context.Context, r io.Reader, storagePath string) er
|
|||||||
caption := styling.Plain(filename)
|
caption := styling.Plain(filename)
|
||||||
docb := message.UploadedDocument(file, caption).
|
docb := message.UploadedDocument(file, caption).
|
||||||
Filename(filename).
|
Filename(filename).
|
||||||
ForceFile(false).
|
ForceFile(t.config.ForceFile).
|
||||||
MIME(mtype.String())
|
MIME(mtype.String())
|
||||||
|
|
||||||
var media message.MediaOption = docb
|
var media message.MediaOption = docb
|
||||||
|
|||||||
Reference in New Issue
Block a user