25 lines
534 B
Go

package helpers
import (
"bytes"
"context"
"errors"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
)
func SendDocument(ctx context.Context, b *bot.Bot, update *models.Update, document []byte, title string)error{
if document == nil {
return errors.New("file provided cant be nil")
}
params := &bot.SendDocumentParams{
ChatID: update.Message.Chat.ID,
Document: &models.InputFileUpload{Filename: title, Data: bytes.NewReader(document)},
Caption: title,
}
b.SendDocument(ctx, params)
return nil
}