示例#1
0
    async def parse_submission(self, daily_number: int, user_id: int,
                               args: list) -> str:
        """Attempt to parse args as a valid daily submission, and submits for the daily if sucessful.

        Returns
        -------
            A string whose content confirms parse, or the empty string if parse fails.
        """
        lv = level.LEVEL_NOS
        time = -1
        ret_str = ''
        if len(args) > 0:
            if args[0] == 'death':
                if len(args) == 2:
                    lv = level.from_str(args[1])
                    if not lv == level.LEVEL_NOS:
                        ret_str = 'died on {}'.format(args[1])
                else:
                    lv = level.LEVEL_UNKNOWN_DEATH
                    ret_str = 'died'
            else:
                time = racetime.from_str(args[0])
                if not time == -1:
                    lv = level.LEVEL_FINISHED
                    ret_str = 'finished in {}'.format(racetime.to_str(time))

        if not lv == level.LEVEL_NOS:  # parse succeeded
            await self.submit_to_daily(daily_number, user_id, lv, time)
            return ret_str
        else:
            return ''
示例#2
0
    async def _do_execute(self, cmd):
        # Override: parse .d X-Y as a death
        if len(cmd.args) >= 1 and cmd.command == 'd':
            lvl = level.from_str(cmd.args[0])
            if lvl != level.LEVEL_NOS:
                await self.reparse_as('death', cmd)
                return

        await self.bot_channel.current_race.finish_member(cmd.author)
示例#3
0
 async def _do_execute(self, cmd):
     if len(cmd.args) == 0:
         await self.reparse_as('forfeit', cmd)
     else:
         if self.bot_channel.last_begun_race is None:
             return
         lvl = level.from_str(cmd.args[0])
         await self.bot_channel.last_begun_race.set_death_for_member(cmd.author, lvl)
         if len(cmd.args) >= 2:
             cmd.args.pop(0)
             await self.reparse_as('comment', cmd)
示例#4
0
    async def _do_execute(self, cmd):
        await self.bot_channel.current_race.forfeit_member(cmd.author)

        if len(cmd.args) >= 1:
            if self.bot_channel.last_begun_race is None:
                return
            lvl = level.from_str(cmd.args[0])
            if lvl != level.LEVEL_NOS:
                cmd.args.pop(0)
                await self.bot_channel.last_begun_race.set_death_for_member(cmd.author, lvl)

            await self.reparse_as('comment', cmd)