diff --git a/types.go b/types.go index ccc5dce..626cddd 100644 --- a/types.go +++ b/types.go @@ -2,6 +2,7 @@ package tgbotapi import ( "encoding/json" + "fmt" "time" ) @@ -178,6 +179,13 @@ type File struct { FilePath string `json:"file_path"` } +// Link returns a full path to the download URL for a File. +// +// It requires the Bot Token to create the link. +func (f *File) Link(token string) string { + return fmt.Sprintf(FileEndpoint, token, f.FilePath) +} + // ReplyKeyboardMarkup allows the Bot to set a custom keyboard. type ReplyKeyboardMarkup struct { Keyboard [][]string `json:"keyboard"`