From 33f8070e573213d49a97663f7fa71494e4373053 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Sun, 16 May 2021 15:00:13 +0100 Subject: [PATCH] cleanup; fix stripping with DEBUG=on --- Makefile | 4 +- email.go | 5 +- main.go | 4 +- package-lock.json | 354 ---------------------------------------------- telegram.go | 124 ++++++++-------- 5 files changed, 74 insertions(+), 417 deletions(-) diff --git a/Makefile b/Makefile index 0debb02..67139ea 100644 --- a/Makefile +++ b/Makefile @@ -29,12 +29,12 @@ endif DEBUG ?= off ifeq ($(DEBUG), on) - LDFLAGS := -s -w $(LDFLAGS) SOURCEMAP := --sourcemap TYPECHECK := tsc -noEmit --project ts/tsconfig.json # jank COPYTS := rm -r $(DATA)/web/js/ts; cp -r ts $(DATA)/web/js else + LDFLAGS := -s -w $(LDFLAGS) SOURCEMAP := COPYTS := TYPECHECK := @@ -79,7 +79,7 @@ compile: $(GOBINARY) mod download $(info Building) mkdir -p build - CGO_ENABLED=0 $(GOBINARY) build -ldflags="-s -w $(LDFLAGS)" $(TAGS) -o build/jfa-go + CGO_ENABLED=0 $(GOBINARY) build -ldflags="$(LDFLAGS)" $(TAGS) -o build/jfa-go compress: upx --lzma build/jfa-go diff --git a/email.go b/email.go index 5a7f6bd..4a14bc3 100644 --- a/email.go +++ b/email.go @@ -215,9 +215,8 @@ func (emailer *Emailer) construct(app *appContext, section, keyFragment string, } var keys []string plaintext := app.config.Section("email").Key("plaintext").MustBool(false) - telegram := app.config.Section("telegram").Key("enabled").MustBool(false) if plaintext { - if telegram { + if telegramEnabled { keys = []string{"text"} text, markdown = "", "" } else { @@ -225,7 +224,7 @@ func (emailer *Emailer) construct(app *appContext, section, keyFragment string, text = "" } } else { - if telegram { + if telegramEnabled { keys = []string{"html", "text", "markdown"} } else { keys = []string{"html", "text"} diff --git a/main.go b/main.go index eeb9fcf..7dffd90 100644 --- a/main.go +++ b/main.go @@ -637,10 +637,10 @@ func flagPassed(name string) (found bool) { } // @title jfa-go internal API -// @version 0.2.0 +// @version 0.3.4 // @description API for the jfa-go frontend // @contact.name Harvey Tindall -// @contact.email hrfee@protonmail.ch +// @contact.email hrfee@hrfee.dev // @license.name MIT // @license.url https://raw.githubusercontent.com/hrfee/jfa-go/main/LICENSE // @BasePath / diff --git a/package-lock.json b/package-lock.json index 0c5c9d1..647f362 100644 --- a/package-lock.json +++ b/package-lock.json @@ -147,11 +147,6 @@ "node": ">= 0.6" } }, - "node_modules/cheerio/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/clean-css": { "version": "4.2.3", "resolved": "https://registry.npm.taobao.org/clean-css/download/clean-css-4.2.3.tgz", @@ -561,11 +556,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-accordion/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-body": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-body/download/mjml-body-4.8.0.tgz", @@ -576,11 +566,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-body/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-button": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-button/download/mjml-button-4.8.0.tgz", @@ -591,11 +576,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-button/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-carousel": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-carousel/download/mjml-carousel-4.8.0.tgz", @@ -606,11 +586,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-carousel/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-cli": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-cli/download/mjml-cli-4.8.0.tgz", @@ -794,11 +769,6 @@ "node": ">=0.12.0" } }, - "node_modules/mjml-cli/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-cli/node_modules/readdirp": { "version": "3.5.0", "resolved": "https://registry.npm.taobao.org/readdirp/download/readdirp-3.5.0.tgz?cache=0&sync_timestamp=1602584469356&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freaddirp%2Fdownload%2Freaddirp-3.5.0.tgz", @@ -901,11 +871,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-column/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-core": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-core/download/mjml-core-4.8.0.tgz", @@ -923,11 +888,6 @@ "mjml-validator": "4.8.0" } }, - "node_modules/mjml-core/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-divider": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-divider/download/mjml-divider-4.8.0.tgz", @@ -938,11 +898,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-divider/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-group": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-group/download/mjml-group-4.8.0.tgz", @@ -953,11 +908,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-group/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-head": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-head/download/mjml-head-4.8.0.tgz", @@ -978,11 +928,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-head-attributes/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-head-breakpoint": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-head-breakpoint/download/mjml-head-breakpoint-4.8.0.tgz", @@ -993,11 +938,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-head-breakpoint/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-head-font": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-head-font/download/mjml-head-font-4.8.0.tgz", @@ -1008,11 +948,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-head-font/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-head-html-attributes": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-head-html-attributes/download/mjml-head-html-attributes-4.8.0.tgz", @@ -1023,11 +958,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-head-html-attributes/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-head-preview": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-head-preview/download/mjml-head-preview-4.8.0.tgz", @@ -1038,11 +968,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-head-preview/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-head-style": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-head-style/download/mjml-head-style-4.8.0.tgz", @@ -1053,11 +978,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-head-style/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-head-title": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-head-title/download/mjml-head-title-4.8.0.tgz", @@ -1068,16 +988,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-head-title/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, - "node_modules/mjml-head/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-hero": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-hero/download/mjml-hero-4.8.0.tgz", @@ -1088,11 +998,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-hero/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-image": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-image/download/mjml-image-4.8.0.tgz", @@ -1103,11 +1008,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-image/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-migrate": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-migrate/download/mjml-migrate-4.8.0.tgz", @@ -1182,11 +1082,6 @@ "node": ">=8" } }, - "node_modules/mjml-migrate/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-migrate/node_modules/string-width": { "version": "4.2.0", "resolved": "https://registry.npm.taobao.org/string-width/download/string-width-4.2.0.tgz", @@ -1267,11 +1162,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-navbar/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-parser-xml": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-parser-xml/download/mjml-parser-xml-4.8.0.tgz", @@ -1357,11 +1247,6 @@ "entities": "^2.0.0" } }, - "node_modules/mjml-parser-xml/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-raw": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-raw/download/mjml-raw-4.8.0.tgz", @@ -1372,11 +1257,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-raw/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-section": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-section/download/mjml-section-4.8.0.tgz", @@ -1387,11 +1267,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-section/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-social": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-social/download/mjml-social-4.8.0.tgz", @@ -1402,11 +1277,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-social/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-spacer": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-spacer/download/mjml-spacer-4.8.0.tgz", @@ -1417,11 +1287,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-spacer/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-table": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-table/download/mjml-table-4.8.0.tgz", @@ -1432,11 +1297,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-table/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-text": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-text/download/mjml-text-4.8.0.tgz", @@ -1447,11 +1307,6 @@ "mjml-core": "4.8.0" } }, - "node_modules/mjml-text/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mjml-validator": { "version": "4.8.0", "resolved": "https://registry.npm.taobao.org/mjml-validator/download/mjml-validator-4.8.0.tgz", @@ -1471,11 +1326,6 @@ "mjml-section": "4.8.0" } }, - "node_modules/mjml-wrapper/node_modules/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npm.taobao.org/mkdirp/download/mkdirp-1.0.4.tgz", @@ -1929,13 +1779,6 @@ "htmlparser2": "^3.9.1", "lodash": "^4.15.0", "parse5": "^3.0.1" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "clean-css": { @@ -2282,13 +2125,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-body": { @@ -2299,13 +2135,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-button": { @@ -2316,13 +2145,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-carousel": { @@ -2333,13 +2155,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-cli": { @@ -2478,11 +2293,6 @@ "resolved": "https://registry.npm.taobao.org/is-number/download/is-number-7.0.0.tgz", "integrity": "sha1-dTU0W4lnNNX4DE0GxQlVUnoU8Ss=" }, - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "readdirp": { "version": "3.5.0", "resolved": "https://registry.npm.taobao.org/readdirp/download/readdirp-3.5.0.tgz?cache=0&sync_timestamp=1602584469356&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freaddirp%2Fdownload%2Freaddirp-3.5.0.tgz", @@ -2561,13 +2371,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-core": { @@ -2585,13 +2388,6 @@ "mjml-migrate": "4.8.0", "mjml-parser-xml": "4.8.0", "mjml-validator": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-divider": { @@ -2602,13 +2398,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-group": { @@ -2619,13 +2408,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-head": { @@ -2636,13 +2418,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-head-attributes": { @@ -2653,13 +2428,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-head-breakpoint": { @@ -2670,13 +2438,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-head-font": { @@ -2687,13 +2448,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-head-html-attributes": { @@ -2704,13 +2458,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-head-preview": { @@ -2721,13 +2468,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-head-style": { @@ -2738,13 +2478,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-head-title": { @@ -2755,13 +2488,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-hero": { @@ -2772,13 +2498,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-image": { @@ -2789,13 +2508,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-migrate": { @@ -2857,11 +2569,6 @@ "resolved": "https://registry.npm.taobao.org/is-fullwidth-code-point/download/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha1-8Rb4Bk/pCz94RKOJl8C3UFEmnx0=" }, - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - }, "string-width": { "version": "4.2.0", "resolved": "https://registry.npm.taobao.org/string-width/download/string-width-4.2.0.tgz", @@ -2924,13 +2631,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-parser-xml": { @@ -3012,11 +2712,6 @@ "domutils": "^2.0.0", "entities": "^2.0.0" } - }, - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" } } }, @@ -3028,13 +2723,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-section": { @@ -3045,13 +2733,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-social": { @@ -3062,13 +2743,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-spacer": { @@ -3079,13 +2753,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-table": { @@ -3096,13 +2763,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-text": { @@ -3113,13 +2773,6 @@ "@babel/runtime": "^7.8.7", "lodash": "^4.17.15", "mjml-core": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mjml-validator": { @@ -3139,13 +2792,6 @@ "lodash": "^4.17.15", "mjml-core": "4.8.0", "mjml-section": "4.8.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597335994883&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", - "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=" - } } }, "mkdirp": { diff --git a/telegram.go b/telegram.go index cfb92fb..7897413 100644 --- a/telegram.go +++ b/telegram.go @@ -111,66 +111,13 @@ func (t *TelegramDaemon) run() { } switch msg := sects[0]; msg { case "/start": - content := t.app.storage.lang.Telegram[lang].Strings.get("startMessage") + "\n" - content += t.app.storage.lang.Telegram[lang].Strings.get("languageMessage") - err := t.Reply(&upd, content) - if err != nil { - t.app.err.Printf("Telegram: Failed to send message to \"%s\": %v", upd.Message.From.UserName, err) - } + t.commandStart(&upd, sects, lang) continue case "/lang": - if len(sects) == 1 { - list := "/lang \n" - for code := range t.app.storage.lang.Telegram { - list += fmt.Sprintf("%s: %s\n", code, t.app.storage.lang.Telegram[code].Meta.Name) - } - err := t.Reply(&upd, list) - if err != nil { - t.app.err.Printf("Telegram: Failed to send message to \"%s\": %v", upd.Message.From.UserName, err) - } - continue - } - if _, ok := t.app.storage.lang.Telegram[sects[1]]; ok { - t.languages[upd.Message.Chat.ID] = sects[1] - for jfID, user := range t.app.storage.telegram { - if user.ChatID == upd.Message.Chat.ID { - user.Lang = sects[1] - t.app.storage.telegram[jfID] = user - err := t.app.storage.storeTelegramUsers() - if err != nil { - t.app.err.Printf("Failed to store Telegram users: %v", err) - } - break - } - } - } + t.commandLang(&upd, sects, lang) continue default: - tokenIndex := -1 - for i, token := range t.tokens { - if upd.Message.Text == token { - tokenIndex = i - break - } - } - if tokenIndex == -1 { - err := t.QuoteReply(&upd, t.app.storage.lang.Telegram[lang].Strings.get("invalidPIN")) - if err != nil { - t.app.err.Printf("Telegram: Failed to send message to \"%s\": %v", upd.Message.From.UserName, err) - } - continue - } - err := t.QuoteReply(&upd, t.app.storage.lang.Telegram[lang].Strings.get("pinSuccess")) - if err != nil { - t.app.err.Printf("Telegram: Failed to send message to \"%s\": %v", upd.Message.From.UserName, err) - } - t.verifiedTokens = append(t.verifiedTokens, VerifiedToken{ - Token: upd.Message.Text, - ChatID: upd.Message.Chat.ID, - Username: upd.Message.Chat.UserName, - }) - t.tokens[len(t.tokens)-1], t.tokens[tokenIndex] = t.tokens[tokenIndex], t.tokens[len(t.tokens)-1] - t.tokens = t.tokens[:len(t.tokens)-1] + t.commandPIN(&upd, sects, lang) } case <-t.ShutdownChannel: @@ -218,3 +165,68 @@ func (t *TelegramDaemon) Shutdown() { <-t.ShutdownChannel close(t.ShutdownChannel) } + +func (t *TelegramDaemon) commandStart(upd *tg.Update, sects []string, lang string) { + content := t.app.storage.lang.Telegram[lang].Strings.get("startMessage") + "\n" + content += t.app.storage.lang.Telegram[lang].Strings.get("languageMessage") + err := t.Reply(upd, content) + if err != nil { + t.app.err.Printf("Telegram: Failed to send message to \"%s\": %v", upd.Message.From.UserName, err) + } +} + +func (t *TelegramDaemon) commandLang(upd *tg.Update, sects []string, lang string) { + if len(sects) == 1 { + list := "/lang \n" + for code := range t.app.storage.lang.Telegram { + list += fmt.Sprintf("%s: %s\n", code, t.app.storage.lang.Telegram[code].Meta.Name) + } + err := t.Reply(upd, list) + if err != nil { + t.app.err.Printf("Telegram: Failed to send message to \"%s\": %v", upd.Message.From.UserName, err) + } + return + } + if _, ok := t.app.storage.lang.Telegram[sects[1]]; ok { + t.languages[upd.Message.Chat.ID] = sects[1] + for jfID, user := range t.app.storage.telegram { + if user.ChatID == upd.Message.Chat.ID { + user.Lang = sects[1] + t.app.storage.telegram[jfID] = user + err := t.app.storage.storeTelegramUsers() + if err != nil { + t.app.err.Printf("Failed to store Telegram users: %v", err) + } + break + } + } + } +} + +func (t *TelegramDaemon) commandPIN(upd *tg.Update, sects []string, lang string) { + tokenIndex := -1 + for i, token := range t.tokens { + if upd.Message.Text == token { + tokenIndex = i + break + } + } + if tokenIndex == -1 { + err := t.QuoteReply(upd, t.app.storage.lang.Telegram[lang].Strings.get("invalidPIN")) + if err != nil { + t.app.err.Printf("Telegram: Failed to send message to \"%s\": %v", upd.Message.From.UserName, err) + } + return + } + err := t.QuoteReply(upd, t.app.storage.lang.Telegram[lang].Strings.get("pinSuccess")) + if err != nil { + t.app.err.Printf("Telegram: Failed to send message to \"%s\": %v", upd.Message.From.UserName, err) + } + t.verifiedTokens = append(t.verifiedTokens, VerifiedToken{ + Token: upd.Message.Text, + ChatID: upd.Message.Chat.ID, + Username: upd.Message.Chat.UserName, + }) + t.tokens[len(t.tokens)-1], t.tokens[tokenIndex] = t.tokens[tokenIndex], t.tokens[len(t.tokens)-1] + t.tokens = t.tokens[:len(t.tokens)-1] +}