Exemple #1
0
    def _daily_do_execute(self, command, called_type):
        client = self._dm.client
        manager = self._dm.daily(called_type.type)
        daily_number = manager.submitted_daily(command.author.id)
        character = called_type.type.character(daily_number)

        if daily_number == 0:
            asyncio.ensure_future(
                client.send_message(
                    command.channel,
                    "{0}: You've never submitted for a {1} daily.".format(command.author.mention, character),
                )
            )
        elif not manager.is_open(daily_number):
            asyncio.ensure_future(
                client.send_message(
                    command.channel,
                    "{0}: The {1} {2} daily has closed.".format(
                        command.author.mention, daily.daily_to_shortstr(daily_number), character
                    ),
                )
            )
        else:
            manager.delete_from_daily(daily_number, command.author)
            asyncio.ensure_future(
                client.send_message(
                    command.channel,
                    "Deleted {1}'s daily submission for {0}, {2}.".format(
                        daily.daily_to_shortstr(daily_number), command.author.mention, character
                    ),
                )
            )
            asyncio.ensure_future(self._dm.update_leaderboard(daily_number, called_type.type))
Exemple #2
0
    def _daily_do_execute(self, command, called_type):
        client = self._dm.client
        manager = self._dm.daily(called_type.type)    

        # Command sent via PM or in #dailyspoilerchat
        if command.is_private or command.channel == manager.spoilerchat_channel:
            daily_number = manager.registered_daily(command.author.id)
            character = called_type.type.character(daily_number)

            if daily_number == 0:
                asyncio.ensure_future(client.send_message(command.channel,
                    "{0}: Please get today's {1} daily seed before submitting (use `.dailyseed`).".format(command.author.mention, character)))
            elif not manager.is_open(daily_number):
                asyncio.ensure_future(client.send_message(command.channel,
                    "{0}: Too late to submit for the {1} {2} daily. Get today's seed with `.dailyseed`.".format(command.author.mention, daily.daily_to_shortstr(daily_number), character)))
            elif manager.has_submitted(daily_number, command.author.id):
                asyncio.ensure_future(client.send_message(command.channel,
                    "{0}: You have already submitted for the {1} {2} daily. Use `.dailyresubmit` to edit your submission.".format(command.author.mention, daily.daily_to_shortstr(daily_number), character)))
            else:
                submission_string = manager.parse_submission(daily_number, command.author, command.args)
                if submission_string: # parse succeeded

                    # Respond in PM if submission is in PM
                    if command.is_private:
                        asyncio.ensure_future(client.send_message(command.channel,
                            "Submitted for {0}, {2}: You {1}.".format(daily.daily_to_shortstr(daily_number), submission_string, character)))

                    # Post to spoilerchat (regardless of where submission was)
                    asyncio.ensure_future(client.send_message(manager.spoilerchat_channel,
                        "Submitted for {0}, {3}: {1} {2}.".format(daily.daily_to_shortstr(daily_number), command.author.mention, submission_string, character)))
                    asyncio.ensure_future(self._dm.update_leaderboard(daily_number, called_type.type))

                    # If submitting for today, make spoilerchat visible
                    if daily_number == manager.today_number:
                        try:
                            yield from client.delete_channel_permissions(manager.spoilerchat_channel, self._dm.necrobot.get_as_member(command.author))
                        except AttributeError:
                            print('User {0}, Spoilerchat Channel {1}'.format(command.author.name, manager.spoilerchat_channel.name))
                            raise
                    
                else: # parse failed
                    asyncio.ensure_future(client.send_message(command.channel,
                        "{0}: I had trouble parsing your submission. Please use one of the forms: `{1} 12:34.56` or `{1} death 4-4`.".format(command.author.mention, self.mention)))

        # Command sent in main channel
        elif command.channel == self._dm.main_channel:
            asyncio.ensure_future(client.send_message(command.channel,
                "{0}: Please call `{1}` from {2}, or via PM (this helps avoid spoilers in the main channel).".format(command.author.mention, self.mention, manager.spoilerchat_channel.mention)))      
            asyncio.ensure_future(client.delete_message(command.message))
Exemple #3
0
    def _daily_do_execute(self, command, called_type):       
        client = self._dm.client
        manager = self._dm.daily(called_type.type)
        
        # Command sent via PM or in #dailyspoilerchat
        if command.is_private or command.channel == manager.spoilerchat_channel:
            
            last_submitted = manager.submitted_daily(command.author.id)
            character = called_type.type.character(last_submitted)

            if last_submitted == 0:
                asyncio.ensure_future(client.send_message(command.channel,
                    "{0}: You've never submitted for a daily of this type.".format(command.author.mention)))
            elif not manager.is_open(last_submitted):
                asyncio.ensure_future(client.send_message(command.channel,
                    "{0}: The {1} {2} daily has closed.".format(command.author.mention, daily.daily_to_shortstr(last_submitted), character)))
            else:
                submission_string = manager.parse_submission(last_submitted, command.author, command.args)
                if submission_string: # parse succeeded
                    # Respond in PM if submission is in PM
                    if command.is_private:
                        asyncio.ensure_future(client.send_message(command.channel,
                            "Reubmitted for {0}, {2}: You {1}.".format(daily.daily_to_shortstr(last_submitted), submission_string, character)))

                    # Post to spoilerchat (regardless of where submission was)
                    asyncio.ensure_future(client.send_message(manager.spoilerchat_channel,
                        "Resubmitted for {0}, {3}: {1} {2}.".format(daily.daily_to_shortstr(last_submitted), command.author.mention, submission_string, character)))
                    asyncio.ensure_future(self._dm.update_leaderboard(last_submitted, called_type.type))

                else: # parse failed
                    asyncio.ensure_future(client.send_message(command.channel,
                        "{0}: I had trouble parsing your submission. Please use one of the forms: `{1} 12:34.56` or `{1} death 4-4`.".format(command.author.mention, self.mention)))  

        # Command sent in main channel
        elif command.channel == self._dm.main_channel:
            
            asyncio.ensure_future(client.send_message(command.channel,
                "{0}: Please call `{1}` from {2} (this helps avoid spoilers in the main channel).".format(command.author.mention, self.mention, manager.spoilerchat_channel.mention)))      
            asyncio.ensure_future(client.delete_message(command.message))