mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-07-12 16:02:05 +08:00
fix: remove unnecessary chat ID validation and constant usage in Save method
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/duke-git/lancet/v2/slice"
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
"github.com/duke-git/lancet/v2/validator"
|
"github.com/duke-git/lancet/v2/validator"
|
||||||
"github.com/gabriel-vasile/mimetype"
|
"github.com/gabriel-vasile/mimetype"
|
||||||
"github.com/gotd/td/constant"
|
|
||||||
"github.com/gotd/td/telegram/message"
|
"github.com/gotd/td/telegram/message"
|
||||||
"github.com/gotd/td/telegram/message/styling"
|
"github.com/gotd/td/telegram/message/styling"
|
||||||
"github.com/gotd/td/telegram/uploader"
|
"github.com/gotd/td/telegram/uploader"
|
||||||
@@ -94,10 +93,6 @@ func (t *Telegram) Save(ctx context.Context, r io.Reader, storagePath string) er
|
|||||||
// id不合法时使用配置文件中的 chat_id
|
// id不合法时使用配置文件中的 chat_id
|
||||||
log.FromContext(ctx).Warnf("Failed to parse chat ID from path, using configured chat_id: %s", err)
|
log.FromContext(ctx).Warnf("Failed to parse chat ID from path, using configured chat_id: %s", err)
|
||||||
cid = chatID
|
cid = chatID
|
||||||
} else {
|
|
||||||
if cid > constant.MaxTDLibChannelID || cid > constant.MaxTDLibChatID || cid > constant.MaxTDLibUserID {
|
|
||||||
cid = chatID
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
chatID = cid
|
chatID = cid
|
||||||
}
|
}
|
||||||
@@ -108,10 +103,6 @@ func (t *Telegram) Save(ctx context.Context, r io.Reader, storagePath string) er
|
|||||||
if filename == "" {
|
if filename == "" {
|
||||||
filename = xid.New().String() + mtype.Extension()
|
filename = xid.New().String() + mtype.Extension()
|
||||||
}
|
}
|
||||||
|
|
||||||
if chatID < 0 {
|
|
||||||
chatID = chatID - constant.ZeroTDLibChannelID
|
|
||||||
}
|
|
||||||
peer := tctx.PeerStorage.GetInputPeerById(chatID)
|
peer := tctx.PeerStorage.GetInputPeerById(chatID)
|
||||||
if peer == nil {
|
if peer == nil {
|
||||||
return fmt.Errorf("failed to get input peer for chat ID %d", chatID)
|
return fmt.Errorf("failed to get input peer for chat ID %d", chatID)
|
||||||
|
|||||||
Reference in New Issue
Block a user