From 6b9324ca39aff0c94731af8df8f1f8fedb532260 Mon Sep 17 00:00:00 2001 From: Syfaro Date: Sat, 19 Sep 2015 10:53:32 -0500 Subject: [PATCH] helper method to generate a link for a file --- types.go | 8 ++++++++ 1 file changed, 8 insertions(+) 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"`