1
0
mirror of synced 2024-11-21 20:16:02 +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)
client.Debug = config.Debug
bot.Debug = config.Debug
if update.Message != nil {
nickname := update.Message.From.UserName
@ -593,7 +585,7 @@ func telegramWebhookHandler(c *gin.Context) {
if snd.Message.Text == "" {
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 {
logger.Error(client.Token, err.Error())
c.AbortWithStatus(http.StatusBadRequest)
@ -1015,7 +1007,7 @@ func textMessage(cid int64, mb string, quoteExternalID string) (chattable tgbota
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 (
items []v1.Item
fileID string