From 7756650dc337b913bba75cdc5b9f3dabc61b4c68 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 10 Aug 2020 13:03:13 -0700 Subject: Updated to comply with reviews. --- bot/exts/evergreen/conversationstarters.py | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 bot/exts/evergreen/conversationstarters.py (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py new file mode 100644 index 00000000..f4d1d3ce --- /dev/null +++ b/bot/exts/evergreen/conversationstarters.py @@ -0,0 +1,57 @@ +import json +import logging +import random +from pathlib import Path + +from discord import Embed +from discord.ext import commands + +from bot.utils.decorators import override_in_channel + + +with Path("bot/resources/easter/starter.json").open("r", encoding="utf8") as f: + STARTERS = json.load(f)["starters"] + + +with Path("bot/resources/easter/py_topics.json").open("r", encoding="utf8") as f: + # First ID is #python-general and the rest are top to bottom categories of Topical Chat/Help. + PY_TOPICS = json.load(f)["python-channels"] + ALL_PYTHON_CHANNELS = [int(channel_id) for channel_id in PY_TOPICS.keys()] + + +class ConvoStarters(commands.Cog): + """Easter conversation topics.""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + + @commands.command() + @override_in_channel(ALL_PYTHON_CHANNELS) + async def topic(self, ctx: commands.Context) -> None: + """Responds with a random topic to start a conversation, changing depending on channel.""" + try: + # Fetching topics. + channel_topics = PY_TOPICS[str(ctx.channel.id)] + + # If the channel isn't Python-related. + except KeyError: + await ctx.send(random.choice(starters['starters'])) + + # If the channel ID doesn't have any topics. + else: + if channel_topics: + await ctx.send(random.choice(channel_topics)) + + else: + embed = Embed( + description=( + "No topics found for this Python channel. You can suggest new ideas for topics " + "[here](https://github.com/python-discord/seasonalbot/issues/426)!" + )) + + await ctx.send(embed=embed) + + +def setup(bot: commands.Bot) -> None: + """Conversation starters Cog load.""" + bot.add_cog(ConvoStarters(bot)) -- cgit v1.2.3 From 0bcbe43557b9566f265d894b28c7f47a96765196 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 10 Aug 2020 13:08:38 -0700 Subject: Linted. --- bot/exts/evergreen/conversationstarters.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index f4d1d3ce..54ed70c1 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -1,5 +1,4 @@ import json -import logging import random from pathlib import Path @@ -35,13 +34,13 @@ class ConvoStarters(commands.Cog): # If the channel isn't Python-related. except KeyError: - await ctx.send(random.choice(starters['starters'])) + await ctx.send(random.choice(STARTERS)) # If the channel ID doesn't have any topics. else: if channel_topics: await ctx.send(random.choice(channel_topics)) - + else: embed = Embed( description=( -- cgit v1.2.3 From 3317f00e7dcd7fee1bda79fd5b82f2d9fbd2e1cc Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 10 Aug 2020 13:50:10 -0700 Subject: Finalized whitelist for allowed channels .topic can be used in. Changed resource path to evergreen, added WHITELISTED_CHANNELS to PY_TOPICS channels. --- bot/exts/evergreen/conversationstarters.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 54ed70c1..4df3f068 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -6,28 +6,36 @@ from discord import Embed from discord.ext import commands from bot.utils.decorators import override_in_channel +from bot.constants import WHITELISTED_CHANNELS -with Path("bot/resources/easter/starter.json").open("r", encoding="utf8") as f: +with Path("bot/resources/evergreen/starter.json").open("r", encoding="utf8") as f: STARTERS = json.load(f)["starters"] -with Path("bot/resources/easter/py_topics.json").open("r", encoding="utf8") as f: +with Path("bot/resources/evergreen/py_topics.json").open("r", encoding="utf8") as f: # First ID is #python-general and the rest are top to bottom categories of Topical Chat/Help. PY_TOPICS = json.load(f)["python-channels"] - ALL_PYTHON_CHANNELS = [int(channel_id) for channel_id in PY_TOPICS.keys()] + + # All the allowed channels that the ".topic" command is allowed to be executed in. + ALL_ALLOWED_CHANNELS = [int(channel_id) for channel_id in PY_TOPICS.keys()].extend(WHITELISTED_CHANNELS) class ConvoStarters(commands.Cog): - """Easter conversation topics.""" + """Evergreen conversation topics.""" def __init__(self, bot: commands.Bot): self.bot = bot @commands.command() - @override_in_channel(ALL_PYTHON_CHANNELS) + @override_in_channel(ALL_ALLOWED_CHANNELS) async def topic(self, ctx: commands.Context) -> None: - """Responds with a random topic to start a conversation, changing depending on channel.""" + """Responds with a random topic to start a conversation + + If in a Python channel, a python-related topic will be given. + + Otherwise, a random conversation topic will be recieved by the user. + """ try: # Fetching topics. channel_topics = PY_TOPICS[str(ctx.channel.id)] -- cgit v1.2.3 From 77cafe8a048bfaca2b1defcedb55761acfd6f5fc Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 10 Aug 2020 13:51:51 -0700 Subject: Linted. --- bot/exts/evergreen/conversationstarters.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 4df3f068..974a361e 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -5,8 +5,8 @@ from pathlib import Path from discord import Embed from discord.ext import commands -from bot.utils.decorators import override_in_channel from bot.constants import WHITELISTED_CHANNELS +from bot.utils.decorators import override_in_channel with Path("bot/resources/evergreen/starter.json").open("r", encoding="utf8") as f: @@ -30,8 +30,9 @@ class ConvoStarters(commands.Cog): @commands.command() @override_in_channel(ALL_ALLOWED_CHANNELS) async def topic(self, ctx: commands.Context) -> None: - """Responds with a random topic to start a conversation - + """ + Responds with a random topic to start a conversation. + If in a Python channel, a python-related topic will be given. Otherwise, a random conversation topic will be recieved by the user. -- cgit v1.2.3 From 141e82af3b5506135a60de8608ec96cc11739097 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 10 Aug 2020 14:18:42 -0700 Subject: ALL_ALLOWED_CHANNELS now is a list of channel IDs instead of None. --- bot/exts/evergreen/conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 974a361e..8a07eea2 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -18,7 +18,7 @@ with Path("bot/resources/evergreen/py_topics.json").open("r", encoding="utf8") a PY_TOPICS = json.load(f)["python-channels"] # All the allowed channels that the ".topic" command is allowed to be executed in. - ALL_ALLOWED_CHANNELS = [int(channel_id) for channel_id in PY_TOPICS.keys()].extend(WHITELISTED_CHANNELS) + ALL_ALLOWED_CHANNELS = [int(channel_id) for channel_id in PY_TOPICS.keys()] + list(WHITELISTED_CHANNELS) class ConvoStarters(commands.Cog): -- cgit v1.2.3 From df51b8c11a3a42ae13dd00d8b994d5f1d70638e7 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 10 Aug 2020 14:31:11 -0700 Subject: Gave the Embed the burple color. --- bot/exts/evergreen/conversationstarters.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 8a07eea2..179fe478 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -2,7 +2,7 @@ import json import random from pathlib import Path -from discord import Embed +from discord import Color, Embed from discord.ext import commands from bot.constants import WHITELISTED_CHANNELS @@ -55,7 +55,9 @@ class ConvoStarters(commands.Cog): description=( "No topics found for this Python channel. You can suggest new ideas for topics " "[here](https://github.com/python-discord/seasonalbot/issues/426)!" - )) + ), + color=Color.blurple + ) await ctx.send(embed=embed) -- cgit v1.2.3 From 1c50a8180809561413ef5cfe73fc0fbc770f8fdc Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Mon, 10 Aug 2020 14:43:53 -0700 Subject: Update bot/exts/evergreen/conversationstarters.py Co-authored-by: Dennis Pham --- bot/exts/evergreen/conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 179fe478..757ec059 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -56,7 +56,7 @@ class ConvoStarters(commands.Cog): "No topics found for this Python channel. You can suggest new ideas for topics " "[here](https://github.com/python-discord/seasonalbot/issues/426)!" ), - color=Color.blurple + color=Color.blurple() ) await ctx.send(embed=embed) -- cgit v1.2.3 From b7779d9af8aaf207252a6adb8a6f2214f6c2ed16 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 17 Aug 2020 03:18:15 -0700 Subject: Changed from json to yaml extraction of channel topics. --- bot/exts/evergreen/conversationstarters.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 757ec059..c559c2f8 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -1,4 +1,5 @@ import json +import yaml import random from pathlib import Path @@ -13,12 +14,15 @@ with Path("bot/resources/evergreen/starter.json").open("r", encoding="utf8") as STARTERS = json.load(f)["starters"] -with Path("bot/resources/evergreen/py_topics.json").open("r", encoding="utf8") as f: +with Path("bot/resources/evergreen/py_topics.yaml").open("r", encoding="utf8") as f: # First ID is #python-general and the rest are top to bottom categories of Topical Chat/Help. - PY_TOPICS = json.load(f)["python-channels"] + PY_TOPICS = yaml.load(f, Loader=yaml.FullLoader) + + # Removing `None` from lists of topics, if not a list, it is changed to an empty one. + PY_TOPICS = {k: [i for i in v if i] if isinstance(v, list) else [] for k, v in PY_TOPICS.items()} # All the allowed channels that the ".topic" command is allowed to be executed in. - ALL_ALLOWED_CHANNELS = [int(channel_id) for channel_id in PY_TOPICS.keys()] + list(WHITELISTED_CHANNELS) + ALL_ALLOWED_CHANNELS = [channel_id for channel_id in PY_TOPICS.keys()] + list(WHITELISTED_CHANNELS) class ConvoStarters(commands.Cog): @@ -39,7 +43,7 @@ class ConvoStarters(commands.Cog): """ try: # Fetching topics. - channel_topics = PY_TOPICS[str(ctx.channel.id)] + channel_topics = PY_TOPICS[ctx.channel.id] # If the channel isn't Python-related. except KeyError: -- cgit v1.2.3 From 809a4458e418d15288749c69b061990b6b737716 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 17 Aug 2020 03:36:57 -0700 Subject: Sorted imports to comply with flake8 standards. --- bot/exts/evergreen/conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index c559c2f8..cfa8dbce 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -1,8 +1,8 @@ import json -import yaml import random from pathlib import Path +import yaml from discord import Color, Embed from discord.ext import commands -- cgit v1.2.3 From 3544e71de5c9bf2de801be22977b7dd9a40ae6f0 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Wed, 9 Sep 2020 15:01:07 -0700 Subject: Topics are now iterated through instead of randomly selected. --- bot/exts/evergreen/conversationstarters.py | 42 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index cfa8dbce..423662bb 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -1,4 +1,5 @@ -import json +import itertools +import logging import random from pathlib import Path @@ -9,10 +10,12 @@ from discord.ext import commands from bot.constants import WHITELISTED_CHANNELS from bot.utils.decorators import override_in_channel +log = logging.getLogger(__name__) -with Path("bot/resources/evergreen/starter.json").open("r", encoding="utf8") as f: - STARTERS = json.load(f)["starters"] +SUGGESTION_FORM = 'https://forms.gle/zw6kkJqv8U43Nfjg9' +with Path("bot/resources/evergreen/starter.yaml").open("r", encoding="utf8") as f: + STARTERS = yaml.load(f, Loader=yaml.FullLoader) with Path("bot/resources/evergreen/py_topics.yaml").open("r", encoding="utf8") as f: # First ID is #python-general and the rest are top to bottom categories of Topical Chat/Help. @@ -24,6 +27,16 @@ with Path("bot/resources/evergreen/py_topics.yaml").open("r", encoding="utf8") a # All the allowed channels that the ".topic" command is allowed to be executed in. ALL_ALLOWED_CHANNELS = [channel_id for channel_id in PY_TOPICS.keys()] + list(WHITELISTED_CHANNELS) +# Putting all topics into one dictionary and shuffling lists to reduce same-topic repetitions. +TOPICS = {} +for k, v in {**{'default': STARTERS}, **PY_TOPICS}.items(): + if len(v): + random.shuffle(v) + TOPICS[k] = itertools.cycle(v) + + else: + TOPICS[k] = False + class ConvoStarters(commands.Cog): """Evergreen conversation topics.""" @@ -39,31 +52,28 @@ class ConvoStarters(commands.Cog): If in a Python channel, a python-related topic will be given. - Otherwise, a random conversation topic will be recieved by the user. + Otherwise, a random conversation topic will be received by the user. """ + # No matter what, the form will be shown. + embed = Embed(description=f'Suggest more topics [here]({SUGGESTION_FORM})!', color=Color.blurple()) + try: # Fetching topics. - channel_topics = PY_TOPICS[ctx.channel.id] + channel_topics = TOPICS[ctx.channel.id] # If the channel isn't Python-related. except KeyError: - await ctx.send(random.choice(STARTERS)) + embed.title = f'**{next(TOPICS["default"])}**' # If the channel ID doesn't have any topics. else: if channel_topics: - await ctx.send(random.choice(channel_topics)) + embed.title = f'**{next(channel_topics)}**' else: - embed = Embed( - description=( - "No topics found for this Python channel. You can suggest new ideas for topics " - "[here](https://github.com/python-discord/seasonalbot/issues/426)!" - ), - color=Color.blurple() - ) - - await ctx.send(embed=embed) + embed.title = 'No topics found for this channel.' + + await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 From f1b0c9da9abf32a838f5ea323325507fd5af8020 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Wed, 9 Sep 2020 15:17:40 -0700 Subject: Removed logging. --- bot/exts/evergreen/conversationstarters.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 423662bb..68790dca 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -1,5 +1,4 @@ import itertools -import logging import random from pathlib import Path @@ -10,8 +9,6 @@ from discord.ext import commands from bot.constants import WHITELISTED_CHANNELS from bot.utils.decorators import override_in_channel -log = logging.getLogger(__name__) - SUGGESTION_FORM = 'https://forms.gle/zw6kkJqv8U43Nfjg9' with Path("bot/resources/evergreen/starter.yaml").open("r", encoding="utf8") as f: -- cgit v1.2.3 From 434e9a65529d77a0954255781c8792de60ab28d6 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Wed, 9 Sep 2020 15:49:05 -0700 Subject: Added RandomCycle utility to jump between set indexes repeatedly. --- bot/exts/evergreen/conversationstarters.py | 13 +++---------- bot/utils/randomization.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 bot/utils/randomization.py (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 68790dca..ebefc53e 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -1,5 +1,3 @@ -import itertools -import random from pathlib import Path import yaml @@ -8,6 +6,7 @@ from discord.ext import commands from bot.constants import WHITELISTED_CHANNELS from bot.utils.decorators import override_in_channel +from bot.utils.randomization import RandomCycle SUGGESTION_FORM = 'https://forms.gle/zw6kkJqv8U43Nfjg9' @@ -25,14 +24,8 @@ with Path("bot/resources/evergreen/py_topics.yaml").open("r", encoding="utf8") a ALL_ALLOWED_CHANNELS = [channel_id for channel_id in PY_TOPICS.keys()] + list(WHITELISTED_CHANNELS) # Putting all topics into one dictionary and shuffling lists to reduce same-topic repetitions. -TOPICS = {} -for k, v in {**{'default': STARTERS}, **PY_TOPICS}.items(): - if len(v): - random.shuffle(v) - TOPICS[k] = itertools.cycle(v) - - else: - TOPICS[k] = False +all_topics = {'default': STARTERS, **PY_TOPICS} +TOPICS = {channel: RandomCycle(topics) if len(topics) else False for channel, topics in all_topics.items()} class ConvoStarters(commands.Cog): diff --git a/bot/utils/randomization.py b/bot/utils/randomization.py new file mode 100644 index 00000000..063d7e1f --- /dev/null +++ b/bot/utils/randomization.py @@ -0,0 +1,19 @@ +import itertools +import random +import typing as t + + +class RandomCycle: + """Cycling through jumping to random indexes in an iterable.""" + + def __init__(self, iterable: t.Iterable) -> None: + self.iterable = list(iterable) + self.index = itertools.cycle(range(len(iterable))) + + def __next__(self) -> t.Any: + idx = next(self.index) + + if idx == 0: + random.shuffle(self.iterable) + + return self.iterable[idx] -- cgit v1.2.3 From 2844b11032e0a330bfeaf43f08c607c2f26ffc58 Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Wed, 9 Sep 2020 20:01:08 -0700 Subject: Update bot/exts/evergreen/conversationstarters.py Co-authored-by: Shirayuki Nekomata --- bot/exts/evergreen/conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index ebefc53e..16a7dcfc 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -24,7 +24,7 @@ with Path("bot/resources/evergreen/py_topics.yaml").open("r", encoding="utf8") a ALL_ALLOWED_CHANNELS = [channel_id for channel_id in PY_TOPICS.keys()] + list(WHITELISTED_CHANNELS) # Putting all topics into one dictionary and shuffling lists to reduce same-topic repetitions. -all_topics = {'default': STARTERS, **PY_TOPICS} +ALL_TOPICS = {'default': STARTERS, **PY_TOPICS} TOPICS = {channel: RandomCycle(topics) if len(topics) else False for channel, topics in all_topics.items()} -- cgit v1.2.3 From ee693c284103ca1e730f71a845b359a400bd7ed2 Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Thu, 10 Sep 2020 08:46:50 -0700 Subject: Update bot/exts/evergreen/conversationstarters.py Co-authored-by: Shirayuki Nekomata --- bot/exts/evergreen/conversationstarters.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 16a7dcfc..beda8479 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -25,7 +25,10 @@ with Path("bot/resources/evergreen/py_topics.yaml").open("r", encoding="utf8") a # Putting all topics into one dictionary and shuffling lists to reduce same-topic repetitions. ALL_TOPICS = {'default': STARTERS, **PY_TOPICS} -TOPICS = {channel: RandomCycle(topics) if len(topics) else False for channel, topics in all_topics.items()} +TOPICS = { + channel: RandomCycle(topics or ['No topics found for this channel.']) + for channel, topics in all_topics.items() +} class ConvoStarters(commands.Cog): -- cgit v1.2.3 From ffdb4ac4a80e4f1579ba1ea26547e206c18ff646 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Thu, 10 Sep 2020 09:06:37 -0700 Subject: Updated conversationstarters to simplify what values need to be checked. --- bot/exts/evergreen/conversationstarters.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index beda8479..1912d1af 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -27,7 +27,7 @@ with Path("bot/resources/evergreen/py_topics.yaml").open("r", encoding="utf8") a ALL_TOPICS = {'default': STARTERS, **PY_TOPICS} TOPICS = { channel: RandomCycle(topics or ['No topics found for this channel.']) - for channel, topics in all_topics.items() + for channel, topics in ALL_TOPICS.items() } @@ -60,13 +60,10 @@ class ConvoStarters(commands.Cog): # If the channel ID doesn't have any topics. else: - if channel_topics: - embed.title = f'**{next(channel_topics)}**' + embed.title = f'**{next(channel_topics)}**' - else: - embed.title = 'No topics found for this channel.' - - await ctx.send(embed=embed) + finally: + await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 From e7f65121440a5fcbc53ad604a7dfbc24f30bab3b Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Thu, 10 Sep 2020 15:54:07 -0700 Subject: Update bot/exts/evergreen/conversationstarters.py Co-authored-by: Dennis Pham --- bot/exts/evergreen/conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot/exts/evergreen/conversationstarters.py') diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index 1912d1af..576b8d76 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -21,7 +21,7 @@ with Path("bot/resources/evergreen/py_topics.yaml").open("r", encoding="utf8") a PY_TOPICS = {k: [i for i in v if i] if isinstance(v, list) else [] for k, v in PY_TOPICS.items()} # All the allowed channels that the ".topic" command is allowed to be executed in. - ALL_ALLOWED_CHANNELS = [channel_id for channel_id in PY_TOPICS.keys()] + list(WHITELISTED_CHANNELS) + ALL_ALLOWED_CHANNELS = list(PY_TOPICS.keys()) + list(WHITELISTED_CHANNELS) # Putting all topics into one dictionary and shuffling lists to reduce same-topic repetitions. ALL_TOPICS = {'default': STARTERS, **PY_TOPICS} -- cgit v1.2.3