diff options
| author | 2018-03-10 14:17:30 +0000 | |
|---|---|---|
| committer | 2018-03-10 14:17:30 +0000 | |
| commit | 05716a1483f72df04dbb42dcfb97598f0ff5d75a (patch) | |
| tree | 35a40c82d68a68922723b0a9b1ec99d862555641 | |
| parent | quickfix for autocodeblocking listening to bot_commands channel (#29) (diff) | |
Comment out on_message handler (#30)
| -rw-r--r-- | bot/cogs/bot.py | 62 | 
1 files changed, 31 insertions, 31 deletions
| diff --git a/bot/cogs/bot.py b/bot/cogs/bot.py index 1aa335388..cf2257b97 100644 --- a/bot/cogs/bot.py +++ b/bot/cogs/bot.py @@ -105,37 +105,37 @@ class Bot:                  content = content.strip()                  return content -    async def on_message(self, msg: Message): -        if msg.channel.id in self.channel_cooldowns: -            on_cooldown = time.time() - self.channel_cooldowns[msg.channel.id] < 300 -            if not on_cooldown or msg.channel.id == DEVTEST_CHANNEL: -                try: -                    content = self.codeblock_stripping(msg.content) -                    if not content: -                        return - -                    # Attempts to parse the message into an AST node. -                    # Invalid Python code will raise a SyntaxError. -                    tree = ast.parse(content) - -                    # Multiple lines of single words could be interpreted as expressions. -                    # This check is to avoid all nodes being parsed as expressions. -                    # (e.g. words over multiple lines) -                    if not all(isinstance(node, ast.Expr) for node in tree.body): -                        codeblock_tag = await self.bot.get_cog("Tags").get_tag_data("codeblock") -                        if codeblock_tag == {}: -                            # todo: add logging -                            return -                        howto = (f"Hey {msg.author.mention}!\n\n" -                                 "I noticed you were trying to paste code into this channel.\n\n" -                                 f"{codeblock_tag['tag_content']}") - -                        howto_embed = Embed(description=howto) -                        await msg.channel.send(embed=howto_embed) -                        self.channel_cooldowns[msg.channel.id] = time.time() -                except SyntaxError: -                    # todo: add logging -                    pass +#    async def on_message(self, msg: Message): +#        if msg.channel.id in self.channel_cooldowns: +#            on_cooldown = time.time() - self.channel_cooldowns[msg.channel.id] < 300 +#            if not on_cooldown or msg.channel.id == DEVTEST_CHANNEL: +#                try: +#                    content = self.codeblock_stripping(msg.content) +#                    if not content: +#                        return +# +#                    # Attempts to parse the message into an AST node. +#                    # Invalid Python code will raise a SyntaxError. +#                    tree = ast.parse(content) +# +#                    # Multiple lines of single words could be interpreted as expressions. +#                    # This check is to avoid all nodes being parsed as expressions. +#                    # (e.g. words over multiple lines) +#                    if not all(isinstance(node, ast.Expr) for node in tree.body): +#                        codeblock_tag = await self.bot.get_cog("Tags").get_tag_data("codeblock") +#                        if codeblock_tag == {}: +#                            # todo: add logging +#                            return +#                        howto = (f"Hey {msg.author.mention}!\n\n" +#                                 "I noticed you were trying to paste code into this channel.\n\n" +#                                 f"{codeblock_tag['tag_content']}") +# +#                        howto_embed = Embed(description=howto) +#                        await msg.channel.send(embed=howto_embed) +#                        self.channel_cooldowns[msg.channel.id] = time.time() +#                except SyntaxError: +#                    # todo: add logging +#                    pass  def setup(bot): | 
