Remove reduntant api initialization
This commit is contained in:
parent
c2b8e33b18
commit
834dd4f286
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user