diff options
| author | 2019-01-09 01:45:01 -0500 | |
|---|---|---|
| committer | 2019-01-09 01:45:01 -0500 | |
| commit | 3a209226e76b2ef1e542cd5a35e2571b3a1cc418 (patch) | |
| tree | 592838dc499b2429445444e83514b9873d72bfdd | |
| parent | Merge branch 'master' of https://github.com/python-discord/bot (diff) | |
Add activity timeout constant
| -rw-r--r-- | bot/cogs/free.py | 13 | ||||
| -rw-r--r-- | bot/constants.py | 6 | ||||
| -rw-r--r-- | config-default.yml | 6 | 
3 files changed, 18 insertions, 7 deletions
diff --git a/bot/cogs/free.py b/bot/cogs/free.py index 076415ded..7447fd941 100644 --- a/bot/cogs/free.py +++ b/bot/cogs/free.py @@ -4,18 +4,17 @@ from datetime import datetime  from discord import Colour, Embed, Member, utils  from discord.ext.commands import BucketType, Context, command, cooldown -from bot.constants import Categories +from bot.constants import Categories, Free  log = logging.getLogger(__name__) +PYTHON_HELP_ID = Categories.python_help +TIMEOUT = Free.activity_timeout +  class Free:      """Tries to figure out which help channels are free.""" - -    PYTHON_HELP_ID = Categories.python_help -    TIME_INACTIVE = 300 -      @command(name="free", aliases=('f',))      @cooldown(1, 60.0, BucketType.channel)      async def free(self, ctx: Context, user: Member = None, seek: int = 2): @@ -34,7 +33,7 @@ class Free:          in an active channel, and we want the message before that happened.          """          free_channels = [] -        python_help = utils.get(ctx.guild.categories, id=self.PYTHON_HELP_ID) +        python_help = utils.get(ctx.guild.categories, id=PYTHON_HELP_ID)          if user is not None and seek == 2:              seek = 3 @@ -49,7 +48,7 @@ class Free:                  msg = await channel.history(limit=1).next()   # noqa (False positive)              inactive = (datetime.utcnow() - msg.created_at).seconds -            if inactive > self.TIME_INACTIVE: +            if inactive > TIMEOUT:                  free_channels.append((inactive, channel))          embed = Embed() diff --git a/bot/constants.py b/bot/constants.py index aae9b05e5..689590c0c 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -471,6 +471,12 @@ class BigBrother(metaclass=YAMLGetter):      header_message_limit: int +class Free(metaclass=YAMLGetter): +    section = 'free' + +    activity_timeout: int + +  # Debug mode  DEBUG_MODE = True if 'local' in os.environ.get("SITE_URL", "local") else False diff --git a/config-default.yml b/config-default.yml index 1b4e6f412..504d40ed7 100644 --- a/config-default.yml +++ b/config-default.yml @@ -337,5 +337,11 @@ big_brother:      header_message_limit: 15 +free: +    # Seconds to elapse for a channel +    # to be considered inactive. +    activity_timeout: 300 + +  config:      required_keys: ['bot.token']  |