Example #1
0
async def last(context):
    internationalization.set_language(context.message)
    tweet_id = twitter_agent.getLastTweetId(
        _(twitter_agent.twitter_timeline["screen_name"]))
    tweet = twitter_agent.getTweet(tweet_id)
    channel = bot.get_channel(context.message.channel.id)
    await bot.send_message(channel, embed=tweet)
Example #2
0
async def unsubscribe(context):
    internationalization.set_language(context.message)
    if context.message.author.server_permissions.administrator:
        msg = twitter_agent.unsubscribe(context.message)
    else:
        msg = _("Only administrators of the server can use this command")
    await bot.say(msg)
Example #3
0
async def lang(context, scope, language):
    internationalization.languages[
        internationalization.Language.ENGLISH].install()
    if context.message.author.server_permissions.administrator:
        if language == "en":
            lang = internationalization.Language.ENGLISH
        elif language == "fr":
            lang = internationalization.Language.FRENCH
        elif language == "es":
            lang = internationalization.Language.SPANISH
        elif language == "0":
            lang = None
        else:
            msg = _("Error, the language was not recognised")
        if scope == "channel":
            msg = internationalization.switch_language_channel(
                context.message, lang)
        elif scope == "server":
            if lang is None:
                msg = _("Error, 0 cannot be used for a server")
            else:
                msg = internationalization.switch_language_server(
                    context.message, lang)
        else:
            msg = _("Error, the scope was not recognised")
    else:
        msg = _("Only administrators of the server can use this command")
    internationalization.set_language(context.message)
    await bot.say(_(msg))
Example #4
0
async def prefix(context, *args):
    internationalization.set_language(context.message)
    if context.message.author.server_permissions.administrator:
        if (len(args) != 1):
            msg = _("This command takes one unique parameter")
        else:
            prefix = args[0]
            server_id = context.message.server.id
            msg = _prefix.change_prefix(prefix, server_id)
    else:
        msg = _("Only administrators of the server can use this command")
    await bot.say(msg)
Example #5
0
async def about(context):
    internationalization.set_language(context.message)
    _about.laima.reset_title(_("Discord bot dedicated to the Krosmaga CCG"))
    _about.laima.reset_description(
        _("I aim to provide useful commands to the Krosmaga community!"))
    _about.laima.reset_embed()
    await bot.say(embed=_about.laima.embed)
    _about.fearei.reset_title(_("Author of the illustration"))
    _about.fearei.reset_description(
        _("Below is the complete illustration of Laima. You can visit the DeviantArt page of FeaRei by cliking on the title!"
          ))
    _about.fearei.reset_embed()
    await bot.say(embed=_about.fearei.embed)
Example #6
0
async def draft(context, *args):
    internationalization.set_language(context.message)
    if context.invoked_subcommand is None:
        msg = "```{victories}{level}{pack}{kamas}{chips}{earnings}".format(
            victories=_("Victories"),
            level=_("  Level"),
            pack=_("    Pack"),
            kamas=_("  Kamas"),
            chips=_("      Chips"),
            earnings=_("  Earnings"))
        try:
            victories, defeats, chips, level_four = _draft.calcResultsPartOne(
                args)
            plays = victories + defeats
            if plays < 10:
                msg = '\n'.join([msg, _draft.defineEarnings(victories, chips)])
                msg = '\n'.join([msg, "```"])
            else:
                allins = [0 for j in range(3)]
                await bot.say(
                    _("Give the play number(s) where you did **all-in**"))
                allins_msg = await bot.wait_for_message(
                    timeout=10,
                    author=context.message.author,
                    channel=context.message.channel)
                if allins_msg is not None:
                    args = allins_msg.content.lower().split(' ')
                    if args[0] in ["none", "aucune", "0"]:
                        pass
                    elif args[0] in ["all", "toutes"]:
                        allins = [1 for j in range(3)]
                    else:
                        ind_max = (int(plays) - 1) % 3
                        args = args[:3]
                        for arg in args:
                            ind = (int(arg) - 1) % 3
                            if ind <= ind_max:
                                allins[ind] = 1
                chips = _draft.calcResultsPartTwo(chips, level_four, allins)
                msg = '\n'.join([msg, _draft.defineEarnings(victories, chips)])
                msg = '\n'.join([msg, "```"])
        except Exception as e:
            msg = e.args[0]
            if msg.startswith("invalid literal for int() with base 10"):
                msg = _("The numbers must be integers")
        finally:
            await bot.say(msg)
