From 4f996f7f277d290fb753a72c125cd4c8186634e8 Mon Sep 17 00:00:00 2001 From: Syfaro Date: Tue, 26 Jul 2016 13:44:48 -0500 Subject: [PATCH] Add NewInlineQueryResultPhotoWithThumb for #54. --- bot.go | 2 +- helpers.go | 10 ++++++++++ helpers_test.go | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/bot.go b/bot.go index 7d39669..c7e473f 100644 --- a/bot.go +++ b/bot.go @@ -396,7 +396,7 @@ func (bot *BotAPI) RemoveWebhook() (APIResponse, error) { // // If this is set, GetUpdates will not get any data! // -// If you do not have a legitmate TLS certificate, you need to include +// If you do not have a legitimate TLS certificate, you need to include // your self signed certificate with the config. func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error) { if config.Certificate == nil { diff --git a/helpers.go b/helpers.go index 221a5c0..53e5005 100644 --- a/helpers.go +++ b/helpers.go @@ -381,6 +381,16 @@ func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto { } } +// NewInlineQueryResultPhotoWithThumb creates a new inline query photo. +func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto { + return InlineQueryResultPhoto{ + Type: "photo", + ID: id, + URL: url, + ThumbURL: thumb, + } +} + // NewInlineQueryResultVideo creates a new inline query video. func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo { return InlineQueryResultVideo{ diff --git a/helpers_test.go b/helpers_test.go index d2a9e0d..9542f02 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -70,6 +70,17 @@ func TestNewInlineQueryResultPhoto(t *testing.T) { } } +func TestNewInlineQueryResultPhotoWithThumb(t *testing.T) { + result := tgbotapi.NewInlineQueryResultPhotoWithThumb("id", "google.com", "thumb.com") + + if result.Type != "photo" || + result.ID != "id" || + result.URL != "google.com" || + result.ThumbURL != "thumb.com" { + t.Fail() + } +} + func TestNewInlineQueryResultVideo(t *testing.T) { result := tgbotapi.NewInlineQueryResultVideo("id", "google.com")