Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f90493f
Add ParseMode to EditMessageCaption
733amir Jun 30, 2018
31f4975
Add cached types for inline query answer
733amir Jul 4, 2018
4edcb0f
Correct formatting of code with `go fmt`
733amir Jul 4, 2018
d066ae7
merge main repo changes
733amir Sep 1, 2018
9860bdf
Fix capitalization in doc.
Syfaro Oct 8, 2018
fad1895
Merge branch 'master' of github.com:go-telegram-bot-api/telegram-bot-api
733amir Oct 15, 2018
b2addf5
Fix backwards compatibility problem
733amir Oct 15, 2018
97ba9e1
Fix help tests
733amir Oct 15, 2018
ab8d548
Closing update body
bcmk Dec 10, 2018
9c39935
Merge pull request #211 from bcmk/close-body
zhuharev Dec 14, 2018
ec221ba
Merge pull request #183 from 733amir/master
Syfaro Dec 25, 2018
fdf31c7
Add type helpers to message entities.
lzakharov Jan 10, 2019
74b2a53
Mark optional fields in InlineQueryResultGif as omitempty to not send…
Jan 24, 2019
97a13fd
Complete definition of InlineQueryResultGIF to comply with Bot API
Jan 24, 2019
0b788c7
added PinnedMessage in Chat struct
Mephistophiles Feb 12, 2019
016d6ac
Passing error code
bcmk Mar 1, 2019
ab4ab5e
Add support for caption_entities in Message type.
Apr 9, 2019
ace7a9c
Merge pull request #229 from kak-tus/caption_entities
Syfaro Apr 24, 2019
2f55ae3
Merge pull request #219 from lzakharov/message-entity-helpers
Syfaro Apr 24, 2019
9b191db
Merge pull request #221 from yauhen-l/bugfix-omitempty-size-in-inline…
Syfaro Apr 24, 2019
e305b7a
Merge pull request #223 from Mephistophiles/master
Syfaro Apr 24, 2019
87e7035
Merge pull request #227 from bcmk/passing-error-code
Syfaro Apr 24, 2019
8d34583
Allow to change API endpoint for bot
zhuharev May 24, 2019
cea05bf
Merge pull request #238 from go-telegram-bot-api/add-api-endpoint-setter
zhuharev May 24, 2019
c915cfd
README: fix typo
merothh Jul 4, 2019
b33efee
Merge pull request #248 from merothh/master
Syfaro Sep 4, 2019
1f98cd2
Add inline venue type
victpork Jan 6, 2020
613005b
Update types.go
chuhlomin Jan 13, 2020
1944464
Merge pull request #297 from chuhlomin/patch-1
Syfaro Jan 13, 2020
aa124ef
Merge pull request #294 from mkishere/inline-venue
Syfaro Jan 13, 2020
b40fac9
Resolve develop and master conflicts
zhuharev Feb 15, 2020
6fcca60
Fix old package import
zhuharev Feb 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type BotAPI struct {
Self User `json:"-"`
Client *http.Client `json:"-"`
shutdownChannel chan interface{}

apiEndpoint string
}

// NewBotAPI creates a new BotAPI instance.
Expand All @@ -46,6 +48,8 @@ func NewBotAPIWithClient(token string, client *http.Client) (*BotAPI, error) {
Client: client,
Buffer: 100,
shutdownChannel: make(chan interface{}),

apiEndpoint: APIEndpoint,
}

self, err := bot.GetMe()
Expand All @@ -58,6 +62,10 @@ func NewBotAPIWithClient(token string, client *http.Client) (*BotAPI, error) {
return bot, nil
}

func (b *BotAPI) SetAPIEndpoint(apiEndpoint string) {
b.apiEndpoint = apiEndpoint
}

