From 014c91559009c5ff8f7eca7934c94d281ef6382c Mon Sep 17 00:00:00 2001 From: Ave Ozkal Date: Fri, 15 Feb 2019 01:10:47 +0300 Subject: [PATCH] logs: ignore embed events, send too long edits/deletes to pastebin Also move default pastebin server from hastebin to mystbin. --- cogs/common.py | 2 +- cogs/logs.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cogs/common.py b/cogs/common.py index dd92d0b..e097dc4 100644 --- a/cogs/common.py +++ b/cogs/common.py @@ -140,7 +140,7 @@ class Common: reply_list.append(f"{prefix}{text}{suffix}") return reply_list - async def haste(self, text, instance='https://hastebin.com/'): + async def haste(self, text, instance='https://mystb.in/'): response = await self.bot.aiosession.post(f"{instance}documents", data=text) if response.status == 200: diff --git a/cogs/logs.py b/cogs/logs.py index 3a8b10a..07fbea1 100644 --- a/cogs/logs.py +++ b/cogs/logs.py @@ -73,11 +73,21 @@ class Logs: if after.channel.id not in config.spy_channels or after.author.bot: return + # If content is the same, just skip over it + # This usually means that something embedded. + if before.clean_content == after.clean_content: + return + log_channel = self.bot.get_channel(config.log_channel) msg = "📝 **Message edit**: \n"\ f"from {self.bot.escape_message(after.author.name)} "\ f"({after.author.id})\n"\ f"`{before.clean_content}` → `{after.clean_content}`" + + # If resulting message is too long, upload to hastebin + if len(msg) > 2000: + msg = f"📝 **Message edit**: \nToo long: <{self.bot.haste(msg)}>" + await log_channel.send(msg) async def on_message_delete(self, message): @@ -89,6 +99,11 @@ class Logs: msg = "🗑️ **Message delete**: \n"\ f"from {self.bot.escape_message(message.author.name)} "\ f"({message.author.id})\n `{message.clean_content}`" + + # If resulting message is too long, upload to hastebin + if len(msg) > 2000: + msg = f"🗑️ **Message delete**: \nToo long: <{self.bot.haste(msg)}>" + await log_channel.send(msg) async def on_member_remove(self, member):