Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Achieving final satisfaction with golint
Browse files Browse the repository at this point in the history
  • Loading branch information
tucnak committed Jul 6, 2015
1 parent 8dab246 commit eaf9b17
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func embedSendOptions(params *url.Values, options *SendOptions) {
return
}

if options.ReplyTo.Id != 0 {
params.Set("reply_to_message_id", strconv.Itoa(options.ReplyTo.Id))
if options.ReplyTo.ID != 0 {
params.Set("reply_to_message_id", strconv.Itoa(options.ReplyTo.ID))
}

if options.DisableWebPagePreview {
Expand Down
36 changes: 18 additions & 18 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func (b Bot) Listen(subscription chan<- Message, interval time.Duration) {

go func() {
for update := range updates {
if update.Id > latestUpdate {
latestUpdate = update.Id
if update.ID > latestUpdate {
latestUpdate = update.ID
}

subscription <- update.Payload
Expand All @@ -59,7 +59,7 @@ func (b Bot) Listen(subscription chan<- Message, interval time.Duration) {
// SendMessage sends a text message to recipient.
func (b Bot) SendMessage(recipient User, message string, options *SendOptions) error {
params := url.Values{}
params.Set("chat_id", strconv.Itoa(recipient.Id))
params.Set("chat_id", strconv.Itoa(recipient.ID))
params.Set("text", message)

if options != nil {
Expand Down Expand Up @@ -91,9 +91,9 @@ func (b Bot) SendMessage(recipient User, message string, options *SendOptions) e
// ForwardMessage forwards a message to recipient.
func (b Bot) ForwardMessage(recipient User, message Message) error {
params := url.Values{}
params.Set("chat_id", strconv.Itoa(recipient.Id))
params.Set("from_chat_id", strconv.Itoa(message.Origin().Id))
params.Set("message_id", strconv.Itoa(message.Id))
params.Set("chat_id", strconv.Itoa(recipient.ID))
params.Set("from_chat_id", strconv.Itoa(message.Origin().ID))
params.Set("message_id", strconv.Itoa(message.ID))

responseJSON, err := sendCommand("forwardMessage", b.Token, params)
if err != nil {
Expand Down Expand Up @@ -125,7 +125,7 @@ func (b Bot) ForwardMessage(recipient User, message Message) error {
// of existing file on Telegram servers.
func (b Bot) SendPhoto(recipient User, photo *Photo, options *SendOptions) error {
params := url.Values{}
params.Set("chat_id", strconv.Itoa(recipient.Id))
params.Set("chat_id", strconv.Itoa(recipient.ID))
params.Set("caption", photo.Caption)

if options != nil {
Expand All @@ -136,7 +136,7 @@ func (b Bot) SendPhoto(recipient User, photo *Photo, options *SendOptions) error
var err error

if photo.Exists() {
params.Set("photo", photo.FileId)
params.Set("photo", photo.FileID)
responseJSON, err = sendCommand("sendPhoto", b.Token, params)
} else {
responseJSON, err = sendFile("sendPhoto", b.Token, "photo",
Expand Down Expand Up @@ -176,7 +176,7 @@ func (b Bot) SendPhoto(recipient User, photo *Photo, options *SendOptions) error
// of existing file on Telegram servers.
func (b Bot) SendAudio(recipient User, audio *Audio, options *SendOptions) error {
params := url.Values{}
params.Set("chat_id", strconv.Itoa(recipient.Id))
params.Set("chat_id", strconv.Itoa(recipient.ID))

if options != nil {
embedSendOptions(&params, options)
Expand All @@ -186,7 +186,7 @@ func (b Bot) SendAudio(recipient User, audio *Audio, options *SendOptions) error
var err error

if audio.Exists() {
params.Set("audio", audio.FileId)
params.Set("audio", audio.FileID)
responseJSON, err = sendCommand("sendAudio", b.Token, params)
} else {
responseJSON, err = sendFile("sendAudio", b.Token, "audio",
Expand Down Expand Up @@ -225,7 +225,7 @@ func (b Bot) SendAudio(recipient User, audio *Audio, options *SendOptions) error
// of existing file on Telegram servers.
func (b Bot) SendDocument(recipient User, doc *Document, options *SendOptions) error {
params := url.Values{}
params.Set("chat_id", strconv.Itoa(recipient.Id))
params.Set("chat_id", strconv.Itoa(recipient.ID))

if options != nil {
embedSendOptions(&params, options)
Expand All @@ -235,7 +235,7 @@ func (b Bot) SendDocument(recipient User, doc *Document, options *SendOptions) e
var err error

if doc.Exists() {
params.Set("document", doc.FileId)
params.Set("document", doc.FileID)
responseJSON, err = sendCommand("sendDocument", b.Token, params)
} else {
responseJSON, err = sendFile("sendDocument", b.Token, "document",
Expand Down Expand Up @@ -274,7 +274,7 @@ func (b Bot) SendDocument(recipient User, doc *Document, options *SendOptions) e
// of existing file on Telegram servers.
func (b *Bot) SendSticker(recipient User, sticker *Sticker, options *SendOptions) error {
params := url.Values{}
params.Set("chat_id", strconv.Itoa(recipient.Id))
params.Set("chat_id", strconv.Itoa(recipient.ID))

if options != nil {
embedSendOptions(&params, options)
Expand All @@ -284,7 +284,7 @@ func (b *Bot) SendSticker(recipient User, sticker *Sticker, options *SendOptions
var err error

if sticker.Exists() {
params.Set("sticker", sticker.FileId)
params.Set("sticker", sticker.FileID)
responseJSON, err = sendCommand("sendSticker", b.Token, params)
} else {
responseJSON, err = sendFile("sendSticker", b.Token, "sticker",
Expand Down Expand Up @@ -323,7 +323,7 @@ func (b *Bot) SendSticker(recipient User, sticker *Sticker, options *SendOptions
// of existing file on Telegram servers.
func (b Bot) SendVideo(recipient User, video *Video, options *SendOptions) error {
params := url.Values{}
params.Set("chat_id", strconv.Itoa(recipient.Id))
params.Set("chat_id", strconv.Itoa(recipient.ID))

if options != nil {
embedSendOptions(&params, options)
Expand All @@ -333,7 +333,7 @@ func (b Bot) SendVideo(recipient User, video *Video, options *SendOptions) error
var err error

if video.Exists() {
params.Set("video", video.FileId)
params.Set("video", video.FileID)
responseJSON, err = sendCommand("sendVideo", b.Token, params)
} else {
responseJSON, err = sendFile("sendVideo", b.Token, "video",
Expand Down Expand Up @@ -372,7 +372,7 @@ func (b Bot) SendVideo(recipient User, video *Video, options *SendOptions) error
// of existing file on Telegram servers.
func (b Bot) SendLocation(recipient User, geo *Location, options *SendOptions) error {
params := url.Values{}
params.Set("chat_id", strconv.Itoa(recipient.Id))
params.Set("chat_id", strconv.Itoa(recipient.ID))
params.Set("latitude", fmt.Sprintf("%f", geo.Latitude))
params.Set("longitude", fmt.Sprintf("%f", geo.Longitude))

Expand Down Expand Up @@ -415,7 +415,7 @@ func (b Bot) SendLocation(recipient User, geo *Location, options *SendOptions) e
// actions, these are aligned as constants of this package.
func (b Bot) SendChatAction(recipient User, action string) error {
params := url.Values{}
params.Set("chat_id", strconv.Itoa(recipient.Id))
params.Set("chat_id", strconv.Itoa(recipient.ID))
params.Set("action", action)

responseJSON, err := sendCommand("sendChatAction", b.Token, params)
Expand Down
2 changes: 1 addition & 1 deletion file.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// File object represents any sort of file.
type File struct {
FileId string `json:"file_id"`
FileID string `json:"file_id"`
FileSize int `json:"file_size"`

// Local absolute path to file on file system. Valid only for
Expand Down
2 changes: 1 addition & 1 deletion message.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

// Message object represents a message.
type Message struct {
Id int `json:"message_id"`
ID int `json:"message_id"`
Sender User `json:"from"`
Unixtime int `json:"date"`

Expand Down
4 changes: 2 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package telebot

// User object represents a Telegram user, bot or group chat.
type User struct {
Id int `json:"id"`
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Username string `json:"username"`
Expand All @@ -13,7 +13,7 @@ type User struct {

// Update object represents an incoming update.
type Update struct {
Id int `json:"update_id"`
ID int `json:"update_id"`
Payload Message `json:"message"`
}

Expand Down

0 comments on commit eaf9b17

Please sign in to comment.