Skip to content

Commit

Permalink
Show commit hash on bot version when $GB_COMMIT is set
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Minari <[email protected]>
  • Loading branch information
yangm97 committed Jul 22, 2018
1 parent 1bf98fc commit 9207af9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 37 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 24 additions & 20 deletions locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Expand Down
2 changes: 1 addition & 1 deletion lua/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
35 changes: 19 additions & 16 deletions lua/plugins/private.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9207af9

Please sign in to comment.