1
0
mirror of synced 2024-11-22 04:26:01 +03:00

Remove reduntant api initialization

This commit is contained in:
Pavel 2019-08-26 14:45:03 +03:00
parent c2b8e33b18
commit 834dd4f286

View File

@ -509,16 +509,8 @@ func telegramWebhookHandler(c *gin.Context) {
) )
} }
bot, err := tgbotapi.NewBotAPI(b.Token)
if err != nil {
logger.Error(b, err)
c.AbortWithStatus(http.StatusBadRequest)
return
}
var client = v1.New(conn.MGURL, conn.MGToken) var client = v1.New(conn.MGURL, conn.MGToken)
client.Debug = config.Debug client.Debug = config.Debug
bot.Debug = config.Debug
if update.Message != nil { if update.Message != nil {
nickname := update.Message.From.UserName nickname := update.Message.From.UserName
@ -593,7 +585,7 @@ func telegramWebhookHandler(c *gin.Context) {
if snd.Message.Text == "" { if snd.Message.Text == "" {
setLocale(update.Message.From.LanguageCode) setLocale(update.Message.From.LanguageCode)
err := setAttachment(bot, update.Message, client, &snd, b.Token) err := setAttachment(update.Message, client, &snd, b.Token)
if err != nil { if err != nil {
logger.Error(client.Token, err.Error()) logger.Error(client.Token, err.Error())
c.AbortWithStatus(http.StatusBadRequest) c.AbortWithStatus(http.StatusBadRequest)
@ -1015,7 +1007,7 @@ func textMessage(cid int64, mb string, quoteExternalID string) (chattable tgbota
return return
} }
func setAttachment(bot *tgbotapi.BotAPI, attachments *tgbotapi.Message, client *v1.MgClient, snd *v1.SendData, botToken string) error { func setAttachment(attachments *tgbotapi.Message, client *v1.MgClient, snd *v1.SendData, botToken string) error {
var ( var (
items []v1.Item items []v1.Item
fileID string fileID string