+ request, err := http.NewRequestWithContext(ctx, http.MethodGet, b.base+"/file/bot"+b.token+"/"+file.Path, nil)
+ if err != nil {
+ return nil, fmt.Errorf("make image request: %s", b.redact(err))
+ }
+
+ response, err := b.http.Do(request)
+ if err != nil {
+ return nil, b.networkError("image download failed", err, b.sendTimeout)
+ }
+
+ defer func() {
+ closeErr := response.Body.Close()
+ if closeErr != nil {
+ err = errors.Join(err, b.networkError("close image download", closeErr, b.sendTimeout))
+ }
+ }()
+
+ if response.StatusCode != http.StatusOK {
+ return nil, &TelegramError{
+ Status: response.StatusCode,
+ Description: http.StatusText(response.StatusCode),
+ }
+ }
+
+ data, err = io.ReadAll(io.LimitReader(response.Body, imageMaxBytes+1))
+ if err != nil {
+ return nil, b.networkError("image cut off", err, b.sendTimeout)
+ }
+
+ if len(data) > imageMaxBytes {
+ return nil, errImageSize
+ }
+
+ return data, nil
+}
+
+// SendMessage sends text to chat with the format of entities, with no parse
+// mode, so the text needs no escaping. With no entities, the text is plain. A
+// call that takes longer than telegramSendTimeout fails with a
+// TelegramNetworkError.
+func (b *TelegramAPI) SendMessage(ctx context.Context, chat int64, text string, entities []TelegramEntity) error {