コード例 #1
0
 def delete_scene(self, args, guild, channel, scenario, sc, user):
     messages = []
     search = ''
     if len(args) == 1:
         if not sc:
             raise Exception('No scene provided for deletion')
     else:
         search = ' '.join(args[1:])
         sc = Scene().find(guild.name, str(channel.id), str(scenario.id),
                           search)
     if not sc:
         return [f'{search} was not found. No changes made.']
     else:
         search = str(sc.name)
         scenario_id = str(sc.scenario_id) if sc.scenario_id else ''
         channel_id = str(sc.channel_id) if sc.channel_id else ''
         sc.character.archive(user)
         sc.archived = True
         sc.updated_by = str(user.id)
         sc.updated = T.now()
         sc.save()
         messages.append(f'***{search}*** removed')
         if scenario_id:
             secenario = Scenario().get_by_id(scenario_id)
             messages.append(secenario.get_string(channel))
         elif channel_id:
             channel = Channel().get_by_id(channel_id)
             messages.append(channel.get_string())
         return messages
コード例 #2
0
    def delete_item(self, args, user, item, method, params):
        """Delete an item

        Parameters
        ----------
        args : list(str)
            List of strings with subcommands
        user : User
            The User mongoengine Document for displaying active records
        item : mongoengine.Document
            The item used to get string information
        method : function
            The mongoengine Document method for filtering an item
        params : dict
            The dictionary of params to search for an item

        Returns
        -------
        list(str) - the array of response strings
        """

        messages = []
        search = ''
        if len(args) == 1:
            if not item:
                raise Exception('No item provided for deletion')
        else:
            search = ' '.join(args[1:])
            params['name'] = search
            item = method(**params)
        if not item:
            return [f'{search} was not found. No changes made.']
        else:
            search = str(item.name)
            channel_id = str(item.channel_id) if hasattr(item,
                                                         'channel_id') else ''
            if hasattr(item, 'character'):
                item.character.archive(user)
            item.archived = True
            self.save(item, user)
            messages.append(f'***{search}*** removed')
            if channel_id:
                channel = Channel().get_by_id(channel_id)
                messages.append(channel.get_string())
            return messages
コード例 #3
0
 def delete_zone(self, args, guild, channel, scene, zone, user):
     messages = []
     search = ''
     if len(args) == 1:
         if not zone:
             raise Exception('No zone provided for deletion')
     else:
         search = ' '.join(args[1:])
         zone = Zone().find(guild.name, str(channel.id), str(scene.id), search)
     if not zone:
         return [f'{search} was not found. No changes made.']
     else:
         search = str(zone.name)
         channel_id = str(zone.channel_id) if zone.channel_id else ''
         zone.character.archive(user)
         zone.archived = True
         self.save(zone, user)
         messages.append(f'***{search}*** removed')
         if channel_id:
             channel = Channel().get_by_id(channel_id)
             messages.append(channel.get_string())
         return messages
コード例 #4
0
 def delete_engagement(self, args, guild, channel, scene, engagement, user):
     messages = []
     search = ''
     if len(args) == 1:
         if not engagement:
             raise Exception('No engagement provided for deletion')
     else:
         search = ' '.join(args[1:])
         engagement = Engagement().find(guild.name, str(channel.id),
                                        str(scene.id), search)
     if not engagement:
         return [f'{search} was not found. No changes made.']
     else:
         search = str(engagement.name)
         channel_id = str(
             engagement.channel_id) if engagement.channel_id else ''
         engagement.character.archive(user)
         engagement.archived = True
         self.save(engagement, user)
         messages.append(f'***{search}*** removed')
         if channel_id:
             channel = Channel().get_by_id(channel_id)
             messages.append(channel.get_string())
         return messages