diff --git a/main.go b/main.go index 0cc5816..59192be 100644 --- a/main.go +++ b/main.go @@ -272,6 +272,18 @@ func createArchive(archiveName string, targets, ignore []string) error { } func TGBotSendFile(botToken, userId, filePath, caption string) error { + // Проверяем размер файла перед отправкой + fileInfo, err := os.Stat(filePath) + if err != nil { + return fmt.Errorf("failed to get file info: %v", err) + } + + // Telegram ограничение - 50MB для обычного API + const maxFileSize = 49 * 1024 * 1024 // 49MB (оставляем запас) + if fileInfo.Size() > maxFileSize { + return fmt.Errorf("file size (%d bytes) exceeds Telegram limit of 50MB", fileInfo.Size()) + } + apiURL := fmt.Sprintf("https://api.telegram.org/bot%s/sendDocument", botToken) file, err := os.Open(filePath)