This commit is contained in:
2026-02-03 16:41:34 +03:00
parent 90e2f38c18
commit c71aad0c79
5 changed files with 97 additions and 0 deletions

15
api.go
View File

@@ -63,3 +63,18 @@ func (r TelegramRequest[R, P]) Do(bot *Bot) (*R, error) {
}
return &response.Result, nil
}
func (b *Bot) GetFileByLink(link string) ([]byte, error) {
c := http.DefaultClient
u := fmt.Sprintf("https://api.telegram.org/file/bot%s/%s", b.token, link)
req, err := http.NewRequest("GET", u, nil)
if err != nil {
return nil, err
}
res, err := c.Do(req)
if err != nil {
return nil, err
}
defer res.Body.Close()
return io.ReadAll(res.Body)
}