all repos — telegram-bot-api @ b971c58157dcf22debf47dee7fc8af15492d2a73

Golang bindings for the Telegram Bot API

Update for larger Chat IDs.
Syfaro syfaro@foxpaw.in
Thu, 24 Mar 2016 13:22:40 -0500
commit

b971c58157dcf22debf47dee7fc8af15492d2a73

parent

14727677a55632b87aa17b9795d09b4681d37be9

4 files changed, 27 insertions(+), 27 deletions(-)

jump to
M README.mdREADME.md

@@ -17,7 +17,7 @@ something with plugins and command handlers without having to design

all that yourself. Use `github.com/go-telegram-bot-api/telegram-bot-api` for the latest -version, or use `gopkg.in/telegram-bot-api.v2` for the stable build. +version, or use `gopkg.in/telegram-bot-api.v3` for the stable build. ## Example

@@ -29,7 +29,7 @@ package main

import ( "log" - "gopkg.in/telegram-bot-api.v2" + "gopkg.in/telegram-bot-api.v3" ) func main() {

@@ -65,7 +65,7 @@ ```go

package main import ( - "gopkg.in/telegram-bot-api.v2" + "gopkg.in/telegram-bot-api.v3" "log" "net/http" )
M configs.goconfigs.go

@@ -63,7 +63,7 @@ }

// BaseChat is base type for all chat config types. type BaseChat struct { - ChatID int // required + ChatID int64 // required ChannelUsername string ReplyToMessageID int ReplyMarkup interface{}

@@ -76,7 +76,7 @@ v := url.Values{}

if chat.ChannelUsername != "" { v.Add("chat_id", chat.ChannelUsername) } else { - v.Add("chat_id", strconv.Itoa(chat.ChatID)) + v.Add("chat_id", strconv.FormatInt(chat.ChatID, 10)) } if chat.ReplyToMessageID != 0 {

@@ -114,7 +114,7 @@

if file.ChannelUsername != "" { params["chat_id"] = file.ChannelUsername } else { - params["chat_id"] = strconv.Itoa(file.ChatID) + params["chat_id"] = strconv.FormatInt(file.ChatID, 10) } if file.ReplyToMessageID != 0 {

@@ -181,7 +181,7 @@

// ForwardConfig contains information about a ForwardMessage request. type ForwardConfig struct { BaseChat - FromChatID int // required + FromChatID int64 // required FromChannelUsername string MessageID int // required }

@@ -189,7 +189,7 @@

// values returns a url.Values representation of ForwardConfig. func (config ForwardConfig) values() (url.Values, error) { v, _ := config.BaseChat.values() - v.Add("from_chat_id", strconv.Itoa(config.FromChatID)) + v.Add("from_chat_id", strconv.FormatInt(config.FromChatID, 10)) v.Add("message_id", strconv.Itoa(config.MessageID)) return v, nil }
M helpers.gohelpers.go

@@ -7,7 +7,7 @@

// NewMessage creates a new Message. // // chatID is where to send it, text is the message text. -func NewMessage(chatID int, text string) MessageConfig { +func NewMessage(chatID int64, text string) MessageConfig { return MessageConfig{ BaseChat: BaseChat{ ChatID: chatID,

@@ -22,7 +22,7 @@ // NewForward creates a new forward.

// // chatID is where to send it, fromChatID is the source chat, // and messageID is the ID of the original message. -func NewForward(chatID int, fromChatID int, messageID int) ForwardConfig { +func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig { return ForwardConfig{ BaseChat: BaseChat{ChatID: chatID}, FromChatID: fromChatID,

@@ -36,7 +36,7 @@ // chatID is where to send it, file is a string path to the file,

// FileReader, or FileBytes. // // Note that you must send animated GIFs as a document. -func NewPhotoUpload(chatID int, file interface{}) PhotoConfig { +func NewPhotoUpload(chatID int64, file interface{}) PhotoConfig { return PhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -51,7 +51,7 @@ // You may use this to reshare an existing photo without reuploading it.

// // chatID is where to send it, fileID is the ID of the file // already uploaded. -func NewPhotoShare(chatID int, fileID string) PhotoConfig { +func NewPhotoShare(chatID int64, fileID string) PhotoConfig { return PhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -65,7 +65,7 @@ // NewAudioUpload creates a new audio uploader.

// // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes. -func NewAudioUpload(chatID int, file interface{}) AudioConfig { +func NewAudioUpload(chatID int64, file interface{}) AudioConfig { return AudioConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -81,7 +81,7 @@ // reuploading it.

// // chatID is where to send it, fileID is the ID of the audio // already uploaded. -func NewAudioShare(chatID int, fileID string) AudioConfig { +func NewAudioShare(chatID int64, fileID string) AudioConfig { return AudioConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -95,7 +95,7 @@ // NewDocumentUpload creates a new document uploader.

// // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes. -func NewDocumentUpload(chatID int, file interface{}) DocumentConfig { +func NewDocumentUpload(chatID int64, file interface{}) DocumentConfig { return DocumentConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -111,7 +111,7 @@ // reuploading it.

// // chatID is where to send it, fileID is the ID of the document // already uploaded. -func NewDocumentShare(chatID int, fileID string) DocumentConfig { +func NewDocumentShare(chatID int64, fileID string) DocumentConfig { return DocumentConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -125,7 +125,7 @@ // NewStickerUpload creates a new sticker uploader.

// // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes. -func NewStickerUpload(chatID int, file interface{}) StickerConfig { +func NewStickerUpload(chatID int64, file interface{}) StickerConfig { return StickerConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -141,7 +141,7 @@ // reuploading it.

// // chatID is where to send it, fileID is the ID of the sticker // already uploaded. -func NewStickerShare(chatID int, fileID string) StickerConfig { +func NewStickerShare(chatID int64, fileID string) StickerConfig { return StickerConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -155,7 +155,7 @@ // NewVideoUpload creates a new video uploader.

// // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes. -func NewVideoUpload(chatID int, file interface{}) VideoConfig { +func NewVideoUpload(chatID int64, file interface{}) VideoConfig { return VideoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -170,7 +170,7 @@ // You may use this to reshare an existing video without reuploading it.

// // chatID is where to send it, fileID is the ID of the video // already uploaded. -func NewVideoShare(chatID int, fileID string) VideoConfig { +func NewVideoShare(chatID int64, fileID string) VideoConfig { return VideoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -184,7 +184,7 @@ // NewVoiceUpload creates a new voice uploader.

// // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes. -func NewVoiceUpload(chatID int, file interface{}) VoiceConfig { +func NewVoiceUpload(chatID int64, file interface{}) VoiceConfig { return VoiceConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -199,7 +199,7 @@ // You may use this to reshare an existing voice without reuploading it.

// // chatID is where to send it, fileID is the ID of the video // already uploaded. -func NewVoiceShare(chatID int, fileID string) VoiceConfig { +func NewVoiceShare(chatID int64, fileID string) VoiceConfig { return VoiceConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID},

@@ -212,7 +212,7 @@

// NewLocation shares your location. // // chatID is where to send it, latitude and longitude are coordinates. -func NewLocation(chatID int, latitude float64, longitude float64) LocationConfig { +func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig { return LocationConfig{ BaseChat: BaseChat{ ChatID: chatID,

@@ -228,7 +228,7 @@ // NewChatAction sets a chat action.

// Actions last for 5 seconds, or until your next action. // // chatID is where to send it, action should be set via Chat constants. -func NewChatAction(chatID int, action string) ChatActionConfig { +func NewChatAction(chatID int64, action string) ChatActionConfig { return ChatActionConfig{ BaseChat: BaseChat{ChatID: chatID}, Action: action,
M types.gotypes.go

@@ -57,7 +57,7 @@ }

// Chat contains information about the place a message was sent. type Chat struct { - ID int `json:"id"` + ID int64 `json:"id"` Type string `json:"type"` Title string `json:"title"` // optional UserName string `json:"username"` // optional

@@ -113,8 +113,8 @@ DeleteChatPhoto bool `json:"delete_chat_photo"` // optional

GroupChatCreated bool `json:"group_chat_created"` // optional SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional ChannelChatCreated bool `json:"channel_chat_created"` // optional - MigrateToChatID int `json:"migrate_to_chat_id"` // optional - MigrateFromChatID int `json:"migrate_from_chat_id"` // optional + MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional + MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional } // Time converts the message timestamp into a Time.