Skip to content

Commit 170874e

Browse files
author
Syfaro
committed
Update for larger Chat IDs.
1 parent 6faae88 commit 170874e

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ something with plugins and command handlers without having to design
1717
all that yourself.
1818

1919
Use `github.com/go-telegram-bot-api/telegram-bot-api` for the latest
20-
version, or use `gopkg.in/telegram-bot-api.v2` for the stable build.
20+
version, or use `gopkg.in/telegram-bot-api.v3` for the stable build.
2121

2222
## Example
2323

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

3030
import (
3131
"log"
32-
"gopkg.in/telegram-bot-api.v2"
32+
"gopkg.in/telegram-bot-api.v3"
3333
)
3434

3535
func main() {
@@ -65,7 +65,7 @@ you may use a slightly different method.
6565
package main
6666

6767
import (
68-
"gopkg.in/telegram-bot-api.v2"
68+
"gopkg.in/telegram-bot-api.v3"
6969
"log"
7070
"net/http"
7171
)

configs.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type Fileable interface {
6363

6464
// BaseChat is base type for all chat config types.
6565
type BaseChat struct {
66-
ChatID int // required
66+
ChatID int64 // required
6767
ChannelUsername string
6868
ReplyToMessageID int
6969
ReplyMarkup interface{}
@@ -76,7 +76,7 @@ func (chat *BaseChat) values() (url.Values, error) {
7676
if chat.ChannelUsername != "" {
7777
v.Add("chat_id", chat.ChannelUsername)
7878
} else {
79-
v.Add("chat_id", strconv.Itoa(chat.ChatID))
79+
v.Add("chat_id", strconv.FormatInt(chat.ChatID, 10))
8080
}
8181

8282
if chat.ReplyToMessageID != 0 {
@@ -114,7 +114,7 @@ func (file BaseFile) params() (map[string]string, error) {
114114
if file.ChannelUsername != "" {
115115
params["chat_id"] = file.ChannelUsername
116116
} else {
117-
params["chat_id"] = strconv.Itoa(file.ChatID)
117+
params["chat_id"] = strconv.FormatInt(file.ChatID, 10)
118118
}
119119

120120
if file.ReplyToMessageID != 0 {
@@ -181,15 +181,15 @@ func (config MessageConfig) method() string {
181181
// ForwardConfig contains information about a ForwardMessage request.
182182
type ForwardConfig struct {
183183
BaseChat
184-
FromChatID int // required
184+
FromChatID int64 // required
185185
FromChannelUsername string
186186
MessageID int // required
187187
}
188188

189189
// values returns a url.Values representation of ForwardConfig.
190190
func (config ForwardConfig) values() (url.Values, error) {
191191
v, _ := config.BaseChat.values()
192-
v.Add("from_chat_id", strconv.Itoa(config.FromChatID))
192+
v.Add("from_chat_id", strconv.FormatInt(config.FromChatID, 10))
193193
v.Add("message_id", strconv.Itoa(config.MessageID))
194194
return v, nil
195195
}

helpers.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
// NewMessage creates a new Message.
88
//
99
// chatID is where to send it, text is the message text.
10-
func NewMessage(chatID int, text string) MessageConfig {
10+
func NewMessage(chatID int64, text string) MessageConfig {
1111
return MessageConfig{
1212
BaseChat: BaseChat{
1313
ChatID: chatID,
@@ -22,7 +22,7 @@ func NewMessage(chatID int, text string) MessageConfig {
2222
//
2323
// chatID is where to send it, fromChatID is the source chat,
2424
// and messageID is the ID of the original message.
25-
func NewForward(chatID int, fromChatID int, messageID int) ForwardConfig {
25+
func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
2626
return ForwardConfig{
2727
BaseChat: BaseChat{ChatID: chatID},
2828
FromChatID: fromChatID,
@@ -36,7 +36,7 @@ func NewForward(chatID int, fromChatID int, messageID int) ForwardConfig {
3636
// FileReader, or FileBytes.
3737
//
3838
// Note that you must send animated GIFs as a document.
39-
func NewPhotoUpload(chatID int, file interface{}) PhotoConfig {
39+
func NewPhotoUpload(chatID int64, file interface{}) PhotoConfig {
4040
return PhotoConfig{
4141
BaseFile: BaseFile{
4242
BaseChat: BaseChat{ChatID: chatID},
@@ -51,7 +51,7 @@ func NewPhotoUpload(chatID int, file interface{}) PhotoConfig {
5151
//
5252
// chatID is where to send it, fileID is the ID of the file
5353
// already uploaded.
54-
func NewPhotoShare(chatID int, fileID string) PhotoConfig {
54+
func NewPhotoShare(chatID int64, fileID string) PhotoConfig {
5555
return PhotoConfig{
5656
BaseFile: BaseFile{
5757
BaseChat: BaseChat{ChatID: chatID},
@@ -65,7 +65,7 @@ func NewPhotoShare(chatID int, fileID string) PhotoConfig {
6565
//
6666
// chatID is where to send it, file is a string path to the file,
6767
// FileReader, or FileBytes.
68-
func NewAudioUpload(chatID int, file interface{}) AudioConfig {
68+
func NewAudioUpload(chatID int64, file interface{}) AudioConfig {
6969
return AudioConfig{
7070
BaseFile: BaseFile{
7171
BaseChat: BaseChat{ChatID: chatID},
@@ -81,7 +81,7 @@ func NewAudioUpload(chatID int, file interface{}) AudioConfig {
8181
//
8282
// chatID is where to send it, fileID is the ID of the audio
8383
// already uploaded.
84-
func NewAudioShare(chatID int, fileID string) AudioConfig {
84+
func NewAudioShare(chatID int64, fileID string) AudioConfig {
8585
return AudioConfig{
8686
BaseFile: BaseFile{
8787
BaseChat: BaseChat{ChatID: chatID},
@@ -95,7 +95,7 @@ func NewAudioShare(chatID int, fileID string) AudioConfig {
9595
//
9696
// chatID is where to send it, file is a string path to the file,
9797
// FileReader, or FileBytes.
98-
func NewDocumentUpload(chatID int, file interface{}) DocumentConfig {
98+
func NewDocumentUpload(chatID int64, file interface{}) DocumentConfig {
9999
return DocumentConfig{
100100
BaseFile: BaseFile{
101101
BaseChat: BaseChat{ChatID: chatID},
@@ -111,7 +111,7 @@ func NewDocumentUpload(chatID int, file interface{}) DocumentConfig {
111111
//
112112
// chatID is where to send it, fileID is the ID of the document
113113
// already uploaded.
114-
func NewDocumentShare(chatID int, fileID string) DocumentConfig {
114+
func NewDocumentShare(chatID int64, fileID string) DocumentConfig {
115115
return DocumentConfig{
116116
BaseFile: BaseFile{
117117
BaseChat: BaseChat{ChatID: chatID},
@@ -125,7 +125,7 @@ func NewDocumentShare(chatID int, fileID string) DocumentConfig {
125125
//
126126
// chatID is where to send it, file is a string path to the file,
127127
// FileReader, or FileBytes.
128-
func NewStickerUpload(chatID int, file interface{}) StickerConfig {
128+
func NewStickerUpload(chatID int64, file interface{}) StickerConfig {
129129
return StickerConfig{
130130
BaseFile: BaseFile{
131131
BaseChat: BaseChat{ChatID: chatID},
@@ -141,7 +141,7 @@ func NewStickerUpload(chatID int, file interface{}) StickerConfig {
141141
//
142142
// chatID is where to send it, fileID is the ID of the sticker
143143
// already uploaded.
144-
func NewStickerShare(chatID int, fileID string) StickerConfig {
144+
func NewStickerShare(chatID int64, fileID string) StickerConfig {
145145
return StickerConfig{
146146
BaseFile: BaseFile{
147147
BaseChat: BaseChat{ChatID: chatID},
@@ -155,7 +155,7 @@ func NewStickerShare(chatID int, fileID string) StickerConfig {
155155
//
156156
// chatID is where to send it, file is a string path to the file,
157157
// FileReader, or FileBytes.
158-
func NewVideoUpload(chatID int, file interface{}) VideoConfig {
158+
func NewVideoUpload(chatID int64, file interface{}) VideoConfig {
159159
return VideoConfig{
160160
BaseFile: BaseFile{
161161
BaseChat: BaseChat{ChatID: chatID},
@@ -170,7 +170,7 @@ func NewVideoUpload(chatID int, file interface{}) VideoConfig {
170170
//
171171
// chatID is where to send it, fileID is the ID of the video
172172
// already uploaded.
173-
func NewVideoShare(chatID int, fileID string) VideoConfig {
173+
func NewVideoShare(chatID int64, fileID string) VideoConfig {
174174
return VideoConfig{
175175
BaseFile: BaseFile{
176176
BaseChat: BaseChat{ChatID: chatID},
@@ -184,7 +184,7 @@ func NewVideoShare(chatID int, fileID string) VideoConfig {
184184
//
185185
// chatID is where to send it, file is a string path to the file,
186186
// FileReader, or FileBytes.
187-
func NewVoiceUpload(chatID int, file interface{}) VoiceConfig {
187+
func NewVoiceUpload(chatID int64, file interface{}) VoiceConfig {
188188
return VoiceConfig{
189189
BaseFile: BaseFile{
190190
BaseChat: BaseChat{ChatID: chatID},
@@ -199,7 +199,7 @@ func NewVoiceUpload(chatID int, file interface{}) VoiceConfig {
199199
//
200200
// chatID is where to send it, fileID is the ID of the video
201201
// already uploaded.
202-
func NewVoiceShare(chatID int, fileID string) VoiceConfig {
202+
func NewVoiceShare(chatID int64, fileID string) VoiceConfig {
203203
return VoiceConfig{
204204
BaseFile: BaseFile{
205205
BaseChat: BaseChat{ChatID: chatID},
@@ -212,7 +212,7 @@ func NewVoiceShare(chatID int, fileID string) VoiceConfig {
212212
// NewLocation shares your location.
213213
//
214214
// chatID is where to send it, latitude and longitude are coordinates.
215-
func NewLocation(chatID int, latitude float64, longitude float64) LocationConfig {
215+
func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig {
216216
return LocationConfig{
217217
BaseChat: BaseChat{
218218
ChatID: chatID,
@@ -228,7 +228,7 @@ func NewLocation(chatID int, latitude float64, longitude float64) LocationConfig
228228
// Actions last for 5 seconds, or until your next action.
229229
//
230230
// chatID is where to send it, action should be set via Chat constants.
231-
func NewChatAction(chatID int, action string) ChatActionConfig {
231+
func NewChatAction(chatID int64, action string) ChatActionConfig {
232232
return ChatActionConfig{
233233
BaseChat: BaseChat{ChatID: chatID},
234234
Action: action,

types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type GroupChat struct {
5757

5858
// Chat contains information about the place a message was sent.
5959
type Chat struct {
60-
ID int `json:"id"`
60+
ID int64 `json:"id"`
6161
Type string `json:"type"`
6262
Title string `json:"title"` // optional
6363
UserName string `json:"username"` // optional
@@ -113,8 +113,8 @@ type Message struct {
113113
GroupChatCreated bool `json:"group_chat_created"` // optional
114114
SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional
115115
ChannelChatCreated bool `json:"channel_chat_created"` // optional
116-
MigrateToChatID int `json:"migrate_to_chat_id"` // optional
117-
MigrateFromChatID int `json:"migrate_from_chat_id"` // optional
116+
MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional
117+
MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional
118118
}
119119

120120
// Time converts the message timestamp into a Time.

0 commit comments

Comments
 (0)