diff options
| author | 2018-05-20 14:45:44 +0200 | |
|---|---|---|
| committer | 2018-05-20 14:45:44 +0200 | |
| commit | 121f9aa077ac0eea8d7958e52a8e818cba391383 (patch) | |
| tree | 9d855953fdafcdb1dda2dc62bdd09d4309aea1fe | |
| parent | install missing dependency for pillow [ci skip] (diff) | |
Snake cog bugfixes (#81)
* This should fix the problem with snakes.video, and is generally a good idea to prevent https-related errors.
* This should fix the recursion error in the snakes.snakify feature
| -rw-r--r-- | bot/__main__.py | 20 | ||||
| -rw-r--r-- | bot/cogs/snakes.py | 7 | 
2 files changed, 14 insertions, 13 deletions
| diff --git a/bot/__main__.py b/bot/__main__.py index 6c115f40c..60553a0ea 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -6,7 +6,7 @@ from aiohttp import AsyncResolver, ClientSession, TCPConnector  from discord import Game  from discord.ext.commands import AutoShardedBot, when_mentioned_or -from bot.constants import CLICKUP_KEY, DEBUG_MODE +from bot.constants import CLICKUP_KEY  from bot.formatter import Formatter  log = logging.getLogger(__name__) @@ -26,17 +26,15 @@ bot = AutoShardedBot(      case_insensitive=True  ) -# Global aiohttp session for all cogs - uses asyncio for DNS resolution instead of threads, so we don't *spam threads* -if DEBUG_MODE: -    bot.http_session = ClientSession( -        connector=TCPConnector( -            resolver=AsyncResolver(), -            family=socket.AF_INET,  # Force aiohttp to use AF_INET if this is a local session. Prevents crashes. -            verify_ssl=False, -        ) +# Global aiohttp session for all cogs +# - Uses asyncio for DNS resolution instead of threads, so we don't spam threads +# - Uses AF_INET as its socket family to prevent https related problems both locally and in prod. +bot.http_session = ClientSession( +    connector=TCPConnector( +        resolver=AsyncResolver(), +        family=socket.AF_INET,      ) -else: -    bot.http_session = ClientSession(connector=TCPConnector(resolver=AsyncResolver())) +)  # Internal/debug  bot.load_extension("bot.cogs.logging") diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 3a5d79148..31890dd94 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -306,8 +306,11 @@ class Snakes:          """          long_message = random.choice(messages) -        if len(long_message.split()) < 3 or retries <= 0: -            return self._get_random_long_message(messages, retries - 1) +        if len(long_message.split()) < 3 or retries > 0: +            return self._get_random_long_message( +                messages, +                retries=retries - 1 +            )          return long_message | 
