Initial codex telegram bot source

This commit is contained in:
Codex
2026-05-21 08:40:16 +00:00
commit ad61f7eeed
275 changed files with 101972 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package telegram
import (
"context"
"fmt"
"io"
"net/http"
"strings"
)
func (c *Client) DownloadFilePath(ctx context.Context, filePath string) ([]byte, error) {
u := c.fileBaseURL + "/" + strings.TrimLeft(filePath, "/")
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)
if err != nil {
return nil, err
}
resp, err := c.httpClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return nil, fmt.Errorf("download file: telegram returned %s", resp.Status)
}
return io.ReadAll(resp.Body)
}