diff --git a/bot.py b/bot.py index e014b61..aa35da0 100755 --- a/bot.py +++ b/bot.py @@ -20,7 +20,7 @@ from subscriptions import Subscriptions from team_expando import TeamExpander from tower_data import TowerOfDoomData -from translations import LANGUAGES +from translations import LANGUAGES, LANGUAGE_CODE_MAPPING from util import bool_to_emoticon, chunks, pluralize_author from views import Views @@ -288,21 +288,18 @@ async def show_spoilers(self, message, prefix, lang, filter): async def show_uptime(self, message, prefix, lang): e = discord.Embed(title='Uptime', color=self.WHITE) - if lang == 'cn': - lang = 'zh' + lang = LANGUAGE_CODE_MAPPING.get(lang, lang) + bot_offline = datetime.timedelta(seconds=self.downtimes) if lang != 'en': _t = humanize.i18n.activate(lang) - now = datetime.datetime.now() - bot_uptime = now - self.bot_start - bot_offline = datetime.timedelta(seconds=self.downtimes) - uptime = f'{humanize.naturaltime(self.bot_start)} ({humanize.naturaldelta(bot_uptime)})' + uptime = f'{humanize.naturaltime(self.bot_start)}' e.add_field(name='Bot running since', value=uptime, inline=False) if bot_offline: e.add_field(name='Offline for', value=humanize.naturaldelta(bot_offline), inline=False) + humanize.i18n.deactivate() bot_runtime = (datetime.datetime.now() - self.bot_start).seconds availability = (bot_runtime - self.downtimes) / bot_runtime e.add_field(name='Availability', value=f'{availability:.3%}') - humanize.i18n.deactivate() await self.answer(message, e) async def show_events(self, message, prefix, lang): diff --git a/translations.py b/translations.py index aee3c6f..9049a3b 100644 --- a/translations.py +++ b/translations.py @@ -12,6 +12,11 @@ 'cn': 'Chinese', } +LANGUAGE_CODE_MAPPING = { + 'ру': 'ru', + 'cn': 'zh', +} + LANG_FILES = [f'GemsOfWar_{language}.json' for language in LANGUAGES.values()]