Ejemplo n.º 1
0
    async def about(self, message, lang, **kwargs):
        color = discord.Color.from_rgb(*RARITY_COLORS['Mythic'])
        e = discord.Embed(title=_('[INFO]', lang),
                          description='<https://garyatrics.com/>',
                          color=color)
        e.set_thumbnail(url=self.user.avatar_url)
        version_title = _('[SETTINGS_VERSION_NO]', lang).replace(':', '')
        e.add_field(name=f'__{version_title}__:',
                    value=self.VERSION,
                    inline=False)

        with HumanizeTranslator(LANGUAGE_CODE_MAPPING.get(lang, lang)) as _t:
            offline = humanize.naturaldelta(self.downtimes)
            start_time = humanize.naturaltime(self.bot_start)
        e.add_field(name=f'__{_("[START]", lang)}__:', value=start_time)
        e.add_field(name=f'__{_("[OFF]", lang)}__:', value=offline)

        bot_runtime = datetime.datetime.now() - self.bot_start
        availability = (bot_runtime - self.downtimes) / bot_runtime
        e.add_field(name=f'__{_("[AVAILABLE]", lang)}__:',
                    value=f'{availability:.3%}')

        slash_invite = self.invite_url.replace('scope=bot',
                                               'scope=applications.commands')
        e.add_field(
            name=f'__{_("[INVITE]", lang)}__:',
            value=
            f'[Bot]({self.invite_url}) / [Slash Commands]({slash_invite})',
            inline=False)

        admin_invite = self.invite_url.split(
            'permissions')[0] + 'permissions=8'
        admin_slash_invite = admin_invite.replace(
            'scope=bot', 'scope=applications.commands')
        e.add_field(
            name=f'__{_("[INVITE]", lang)} ({_("[ADMIN]", lang)})__:',
            value=
            f'[Bot]({admin_invite}>) / [Slash Commands]({admin_slash_invite})',
            inline=False)

        my_prefix = self.prefix.get(message.guild)
        e.add_field(name=f'__{_("[HELP]", lang)}__:',
                    value=f'`{my_prefix}help` / `{my_prefix}quickhelp`',
                    inline=False)

        e.add_field(name=f'__{_("[SUPPORT]", lang)}__:',
                    value='<https://discord.gg/XWs7x3cFTU>',
                    inline=False)
        github = self.my_emojis.get('github')
        gold = self.my_emojis.get('gold')
        contribute = f'{gold} <https://www.buymeacoffee.com/garyatrics>\n' \
                     f'{github} <https://github.com/maduck/GoWDiscordTeamBot>'
        e.add_field(name=f'__{_("[CONTRIBUTE]", lang)}__:',
                    value=contribute,
                    inline=False)
        await self.answer(message, e)
Ejemplo n.º 2
0
 async def show_uptime(self, message, lang, **kwargs):
     e = discord.Embed(title='Uptime', color=self.WHITE)
     lang = LANGUAGE_CODE_MAPPING.get(lang, lang)
     with HumanizeTranslator(lang) as _t:
         uptime = humanize.naturaltime(self.bot_start)
         downtime = humanize.naturaldelta(self.downtimes)
     e.add_field(name='Bot running since', value=uptime, inline=False)
     e.add_field(name='Offline for', value=downtime, inline=False)
     bot_runtime = datetime.datetime.now() - self.bot_start
     availability = (bot_runtime - self.downtimes) / bot_runtime
     e.add_field(name='Availability', value=f'{availability:.3%}')
     await self.answer(message, e)
Ejemplo n.º 3
0
def format_locale_date(date, lang):
    lang = LANGUAGE_CODE_MAPPING.get(lang, lang)
    today = datetime.date.today()
    if date:
        month, day = date.split('-')
        date = today.replace(month=int(month), day=int(day))
    else:
        date = today + datetime.timedelta(days=-today.weekday(), weeks=1)
    locale = lang
    if platform.system() != 'Windows':
        locale = LOCALE_MAPPING.get(lang, 'en_GB') + '.UTF8'
    with different_locale(locale):
        date = date.strftime('%b %d')
    return date
Ejemplo n.º 4
0
    def search(self, search_term, lang):
        lang = LANGUAGE_CODE_MAPPING.get(lang, lang)
        if search_term.isdigit() and int(search_term) in self.items:
            item = self.items.get(int(search_term))
            if item:
                return [item.translations[lang]]
            return []

        possible_matches = []
        for item in self.items.values():
            if item.matches_precisely(search_term, lang):
                return [item.translations[lang]]
            elif item.matches(search_term, lang):
                possible_matches.append(item.translations[lang])
        return possible_matches
Ejemplo n.º 5
0
    async def on_message(self, message):
        if message.author.bot:
            return

        await self.wait_until_ready()

        user_command = message.content.strip()
        my_prefix = self.prefix.get(message.guild)
        function, params = await self.get_function_for_command(
            user_command, my_prefix)
        if not function:
            return

        params['lang'] = params.get('lang') or self.language.get(message.guild)
        params['lang'] = params['lang'].lower()
        params['lang'] = LANGUAGE_CODE_MAPPING.get(params['lang'],
                                                   params['lang'])
        debug(message)
        await function(message=message, **params)
Ejemplo n.º 6
0
 def render_tower_help(self, prefix, lang):
     title = f'{_("[TOWER_OF_DOOM]", lang)} {_("[HELP]", lang)}'
     e = discord.Embed(title=title, color=self.WHITE)
     lang = LANGUAGE_CODE_MAPPING.get(lang, lang)
     return self.render_embed(e, f'help/tower_of_doom-{lang}.jinja', prefix=prefix)
Ejemplo n.º 7
0
 async def help(self, message, lang, **kwargs):
     prefix = self.prefix.get(message.guild)
     lang = LANGUAGE_CODE_MAPPING.get(lang, lang)
     e = self.views.render_help(prefix, lang)
     await self.answer(message, e)
Ejemplo n.º 8
0
 async def current_event(self, message, lang, **kwargs):
     lang = LANGUAGE_CODE_MAPPING.get(lang, lang)
     current_event = self.expander.get_current_event(lang)
     e = self.views.render_current_event(current_event, lang)
     await self.answer(message, e)
Ejemplo n.º 9
0
def translate_day(day_no, locale):
    locale = LANGUAGE_CODE_MAPPING.get(locale, locale)
    locale = LOCALE_MAPPING.get(locale, 'en_GB') + '.UTF8'
    with different_locale(locale):
        return day_name[day_no]