Skip to content

Commit

Permalink
Update for larger Chat IDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Syfaro committed Mar 24, 2016
1 parent 6faae88 commit 170874e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

import (
"log"
"gopkg.in/telegram-bot-api.v2"
"gopkg.in/telegram-bot-api.v3"
)

func main() {
Expand Down Expand Up @@ -65,7 +65,7 @@ you may use a slightly different method.
package main

import (
"gopkg.in/telegram-bot-api.v2"
"gopkg.in/telegram-bot-api.v3"
"log"
"net/http"
)
Expand Down
10 changes: 5 additions & 5 deletions configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Fileable interface {

// BaseChat is base type for all chat config types.
type BaseChat struct {
ChatID int // required
ChatID int64 // required
ChannelUsername string
ReplyToMessageID int
ReplyMarkup interface{}
Expand All @@ -76,7 +76,7 @@ func (chat *BaseChat) values() (url.Values, error) {
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 {
Expand Down Expand Up @@ -114,7 +114,7 @@ func (file BaseFile) params() (map[string]string, error) {
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 {
Expand Down Expand Up @@ -181,15 +181,15 @@ func (config MessageConfig) method() string {
// ForwardConfig contains information about a ForwardMessage request.
type ForwardConfig struct {
BaseChat
FromChatID int // required
FromChatID int64 // required
FromChannelUsername string
MessageID int // required
}

// 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
}
Expand Down
32 changes: 16 additions & 16 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
// 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,
Expand All @@ -22,7 +22,7 @@ func NewMessage(chatID int, text string) MessageConfig {
//
// 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,
Expand All @@ -36,7 +36,7 @@ func NewForward(chatID int, fromChatID int, messageID int) ForwardConfig {
// 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},
Expand All @@ -51,7 +51,7 @@ func NewPhotoUpload(chatID int, file interface{}) PhotoConfig {
//
// 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},
Expand All @@ -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,
// 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},
Expand All @@ -81,7 +81,7 @@ func NewAudioUpload(chatID int, file interface{}) AudioConfig {
//
// 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},
Expand All @@ -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,
// 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},
Expand All @@ -111,7 +111,7 @@ func NewDocumentUpload(chatID int, file interface{}) DocumentConfig {
//
// 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},
Expand All @@ -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,
// 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},
Expand All @@ -141,7 +141,7 @@ func NewStickerUpload(chatID int, file interface{}) StickerConfig {
//
// 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},
Expand All @@ -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,
// 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},
Expand All @@ -170,7 +170,7 @@ func NewVideoUpload(chatID int, file interface{}) VideoConfig {
//
// 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},
Expand All @@ -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,
// 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},
Expand All @@ -199,7 +199,7 @@ func NewVoiceUpload(chatID int, file interface{}) VoiceConfig {
//
// 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},
Expand All @@ -212,7 +212,7 @@ func NewVoiceShare(chatID int, fileID string) VoiceConfig {
// 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,
Expand All @@ -228,7 +228,7 @@ func NewLocation(chatID int, latitude float64, longitude float64) LocationConfig
// 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,
Expand Down
6 changes: 3 additions & 3 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type GroupChat struct {

// 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
Expand Down Expand Up @@ -113,8 +113,8 @@ type Message struct {
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.
Expand Down

0 comments on commit 170874e

Please sign in to comment.