From 398646950217ab7a4669c84ed36f35c823e46807 Mon Sep 17 00:00:00 2001 From: DmitryZagorulko Date: Wed, 11 Jul 2018 10:17:20 +0300 Subject: [PATCH] cut off the lang string --- telegram.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/telegram.go b/telegram.go index b8cdc08..eac04a2 100644 --- a/telegram.go +++ b/telegram.go @@ -124,6 +124,12 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string } } + lang := update.Message.From.LanguageCode + + if len(update.Message.From.LanguageCode) > 2 { + lang = update.Message.From.LanguageCode[:2] + } + if config.Debug { logger.Debugf("telegramWebhookHandler user %v", user) } @@ -143,7 +149,7 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string Firstname: update.Message.From.FirstName, Avatar: user.UserPhotoURL, Lastname: update.Message.From.LastName, - Language: update.Message.From.LanguageCode, + Language: lang, }, Channel: b.Channel, ExternalChatID: strconv.FormatInt(update.Message.Chat.ID, 10),