Example #7
0
async def ladder(context, search=None, season=None):
    internationalization.set_language(context.message)
    try:
        if search is None:
            ladder = _ladder.get_ladder(season)
            msg = _ladder.create_message(ladder, 1, 20)
        else:
            places = search.split('-')
            if len(places) == 1:
                place = int(places[0])
                if place in range(1, 101):
                    ladder = _ladder.get_ladder(season)
                    msg = _ladder.create_message(ladder, place, place)
                else:
                    msg = _("Sorry, the place asked is not between 1 and 100.")
            elif len(places) == 2:
                first = int(places[0])
                last = int(places[1])
                if first not in range(1, 101):
                    msg = _("Sorry, the first place is not between 1 and 100.")
                elif last not in range(1, 101):
                    msg = _("Sorry, the last place is not between 1 and 100.")
                else:
                    if first > last:
                        first, last = last, first
                    ladder = _ladder.get_ladder(season)
                    if last - first < 20:
                        msg = _ladder.create_message(ladder, first, last)
                    else:
                        msg = None
                        msgs = _ladder.create_messages(ladder, first, last)
            else:
                ladder = _ladder.get_ladder(season, search)
                msg = _ladder.create_message(ladder)
    except:
        ladder = _ladder.get_ladder(season, search)
        msg = _ladder.create_message(ladder)
    finally:
        if msg is not None:
            await bot.say(msg)
        else:
            for msg in msgs:
                await bot.say(msg)
Example #8
0
async def ladder(context, search=None):
    internationalization.set_language(context.message)
    error_msg = None
    ladder = _esport.get_ladder()
    try:
        last_place = len(ladder["places"])
        if search is None:
            msgs = _esport.create_ladder(ladder)
        else:
            places = search.split('-')
            if len(places) == 1:
                place = int(places[0])
                if place < 0:
                    error_msg = _("Sorry a place cannot be negative.")
                elif place == 0:
                    msgs = _esport.create_ladder(ladder, 1, last_place)
                else:
                    place = min(place, last_place)
                    msgs = _esport.create_ladder(ladder, 1, place)
            elif len(places) == 2:
                first = int(places[0])
                last = int(places[1])
                if first > last:
                    first, last = last, first
                if first not in range(1, last_place + 1):
                    error_msg = _(
                        "Sorry, the first place is not between 1 and {last_place} (last place)."
                    ).format(last_place=last_place)
                else:
                    last = min(last, last_place)
                    msgs = _esport.create_ladder(ladder, first, last)
    except:
        error_msg = _(
            "Sorry, bad request. Run ```{prefix}help esport ladder``` for more help."
        ).format(prefix=_prefix.prefix(bot, context.message))
    finally:
        if error_msg is not None:
            await bot.say(error_msg)
        else:
            for msg in msgs:
                await bot.say(msg)
Example #9
0
    def format(self):
        internationalization.set_language(self.context.message)
        self._paginator = Paginator()

        # we need a padding of ~80 or so

        description = self.command.description if not self.is_cog(
        ) else inspect.getdoc(self.command)

        if description:
            # <description> portion
            self._paginator.add_line(_(description), empty=True)

        if isinstance(self.command, Command):
            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line(_(signature), empty=True)

            # <long doc> section
            if self.command.help:
                self._paginator.add_line(_(self.command.help), empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        max_width = self.max_name_size

        self._paginator.add_line(_("Commands:"))
        self._custom_add_subcommands_to_page(max_width,
                                             self.filter_command_list())

        # add the ending note
        self._paginator.add_line()
        ending_note = self._custom_get_ending_note()
        self._paginator.add_line(ending_note)
        return self._paginator.pages
Example #10
0
async def status(context):
    internationalization.set_language(context.message)
    msg = twitter_agent.getStatus(context.message)
    await bot.say(msg)
Example #11
0
async def twitter(context):
    internationalization.set_language(context.message)
    if context.invoked_subcommand is None:
        await bot.say(
            _("No subcommand used. Run ```{prefix}help twitter``` for more help."
              ).format(prefix=_prefix.prefix(bot, context.message)))
Example #12
0
async def season(context, *args: str):
    internationalization.set_language(context.message)
    msg = _season.createTable(args)
    await bot.say(msg)
Example #13
0
async def calendar(context, search=None):
    internationalization.set_language(context.message)
    calendar = _esport.get_calendar()
    msg = _esport.create_calendar(calendar)
    await bot.say(msg)