예제 #1
0
    def archive(self, event, size=50, mode=None, user=None, channel=None):
        if 0 > size >= 15000:
            raise CommandFail('too many messages must be between 1-15000')

        q = Message.select(Message.id).join(User).order_by(Message.id.desc()).limit(size)

        if mode in ('all', 'channel'):
            cid = event.channel.id
            if channel:
                cid = channel if isinstance(channel, (int, long)) else channel.id
            channel = event.guild.channels.get(cid)
            if not channel:
                raise CommandFail('channel not found')
            perms = channel.get_permissions(event.author)
            if not (perms.administrator or perms.read_messages):
                raise CommandFail('invalid permissions')
            q = q.where(Message.channel_id == cid)
        else:
            user_id = user if isinstance(user, (int, long)) else user.id
            if event.author.id != user_id:
                self.can_act_on(event, user_id)
            q = q.where(
                (Message.author_id == user_id) &
                (Message.guild_id == event.guild.id)
            )

        archive = MessageArchive.create_from_message_ids([i.id for i in q])
        event.msg.reply('OK, archived {} messages at {}'.format(len(archive.message_ids), archive.url))
예제 #2
0
파일: core.py 프로젝트: golu701/jetski
    def on_message_delete_bulk(self, event):
        channel = self.state.channels.get(event.channel_id)
        if not channel:
            return

        if event.guild.id in self.hushed:
            return

        archive = MessageArchive.create_from_message_ids(event.ids)
        self.log_action(Actions.MESSAGE_DELETE_BULK, event, log=archive.url, channel=channel, count=len(event.ids))
예제 #3
0
파일: admin.py 프로젝트: suufi/rowboat
    def archive(self, event, size=50, mode=None, user=None, channel=None):
        if 0 > size >= 15000:
            raise CommandFail('too many messages must be between 1-15000')

        q = Message.select(Message.id).join(User).order_by(Message.id.desc()).limit(size)

        if mode in ('all', 'channel'):
            q = q.where((Message.channel_id == (channel or event.channel).id))
        else:
            q = q.where(
                (Message.author_id == (user if isinstance(user, (int, long)) else user.id)) &
                (Message.guild_id == event.guild.id)
            )

        archive = MessageArchive.create_from_message_ids([i.id for i in q])
        event.msg.reply('OK, archived {} messages at {}'.format(len(archive.message_ids), archive.url))