Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0853536d9 | ||
|
|
15cf81e1bd | ||
|
|
ae48bd52bf |
@@ -99,13 +99,6 @@ func GetFilesFromUpdateLinkMessageWithReplyEdit(ctx *ext.Context, update *ext.Up
|
|||||||
logger.Debugf("message %d has no media", msg.GetID())
|
logger.Debugf("message %d has no media", msg.GetID())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// var opt tfile.TGFileOption
|
|
||||||
// switch user.FilenameStrategy {
|
|
||||||
// case fnamest.Message.String():
|
|
||||||
// opt = tfile.WithName(tgutil.GenFileNameFromMessage(*msg))
|
|
||||||
// default:
|
|
||||||
// opt = tfile.WithNameIfEmpty(tgutil.GenFileNameFromMessage(*msg))
|
|
||||||
// }
|
|
||||||
opts := mediautil.TfileOptions(ctx, user, msg)
|
opts := mediautil.TfileOptions(ctx, user, msg)
|
||||||
file, err := tfile.FromMediaMessage(media, client, msg, opts...)
|
file, err := tfile.FromMediaMessage(media, client, msg, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -138,7 +131,7 @@ func GetFilesFromUpdateLinkMessageWithReplyEdit(ctx *ext.Context, update *ext.Up
|
|||||||
}
|
}
|
||||||
groupID, isGroup := msg.GetGroupedID()
|
groupID, isGroup := msg.GetGroupedID()
|
||||||
if isGroup && groupID != 0 && !linkUrl.Query().Has("single") {
|
if isGroup && groupID != 0 && !linkUrl.Query().Has("single") {
|
||||||
gmsgs, err := tgutil.GetGroupedMessages(ctx, chatId, msg)
|
gmsgs, err := tgutil.GetGroupedMessages(tctx, chatId, msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("failed to get grouped messages: %s", err)
|
logger.Errorf("failed to get grouped messages: %s", err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ func GetGroupedMessages(ctx *ext.Context, chatID int64, msg *tg.Message) ([]*tg.
|
|||||||
}
|
}
|
||||||
msgs, err := GetMessagesRange(ctx, chatID, minID, maxID)
|
msgs, err := GetMessagesRange(ctx, chatID, minID, maxID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get grouped messages: %w", err)
|
return nil, err
|
||||||
}
|
}
|
||||||
groupedMessages := make([]*tg.Message, 0, len(msgs))
|
groupedMessages := make([]*tg.Message, 0, len(msgs))
|
||||||
for _, m := range msgs {
|
for _, m := range msgs {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
func ParseChatID(ctx *ext.Context, idOrUsername string) (int64, error) {
|
func ParseChatID(ctx *ext.Context, idOrUsername string) (int64, error) {
|
||||||
idOrUsername = strings.TrimPrefix(idOrUsername, "@")
|
idOrUsername = strings.TrimPrefix(idOrUsername, "@")
|
||||||
if validator.IsIntStr(idOrUsername) {
|
if validator.IsIntStr(idOrUsername) {
|
||||||
chatID, err := strconv.Atoi(strings.TrimPrefix(idOrUsername, "-100"))
|
chatID, err := strconv.Atoi(idOrUsername)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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