def on_message_delete(self, event): if event.guild.id in self.hushed: return try: msg = Message.get(Message.id == event.id) except Message.DoesNotExist: return channel = self.bot.client.state.channels.get(msg.channel_id) if not channel or not msg.author: return if self.debounces.find(event, message_id=event.id): return if msg.author.id == self.bot.client.state.me.id: return if msg.author.id in event.config.ignored_users: return if msg.channel_id in event.config.ignored_channels: return # Truncate/limit the size of contents contents = S(filter_urls(msg.content), escape_codeblocks=True) if len(contents) > 1800: contents = contents[:1800] + '\n> … ({} more characters)'.format( len(contents) - 1800) self.log_action( Actions.MESSAGE_DELETE, event, author=msg.author, author_id=msg.author.id, channel=channel, msg=contents.replace('cdn.discordapp.com', 'media.discordapp.net'), attachments='' if not msg.attachments else '({})'.format(', '.join( '<{}>'.format( i.replace('https://cdn.discordapp.com/', 'https://media.discordapp.net/')) for i in msg.attachments)))
def on_message_delete(self, event): if event.guild.id in self.hushed: return try: msg = Message.get(Message.id == event.id) except Message.DoesNotExist: return channel = self.state.channels.get(msg.channel_id) if not channel or not msg.author: return debounce = self.debounces.find(event, message_id=event.id) if debounce: return if msg.author.id == self.state.me.id: return if msg.author.id in event.config.ignored_users: return if msg.channel_id in event.config.ignored_channels: return # Truncate/limit the size of contents contents = filter_urls(msg.content) if len(contents) > 1750: contents = contents[:1750] + u'... ({} more characters)'.format( len(contents) - 1750) self.log_action(Actions.MESSAGE_DELETE, event, author=msg.author, author_id=msg.author.id, channel=channel, msg=contents, attachments='' if not msg.attachments else u'({})'.format(', '.join(u'<{}>'.format( unicode(i).replace('cdn.discordapp.com', 'media.discordapp.net', 1)) for i in msg.attachments)))
def on_message_update(self, event): if event.author.id == self.state.me.id: return if event.author.id in event.config.ignored_users: return if event.channel_id in event.config.ignored_channels: return try: msg = Message.get(Message.id == event.id) except Message.DoesNotExist: return if not event.channel or not event.author: return if event.content is not UNSET and msg.content != event.with_proper_mentions: self.log_action(Actions.MESSAGE_EDIT, event, before=filter_urls(msg.content), after=filter_urls(event.with_proper_mentions))
def on_message_delete(self, event): if event.guild.id in self.hushed: return try: msg = Message.get(Message.id == event.id) except Message.DoesNotExist: return channel = self.state.channels.get(msg.channel_id) if not channel or not msg.author: return debounce = self.get_debounce(event.guild.id, msg.author.id, 'censor') if debounce: self.delete_debounce(event.guild.id, msg.author.id, 'censor') return if msg.author.id == self.state.me.id: return if msg.author.id in event.config.ignored_users: return if msg.channel_id in event.config.ignored_channels: return self.log_action(Actions.MESSAGE_DELETE, event, author=msg.author, author_id=msg.author.id, channel=channel, msg=filter_urls(msg.content), attachments='' if not msg.attachments else u'({})'.format(', '.join(u'<{}>'.format(i) for i in msg.attachments)))
def on_message_update(self, event): if event.author.id == self.bot.client.state.me.id: return if event.author.id in event.config.ignored_users: return if event.channel_id in event.config.ignored_channels: return if not event.channel or not event.author: return try: msg = Message.get(Message.id == event.id) except Message.DoesNotExist: return if event.content and msg.content != event.with_proper_mentions: if len(msg.content) >= 860: mcontent = msg.content[: 860] + '\n… ({} more characters)'.format( len(msg.content) - 860) else: mcontent = msg.content if len(event.with_proper_mentions) >= 860: econtent = event.with_proper_mentions[:860] + '\n… ({} more characters)'.format( len(event.with_proper_mentions) - 860) else: econtent = event.with_proper_mentions self.log_action( Actions.MESSAGE_EDIT, event, before=filter_urls(S(mcontent, escape_codeblocks=True)), after=filter_urls(S(econtent, escape_codeblocks=True)))