Skip to content

Commit 6b9324c

Browse files
author
Syfaro
committed
helper method to generate a link for a file
1 parent 1bceea1 commit 6b9324c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tgbotapi
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"time"
67
)
78

@@ -178,6 +179,13 @@ type File struct {
178179
FilePath string `json:"file_path"`
179180
}
180181

182+
// Link returns a full path to the download URL for a File.
183+
//
184+
// It requires the Bot Token to create the link.
185+
func (f *File) Link(token string) string {
186+
return fmt.Sprintf(FileEndpoint, token, f.FilePath)
187+
}
188+
181189
// ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
182190
type ReplyKeyboardMarkup struct {
183191
Keyboard [][]string `json:"keyboard"`

0 commit comments

Comments
 (0)