Пример #1
0
 def _do_execute(self, command):
     race_info = raceinfo.parse_args(command.args)
     if race_info:
         try:
             yield from self._rm.make_race(race_info, creator=command.author, suppress_alerts=False)
         except discord.HTTPException as e:
             asyncio.ensure_future(self._rm.client.send_message(command.channel,
                 'Error making race.'))
             logging.getLogger('discord').warning(e.response)
Пример #2
0
def parse_args(args):
    race_private_info = RacePrivateInfo()
    commands = clparse.pop_commands_from_list(args, ALL_COMMANDS)

    set_admins = False
    set_racers = False
    set_bestof = False
    set_repeat = False

    while commands:
        cmd = commands.pop(0)
        if _parse_admins(cmd, race_private_info):
            if set_admins:
                return None
            else:
                set_admins = True
        elif _parse_racers(cmd, race_private_info):
            if set_racers:
                return None
            else:
                set_racers = True
        elif _parse_bestof(cmd, race_private_info):
            if set_bestof or set_repeat:
                return None
            else:
                set_bestof = True
        elif _parse_repeat(cmd, race_private_info):
            if set_repeat or set_bestof:
                return None
            else:
                set_repeat = True
        else:
            return None

    race_private_info.race_info = raceinfo.parse_args(args)
    if not race_private_info.race_info:
        return None

    return race_private_info