diff options
| author | 2018-02-26 01:45:04 +0000 | |
|---|---|---|
| committer | 2018-02-26 01:45:04 +0000 | |
| commit | 2de9f6f75335e7255c9886049379f201186c83a5 (patch) | |
| tree | cc02db4cf4733030dca51344955eb39e44f54387 | |
| parent | Adding autocodeblocking (#15) (diff) | |
Patched the grievous error we overlooked (#16)
• Patched the grievous error we overlooked
• Past time must be subtracted from current time for cooldowns
• Added `DEVTEST_CHANNEL` to constants
• Renamed previous times variable, added devtest
• Reordered imports to satisfy Travis
• For God's sake, Travis
| -rw-r--r-- | bot/cogs/bot.py | 20 | ||||
| -rw-r--r-- | bot/constants.py | 1 | 
2 files changed, 12 insertions, 9 deletions
| diff --git a/bot/cogs/bot.py b/bot/cogs/bot.py index 9d8ee52aa..a953f0f97 100644 --- a/bot/cogs/bot.py +++ b/bot/cogs/bot.py @@ -7,8 +7,9 @@ from discord.ext.commands import AutoShardedBot, Context, command, group  from dulwich.repo import Repo -from bot.constants import (HELP1_CHANNEL, HELP2_CHANNEL, HELP3_CHANNEL, -                           PYTHON_CHANNEL, PYTHON_GUILD, VERIFIED_ROLE) +from bot.constants import (DEVTEST_CHANNEL, HELP1_CHANNEL, HELP2_CHANNEL, +                           HELP3_CHANNEL, PYTHON_CHANNEL, PYTHON_GUILD, +                           VERIFIED_ROLE)  from bot.decorators import with_role @@ -21,10 +22,11 @@ class Bot:          self.bot = bot          # Stores allowed channels plus unix timestamp from last call -        self.code_block_channels = {HELP1_CHANNEL: 0, -                                    HELP2_CHANNEL: 0, -                                    HELP3_CHANNEL: 0, -                                    PYTHON_CHANNEL: 0 +        self.previous_format_times = {HELP1_CHANNEL: 0, +                                      HELP2_CHANNEL: 0, +                                      HELP3_CHANNEL: 0, +                                      PYTHON_CHANNEL: 0, +                                      DEVTEST_CHANNEL: 0          }  # noqa. E124      @group(invoke_without_command=True, name="bot", hidden=True) @@ -72,8 +74,8 @@ class Bot:          await ctx.invoke(self.info)      async def on_message(self, msg: Message): -        if msg.channel.id in self.code_block_channels: -            if self.code_block_channels[msg.channel.id]-time.time() > 300: +        if msg.channel.id in self.previous_format_times: +            if time.time()-self.previous_format_times[msg.channel.id] > 300:                  if msg.content.count("\n") >= 3:                      try:                          tree = ast.parse(msg.content) @@ -98,7 +100,7 @@ class Bot:                              )  # noqa. E124                              information = Embed(title="Code formatting", description=howto)                              await msg.channel.send(embed=information) -                            self.code_block_channels[msg.channel.id] = time.time() +                            self.previous_format_times[msg.channel.id] = time.time()                      except SyntaxError:                          pass diff --git a/bot/constants.py b/bot/constants.py index aa546b66b..a56fec1dd 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -10,6 +10,7 @@ HELP2_CHANNEL = 303906556754395136  HELP3_CHANNEL = 303906514266226689  PYTHON_CHANNEL = 267624335836053506  DEVLOG_CHANNEL = 409308876241108992 +DEVTEST_CHANNEL = 414574275865870337  VERIFICATION_CHANNEL = 352442727016693763  ADMIN_ROLE = 267628507062992896 | 