func buildParams(in Params) (out url.Values) {
if in == nil {
return url.Values{}
Expand All @@ -78,7 +86,7 @@ func (bot *BotAPI) MakeRequest(endpoint string, params Params) (APIResponse, err
log.Printf("Endpoint: %s, params: %v\n", endpoint, params)
}

method := fmt.Sprintf(APIEndpoint, bot.Token, endpoint)
method := fmt.Sprintf(bot.apiEndpoint, bot.Token, endpoint)

values := buildParams(params)

Expand Down Expand Up @@ -106,6 +114,7 @@ func (bot *BotAPI) MakeRequest(endpoint string, params Params) (APIResponse, err
}

return apiResp, Error{
Code: apiResp.ErrorCode,
Message: apiResp.Description,
ResponseParameters: parameters,
}
Expand Down Expand Up @@ -199,7 +208,7 @@ func (bot *BotAPI) UploadFile(endpoint string, params Params, fieldname string,
log.Printf("Endpoint: %s, fieldname: %s, params: %v, file: %T\n", endpoint, fieldname, params, file)
}

method := fmt.Sprintf(APIEndpoint, bot.Token, endpoint)
method := fmt.Sprintf(bot.apiEndpoint, bot.Token, endpoint)

req, err := http.NewRequest("POST", method, nil)
if err != nil {
Expand Down Expand Up @@ -439,6 +448,7 @@ func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel {

http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
bytes, _ := ioutil.ReadAll(r.Body)
r.Body.Close()

var update Update
json.Unmarshal(bytes, &update)
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module github.com/go-telegram-bot-api/telegram-bot-api/v5

require github.com/technoweenie/multipartstreamer v1.0.1
require (
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect
github.com/technoweenie/multipartstreamer v1.0.1
)

go 1.13
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
78 changes: 78 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,15 @@ func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF {
}
}

// NewInlineQueryResultCachedGIF create a new inline query with cached photo.
func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF {
return InlineQueryResultCachedGIF{
Type: "gif",
ID: id,
GifID: gifID,
}
}

// NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF {
return InlineQueryResultMPEG4GIF{
Expand All @@ -500,6 +509,15 @@ func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF {
}
}

// NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
func NewInlineQueryResultCachedMPEG4GIF(id, MPEG4GifID string) InlineQueryResultCachedMpeg4Gif {
return InlineQueryResultCachedMpeg4Gif{
Type: "mpeg4_gif",
ID: id,
MGifID: MPEG4GifID,
}
}

// NewInlineQueryResultPhoto creates a new inline query photo.
func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto {
return InlineQueryResultPhoto{
Expand All @@ -519,6 +537,15 @@ func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResult
}
}

// NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
func NewInlineQueryResultCachedPhoto(id, photoID string) InlineQueryResultCachedPhoto {
return InlineQueryResultCachedPhoto{
Type: "photo",
ID: id,
PhotoID: photoID,
}
}

// NewInlineQueryResultVideo creates a new inline query video.
func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
return InlineQueryResultVideo{
Expand All @@ -528,6 +555,16 @@ func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
}
}

// NewInlineQueryResultCachedVideo create a new inline query with cached video.
func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo {
return InlineQueryResultCachedVideo{
Type: "video",
ID: id,
VideoID: videoID,
Title: title,
}
}

// NewInlineQueryResultAudio creates a new inline query audio.
func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio {
return InlineQueryResultAudio{
Expand All @@ -538,6 +575,15 @@ func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio {
}
}

// NewInlineQueryResultCachedAudio create a new inline query with cached photo.
func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio {
return InlineQueryResultCachedAudio{
Type: "audio",
ID: id,
AudioID: audioID,
}
}

// NewInlineQueryResultVoice creates a new inline query voice.
func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice {
return InlineQueryResultVoice{
Expand All @@ -548,6 +594,16 @@ func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice {
}
}

// NewInlineQueryResultCachedVoice create a new inline query with cached photo.
func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice {
return InlineQueryResultCachedVoice{
Type: "voice",
ID: id,
VoiceID: voiceID,
Title: title,
}
}

// NewInlineQueryResultDocument creates a new inline query document.
func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument {
return InlineQueryResultDocument{
Expand All @@ -559,6 +615,16 @@ func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryRe
}
}

// NewInlineQueryResultCachedDocument create a new inline query with cached photo.
func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument {
return InlineQueryResultCachedDocument{
Type: "document",
ID: id,
DocumentID: documentID,
Title: title,
}
}

// NewInlineQueryResultLocation creates a new inline query location.
func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation {
return InlineQueryResultLocation{
Expand All @@ -570,6 +636,18 @@ func NewInlineQueryResultLocation(id, title string, latitude, longitude float64)
}
}

// NewInlineQueryResultVenue creates a new inline query venue.
func NewInlineQueryResultVenue(id, title, address string, latitude, longitude float64) InlineQueryResultVenue {
return InlineQueryResultVenue{
Type: "venue",
ID: id,
Title: title,
Address: address,
Latitude: latitude,
Longitude: longitude,
}
}

// NewEditMessageText allows you to edit the text of a message.
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
return EditMessageTextConfig{
Expand Down
Loading