prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Mod-alerts channel pings when large amounts of emojis are within a code block.
  When a user inputs a large amount of emojis in a code block, it seems that the bot does not ignore them and proceeds to mute for emoji spam. All emojis contained within a code block should be looked over, but anything on the outside should still be scanned for amounts of emojis.
  
  An example of what can trigger the filter:
  ![Untitled](https://user-images.githubusercontent.com/15021300/91444625-de5a8980-e829-11ea-9594-d38246b90651.png)
  
  
  
  </issue>
  <code>
  [start of bot/rules/discord_emojis.py]
  1 import re
  2 from typing import Dict, Iterable, List, Optional, Tuple
  3 
  4 from discord import Member, Message
  5 
  6 
  7 DISCORD_EMOJI_RE = re.compile(r"<:\w+:\d+>")
  8 
  9 
  10 async def apply(
  11     last_message: Message, recent_messages: List[Message], config: Dict[str, int]
  12 ) -> Optional[Tuple[str, Iterable[Member], Iterable[Message]]]:
  13     """Detects total Discord emojis (excluding Unicode emojis) exceeding the limit sent by a single user."""
  14     relevant_messages = tuple(
  15         msg
  16         for msg in recent_messages
  17         if msg.author == last_message.author
  18     )
  19 
  20     total_emojis = sum(
  21         len(DISCORD_EMOJI_RE.findall(msg.content))
  22         for msg in relevant_messages
  23     )
  24 
  25     if total_emojis > config['max']:
  26         return (
  27             f"sent {total_emojis} emojis in {config['interval']}s",
  28             (last_message.author,),
  29             relevant_messages
  30         )
  31     return None
  32
  [end of bot/rules/discord_emojis.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/bot/rules/discord_emojis.py b/bot/rules/discord_emojis.py
  --- a/bot/rules/discord_emojis.py
  +++ b/bot/rules/discord_emojis.py
  @@ -5,6 +5,7 @@
   
   
   DISCORD_EMOJI_RE = re.compile(r"<:\w+:\d+>")
  +CODE_BLOCK_RE = re.compile(r"```.*?```", flags=re.DOTALL)
   
   
   async def apply(
  @@ -17,8 +18,9 @@
           if msg.author == last_message.author
       )
   
  +    # Get rid of code blocks in the message before searching for emojis.
       total_emojis = sum(
  -        len(DISCORD_EMOJI_RE.findall(msg.content))
  +        len(DISCORD_EMOJI_RE.findall(CODE_BLOCK_RE.sub("", msg.content)))
           for msg in relevant_messages
       )
  
verification_info: {"golden_diff": "diff --git a/bot/rules/discord_emojis.py b/bot/rules/discord_emojis.py\n--- a/bot/rules/discord_emojis.py\n+++ b/bot/rules/discord_emojis.py\n@@ -5,6 +5,7 @@\n \n \n DISCORD_EMOJI_RE = re.compile(r\"<:\\w+:\\d+>\")\n+CODE_BLOCK_RE = re.compile(r\"```.*?```\", flags=re.DOTALL)\n \n \n async def apply(\n@@ -17,8 +18,9 @@\n         if msg.author == last_message.author\n     )\n \n+    # Get rid of code blocks in the message before searching for emojis.\n     total_emojis = sum(\n-        len(DISCORD_EMOJI_RE.findall(msg.content))\n+        len(DISCORD_EMOJI_RE.findall(CODE_BLOCK_RE.sub(\"\", msg.content)))\n         for msg in relevant_messages\n     )\n", "issue": "Mod-alerts channel pings when large amounts of emojis are within a code block.\nWhen a user inputs a large amount of emojis in a code block, it seems that the bot does not ignore them and proceeds to mute for emoji spam. All emojis contained within a code block should be looked over, but anything on the outside should still be scanned for amounts of emojis.\r\n\r\nAn example of what can trigger the filter:\r\n![Untitled](https://user-images.githubusercontent.com/15021300/91444625-de5a8980-e829-11ea-9594-d38246b90651.png)\r\n\r\n\n", "before_files": [{"content": "import re\nfrom typing import Dict, Iterable, List, Optional, Tuple\n\nfrom discord import Member, Message\n\n\nDISCORD_EMOJI_RE = re.compile(r\"<:\\w+:\\d+>\")\n\n\nasync def apply(\n    last_message: Message, recent_messages: List[Message], config: Dict[str, int]\n) -> Optional[Tuple[str, Iterable[Member], Iterable[Message]]]:\n    \"\"\"Detects total Discord emojis (excluding Unicode emojis) exceeding the limit sent by a single user.\"\"\"\n    relevant_messages = tuple(\n        msg\n        for msg in recent_messages\n        if msg.author == last_message.author\n    )\n\n    total_emojis = sum(\n        len(DISCORD_EMOJI_RE.findall(msg.content))\n        for msg in relevant_messages\n    )\n\n    if total_emojis > config['max']:\n        return (\n            f\"sent {total_emojis} emojis in {config['interval']}s\",\n            (last_message.author,),\n            relevant_messages\n        )\n    return None\n", "path": "bot/rules/discord_emojis.py"}]}