From 9207af91f823008b90df9ce7acfe3b5a3c248594 Mon Sep 17 00:00:00 2001 From: Yan Minari Date: Sun, 22 Jul 2018 16:05:10 -0300 Subject: [PATCH] Show commit hash on bot version when $GB_COMMIT is set Signed-off-by: Yan Minari --- Dockerfile | 3 +++ locales/en.po | 44 ++++++++++++++++++++++------------------- lua/config.lua | 2 +- lua/plugins/private.lua | 35 +++++++++++++++++--------------- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/Dockerfile b/Dockerfile index 83f03af14..922908690 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,3 +14,6 @@ RUN apk add --no-cache $DEPS_NATIVE && \ COPY locales locales COPY lua lua COPY polling.lua . + +ARG GB_COMMIT +ENV GB_COMMIT=$GB_COMMIT diff --git a/locales/en.po b/locales/en.po index 56a1999f5..bcb57ef86 100644 --- a/locales/en.po +++ b/locales/en.po @@ -1779,45 +1779,49 @@ msgid "" "having to send it again" msgstr "" -#: lua/plugins/private.lua:13 +#: lua/plugins/private.lua:11 +msgid "unknown" +msgstr "" + +#: lua/plugins/private.lua:17 +#, lua-format +msgid "" +"This bot is based on [otouto](https://github.com/topkecleon/otouto) (AKA " +"@mokubot, channel: @otouto), a multipurpose Lua bot.\n" +"Group Butler wouldn't exist without it.\n" +"\n" +"You can contact the owners of this bot using the /groups command.\n" +"\n" +"Bot version: %s\n" +"*Some useful links:*" +msgstr "" + +#: lua/plugins/private.lua:30 msgid "Channel" msgstr "" -#: lua/plugins/private.lua:14 +#: lua/plugins/private.lua:31 msgid "GitHub" msgstr "" -#: lua/plugins/private.lua:15 +#: lua/plugins/private.lua:32 msgid "Rate me!" msgstr "" -#: lua/plugins/private.lua:18 +#: lua/plugins/private.lua:35 msgid "👥 Groups" msgstr "" -#: lua/plugins/private.lua:28 +#: lua/plugins/private.lua:45 msgid "Pong!" msgstr "" -#: lua/plugins/private.lua:42 lua/plugins/private.lua:62 -#, lua-format -msgid "" -"This bot is based on [otouto](https://github.com/topkecleon/otouto) (AKA " -"@mokubot, channel: @otouto), a multipurpose Lua bot.\n" -"Group Butler wouldn't exist without it.\n" -"\n" -"You can contact the owners of this bot using the /groups command.\n" -"\n" -"Bot version: `%s`\n" -"*Some useful links:*" -msgstr "" - -#: lua/plugins/private.lua:54 lua/plugins/private.lua:75 +#: lua/plugins/private.lua:64 lua/plugins/private.lua:78 #, lua-format msgid "You can find the list of our support groups in [this channel](%s)" msgstr "" -#: lua/plugins/private.lua:73 +#: lua/plugins/private.lua:76 msgid "🔙 back" msgstr "" diff --git a/lua/config.lua b/lua/config.lua index fe12403f5..d91d9e03b 100644 --- a/lua/config.lua +++ b/lua/config.lua @@ -49,7 +49,7 @@ local _M = -- Aesthetic lang = os.getenv('DEFAULT_LANG') or 'en', - human_readable_version = os.getenv('VERSION') or 'unknown', + commit = os.getenv("GB_COMMIT"), channel = os.getenv("GB_CHANNEL") or '@GroupButler_ch', source_code = os.getenv("GB_SOURCE") or 'https://github.com/group-butler/GroupButler', help_group = os.getenv('HELP_GROUP') or 'telegram.me/GBgroups', diff --git a/lua/plugins/private.lua b/lua/plugins/private.lua index 01aa152ca..aaff46ae2 100644 --- a/lua/plugins/private.lua +++ b/lua/plugins/private.lua @@ -6,6 +6,23 @@ local i18n = locale.translate local plugin = {} +local function bot_version() + if not config.commit then + return i18n("unknown") + end + return ("[%s](%s/commit/%s)"):format(string.sub(config.commit, 1, 7), config.source_code, config.commit) +end + +local strings = { + about = i18n([[This bot is based on [otouto](https://github.com/topkecleon/otouto) (AKA @mokubot, channel: @otouto), a multipurpose Lua bot. +Group Butler wouldn't exist without it. + +You can contact the owners of this bot using the /groups command. + +Bot version: %s +*Some useful links:*]]):format(bot_version()) +} + local function do_keyboard_credits() local keyboard = {} keyboard.inline_keyboard = { @@ -39,14 +56,7 @@ function plugin.onTextMessage(msg, blocks) end if blocks[1] == 'about' then local keyboard = do_keyboard_credits() - local text = i18n([[This bot is based on [otouto](https://github.com/topkecleon/otouto) (AKA @mokubot, channel: @otouto), a multipurpose Lua bot. -Group Butler wouldn't exist without it. - -You can contact the owners of this bot using the /groups command. - -Bot version: `%s` -*Some useful links:*]]):format(config.human_readable_version) - api.sendMessage(msg.chat.id, text, true, keyboard) + api.sendMessage(msg.chat.id, strings.about, true, keyboard) end if blocks[1] == 'group' then if config.help_group and config.help_group ~= '' then @@ -59,14 +69,7 @@ end function plugin.onCallbackQuery(msg, blocks) if blocks[1] == 'about' then local keyboard = do_keyboard_credits() - local text = i18n([[This bot is based on [otouto](https://github.com/topkecleon/otouto) (AKA @mokubot, channel: @otouto), a multipurpose Lua bot. -Group Butler wouldn't exist without it. - -You can contact the owners of this bot using the /groups command. - -Bot version: `%s` -*Some useful links:*]]):format(config.human_readable_version) - api.editMessageText(msg.chat.id, msg.message_id, text, true, keyboard) + api.editMessageText(msg.chat.id, msg.message_id, strings.about, true, keyboard) end if blocks[1] == 'group' then if config.help_group and config.help_group ~= '' then