Update for larger Chat IDs.

bot-api-6.1
Syfaro 2016-03-24 13:22:40 -05:00
parent 14727677a5
commit b971c58157
4 changed files with 27 additions and 27 deletions

View File

@ -17,7 +17,7 @@ something with plugins and command handlers without having to design
all that yourself. all that yourself.
Use `github.com/go-telegram-bot-api/telegram-bot-api` for the latest 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 ## Example
@ -29,7 +29,7 @@ package main
import ( import (
"log" "log"
"gopkg.in/telegram-bot-api.v2" "gopkg.in/telegram-bot-api.v3"
) )
func main() { func main() {
@ -65,7 +65,7 @@ you may use a slightly different method.
package main package main
import ( import (
"gopkg.in/telegram-bot-api.v2" "gopkg.in/telegram-bot-api.v3"
"log" "log"
"net/http" "net/http"
) )

View File

@ -63,7 +63,7 @@ type Fileable interface {
// BaseChat is base type for all chat config types. // BaseChat is base type for all chat config types.
type BaseChat struct { type BaseChat struct {
ChatID int // required ChatID int64 // required
ChannelUsername string ChannelUsername string
ReplyToMessageID int ReplyToMessageID int
ReplyMarkup interface{} ReplyMarkup interface{}
@ -76,7 +76,7 @@ func (chat *BaseChat) values() (url.Values, error) {
if chat.ChannelUsername != "" { if chat.ChannelUsername != "" {
v.Add("chat_id", chat.ChannelUsername) v.Add("chat_id", chat.ChannelUsername)
} else { } else {
v.Add("chat_id", strconv.Itoa(chat.ChatID)) v.Add("chat_id", strconv.FormatInt(chat.ChatID, 10))
} }
if chat.ReplyToMessageID != 0 { if chat.ReplyToMessageID != 0 {
@ -114,7 +114,7 @@ func (file BaseFile) params() (map[string]string, error) {
if file.ChannelUsername != "" { if file.ChannelUsername != "" {
params["chat_id"] = file.ChannelUsername params["chat_id"] = file.ChannelUsername
} else { } else {
params["chat_id"] = strconv.Itoa(file.ChatID) params["chat_id"] = strconv.FormatInt(file.ChatID, 10)
} }
if file.ReplyToMessageID != 0 { if file.ReplyToMessageID != 0 {
@ -181,7 +181,7 @@ func (config MessageConfig) method() string {
// ForwardConfig contains information about a ForwardMessage request. // ForwardConfig contains information about a ForwardMessage request.
type ForwardConfig struct { type ForwardConfig struct {
BaseChat BaseChat
FromChatID int // required FromChatID int64 // required
FromChannelUsername string FromChannelUsername string
MessageID int // required MessageID int // required
} }
@ -189,7 +189,7 @@ type ForwardConfig struct {
// values returns a url.Values representation of ForwardConfig. // values returns a url.Values representation of ForwardConfig.
func (config ForwardConfig) values() (url.Values, error) { func (config ForwardConfig) values() (url.Values, error) {
v, _ := config.BaseChat.values() 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)) v.Add("message_id", strconv.Itoa(config.MessageID))
return v, nil return v, nil
} }

View File

@ -7,7 +7,7 @@ import (
// NewMessage creates a new Message. // NewMessage creates a new Message.
// //
// chatID is where to send it, text is the message text. // 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{ return MessageConfig{
BaseChat: BaseChat{ BaseChat: BaseChat{
ChatID: chatID, ChatID: chatID,
@ -22,7 +22,7 @@ func NewMessage(chatID int, text string) MessageConfig {
// //
// chatID is where to send it, fromChatID is the source chat, // chatID is where to send it, fromChatID is the source chat,
// and messageID is the ID of the original message. // 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{ return ForwardConfig{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
FromChatID: fromChatID, FromChatID: fromChatID,
@ -36,7 +36,7 @@ func NewForward(chatID int, fromChatID int, messageID int) ForwardConfig {
// FileReader, or FileBytes. // FileReader, or FileBytes.
// //
// Note that you must send animated GIFs as a document. // 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{ return PhotoConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -51,7 +51,7 @@ func NewPhotoUpload(chatID int, file interface{}) PhotoConfig {
// //
// chatID is where to send it, fileID is the ID of the file // chatID is where to send it, fileID is the ID of the file
// already uploaded. // already uploaded.
func NewPhotoShare(chatID int, fileID string) PhotoConfig { func NewPhotoShare(chatID int64, fileID string) PhotoConfig {
return PhotoConfig{ return PhotoConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -65,7 +65,7 @@ func NewPhotoShare(chatID int, fileID string) PhotoConfig {
// //
// chatID is where to send it, file is a string path to the file, // chatID is where to send it, file is a string path to the file,
// FileReader, or FileBytes. // FileReader, or FileBytes.
func NewAudioUpload(chatID int, file interface{}) AudioConfig { func NewAudioUpload(chatID int64, file interface{}) AudioConfig {
return AudioConfig{ return AudioConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -81,7 +81,7 @@ func NewAudioUpload(chatID int, file interface{}) AudioConfig {
// //
// chatID is where to send it, fileID is the ID of the audio // chatID is where to send it, fileID is the ID of the audio
// already uploaded. // already uploaded.
func NewAudioShare(chatID int, fileID string) AudioConfig { func NewAudioShare(chatID int64, fileID string) AudioConfig {
return AudioConfig{ return AudioConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -95,7 +95,7 @@ func NewAudioShare(chatID int, fileID string) AudioConfig {
// //
// chatID is where to send it, file is a string path to the file, // chatID is where to send it, file is a string path to the file,
// FileReader, or FileBytes. // FileReader, or FileBytes.
func NewDocumentUpload(chatID int, file interface{}) DocumentConfig { func NewDocumentUpload(chatID int64, file interface{}) DocumentConfig {
return DocumentConfig{ return DocumentConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -111,7 +111,7 @@ func NewDocumentUpload(chatID int, file interface{}) DocumentConfig {
// //
// chatID is where to send it, fileID is the ID of the document // chatID is where to send it, fileID is the ID of the document
// already uploaded. // already uploaded.
func NewDocumentShare(chatID int, fileID string) DocumentConfig { func NewDocumentShare(chatID int64, fileID string) DocumentConfig {
return DocumentConfig{ return DocumentConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -125,7 +125,7 @@ func NewDocumentShare(chatID int, fileID string) DocumentConfig {
// //
// chatID is where to send it, file is a string path to the file, // chatID is where to send it, file is a string path to the file,
// FileReader, or FileBytes. // FileReader, or FileBytes.
func NewStickerUpload(chatID int, file interface{}) StickerConfig { func NewStickerUpload(chatID int64, file interface{}) StickerConfig {
return StickerConfig{ return StickerConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -141,7 +141,7 @@ func NewStickerUpload(chatID int, file interface{}) StickerConfig {
// //
// chatID is where to send it, fileID is the ID of the sticker // chatID is where to send it, fileID is the ID of the sticker
// already uploaded. // already uploaded.
func NewStickerShare(chatID int, fileID string) StickerConfig { func NewStickerShare(chatID int64, fileID string) StickerConfig {
return StickerConfig{ return StickerConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -155,7 +155,7 @@ func NewStickerShare(chatID int, fileID string) StickerConfig {
// //
// chatID is where to send it, file is a string path to the file, // chatID is where to send it, file is a string path to the file,
// FileReader, or FileBytes. // FileReader, or FileBytes.
func NewVideoUpload(chatID int, file interface{}) VideoConfig { func NewVideoUpload(chatID int64, file interface{}) VideoConfig {
return VideoConfig{ return VideoConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -170,7 +170,7 @@ func NewVideoUpload(chatID int, file interface{}) VideoConfig {
// //
// chatID is where to send it, fileID is the ID of the video // chatID is where to send it, fileID is the ID of the video
// already uploaded. // already uploaded.
func NewVideoShare(chatID int, fileID string) VideoConfig { func NewVideoShare(chatID int64, fileID string) VideoConfig {
return VideoConfig{ return VideoConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -184,7 +184,7 @@ func NewVideoShare(chatID int, fileID string) VideoConfig {
// //
// chatID is where to send it, file is a string path to the file, // chatID is where to send it, file is a string path to the file,
// FileReader, or FileBytes. // FileReader, or FileBytes.
func NewVoiceUpload(chatID int, file interface{}) VoiceConfig { func NewVoiceUpload(chatID int64, file interface{}) VoiceConfig {
return VoiceConfig{ return VoiceConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -199,7 +199,7 @@ func NewVoiceUpload(chatID int, file interface{}) VoiceConfig {
// //
// chatID is where to send it, fileID is the ID of the video // chatID is where to send it, fileID is the ID of the video
// already uploaded. // already uploaded.
func NewVoiceShare(chatID int, fileID string) VoiceConfig { func NewVoiceShare(chatID int64, fileID string) VoiceConfig {
return VoiceConfig{ return VoiceConfig{
BaseFile: BaseFile{ BaseFile: BaseFile{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
@ -212,7 +212,7 @@ func NewVoiceShare(chatID int, fileID string) VoiceConfig {
// NewLocation shares your location. // NewLocation shares your location.
// //
// chatID is where to send it, latitude and longitude are coordinates. // 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{ return LocationConfig{
BaseChat: BaseChat{ BaseChat: BaseChat{
ChatID: chatID, ChatID: chatID,
@ -228,7 +228,7 @@ func NewLocation(chatID int, latitude float64, longitude float64) LocationConfig
// Actions last for 5 seconds, or until your next action. // Actions last for 5 seconds, or until your next action.
// //
// chatID is where to send it, action should be set via Chat constants. // 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{ return ChatActionConfig{
BaseChat: BaseChat{ChatID: chatID}, BaseChat: BaseChat{ChatID: chatID},
Action: action, Action: action,

View File

@ -57,7 +57,7 @@ type GroupChat struct {
// Chat contains information about the place a message was sent. // Chat contains information about the place a message was sent.
type Chat struct { type Chat struct {
ID int `json:"id"` ID int64 `json:"id"`
Type string `json:"type"` Type string `json:"type"`
Title string `json:"title"` // optional Title string `json:"title"` // optional
UserName string `json:"username"` // optional UserName string `json:"username"` // optional
@ -113,8 +113,8 @@ type Message struct {
GroupChatCreated bool `json:"group_chat_created"` // optional GroupChatCreated bool `json:"group_chat_created"` // optional
SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional
ChannelChatCreated bool `json:"channel_chat_created"` // optional ChannelChatCreated bool `json:"channel_chat_created"` // optional
MigrateToChatID int `json:"migrate_to_chat_id"` // optional MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional
MigrateFromChatID int `json:"migrate_from_chat_id"` // optional MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional
} }
// Time converts the message timestamp into a Time. // Time converts the message timestamp into a Time.