From fa841bfa8bc0941e0416608e78308401c9334ae9 Mon Sep 17 00:00:00 2001 From: bodqhrohro Date: Wed, 4 Dec 2019 21:29:57 +0200 Subject: [PATCH] Replace Itoa with FormatInt --- telegram/handlers.go | 4 ++-- telegram/utils.go | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/telegram/handlers.go b/telegram/handlers.go index b72ff2c..f0faa18 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -142,7 +142,7 @@ func (c *Client) updateNewChat(update *client.UpdateNewChat) { gateway.SendPresence( c.xmpp, c.jid, - gateway.SPFrom(strconv.Itoa(int(update.Chat.Id))), + gateway.SPFrom(strconv.FormatInt(update.Chat.Id, 10)), gateway.SPType("subscribe"), gateway.SPNickname(update.Chat.Title), ) @@ -202,7 +202,7 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) { ForceRead: true, }) // forward message to XMPP - gateway.SendMessage(c.jid, strconv.Itoa(int(update.Message.ChatId)), text, c.xmpp) + gateway.SendMessage(c.jid, strconv.FormatInt(update.Message.ChatId, 10), text, c.xmpp) } // message content updated diff --git a/telegram/utils.go b/telegram/utils.go index d2d2509..13c81d5 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -167,7 +167,7 @@ func (c *Client) processStatusUpdate(chatID int64, status string, show string, a gateway.SendPresence( c.xmpp, c.jid, - gateway.SPFrom(strconv.Itoa(int(chatID))), + gateway.SPFrom(strconv.FormatInt(chatID, 10)), gateway.SPShow(show), gateway.SPStatus(status), gateway.SPPhoto(photo), @@ -193,12 +193,12 @@ func (c *Client) formatContact(chatID int64) string { } else if user != nil { username := user.Username if username == "" { - username = strconv.Itoa(int(user.Id)) + username = strconv.FormatInt(int64(user.Id), 10) } str = fmt.Sprintf("%s %s (%v)", user.FirstName, user.LastName, username) } else { - str = strconv.Itoa(int(chatID)) + str = strconv.FormatInt(chatID, 10) } str = spaceRegex.ReplaceAllString(str, " ") @@ -350,7 +350,7 @@ func (c *Client) contentToFilename(content client.MessageContent) (*client.File, sizes := photo.Photo.Sizes if len(sizes) > 1 { file := sizes[len(sizes)-1].Photo - return file, strconv.Itoa(int(file.Id)) + ".jpg" + return file, strconv.FormatInt(int64(file.Id), 10) + ".jpg" } return nil, "" case client.TypeMessageAudio: @@ -376,7 +376,7 @@ func (c *Client) messageToPrefix(message *client.Message, fileString string) str } else { directionChar = "⬅ " } - prefix = append(prefix, directionChar+strconv.Itoa(int(message.Id))) + prefix = append(prefix, directionChar+strconv.FormatInt(message.Id, 10)) // show sender in group chats if message.ChatId < 0 && message.SenderUserId != 0 { prefix = append(prefix, c.formatContact(int64(message.SenderUserId))) @@ -415,7 +415,7 @@ func (c *Client) ProcessOutgoingMessage(chatID int64, text string, messageID int // try to execute a command response, isCommand := c.ProcessChatCommand(text) if response != "" { - gateway.SendMessage(returnJid, strconv.Itoa(int(chatID)), response, c.xmpp) + gateway.SendMessage(returnJid, strconv.FormatInt(chatID, 10), response, c.xmpp) } // do not send on success if isCommand {