chore: update tg message handler

This commit is contained in:
Steven
2024-03-12 22:48:53 +08:00
parent 425e85f0f9
commit 6b6edc3791
4 changed files with 50 additions and 22 deletions

View File

@@ -13,7 +13,6 @@ func (b *Bot) handleSingleMessages(ctx context.Context, messages []Message) erro
if err != nil {
return err
}
if attachment != nil {
attachments = append(attachments, *attachment)
}
@@ -33,7 +32,7 @@ func (b *Bot) handleGroupMessages(ctx context.Context, groupMessages []Message)
messages := make(map[string]Message, len(groupMessages))
attachments := make(map[string][]Attachment, len(groupMessages))
// Group all captions, blobs and messages
// Group all captions, blobs and messages.
for _, message := range groupMessages {
groupID := *message.MediaGroupID
@@ -53,9 +52,9 @@ func (b *Bot) handleGroupMessages(ctx context.Context, groupMessages []Message)
}
}
// Handle each group message
// Handle each group message.
for groupID, message := range messages {
// replace Caption with all Caption in the group
// replace Caption with all Caption in the group.
caption := captions[groupID]
message.Caption = &caption
err := b.handler.MessageHandle(ctx, b, message, attachments[groupID])