From 8e6b3470381947b64c7c0551ccafae92a7f2ef14 Mon Sep 17 00:00:00 2001 From: Anubhav <57266248+Anubhav1603@users.noreply.github.com> Date: Mon, 21 Sep 2020 11:55:36 +0530 Subject: changed titles_no_underscore -> titles Co-authored-by: Thomas Petersson <61778143+thomaspet@users.noreply.github.com> --- bot/exts/evergreen/wikipedia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/evergreen/wikipedia.py b/bot/exts/evergreen/wikipedia.py index ab01e1ee..6087a014 100644 --- a/bot/exts/evergreen/wikipedia.py +++ b/bot/exts/evergreen/wikipedia.py @@ -85,7 +85,7 @@ class WikipediaCog(commands.Cog): elif response == 0: await ctx.send(f"Sorry, please give an integer between `1` to `{titles_len}`, {error_msg}") else: - await ctx.send(WIKIPEDIA_URL.format(title=titles_no_underscore[response - 1])) + await ctx.send(WIKIPEDIA_URL.format(title=titles[response - 1].replace(" ", "_"))) break except asyncio.TimeoutError: -- cgit v1.2.3 From 5528dddaf9da08b70c5ccba9c7477190427970c1 Mon Sep 17 00:00:00 2001 From: Anubhav <57266248+Anubhav1603@users.noreply.github.com> Date: Mon, 21 Sep 2020 11:56:33 +0530 Subject: Removed the title_no_underscore list with titles Co-authored-by: Thomas Petersson <61778143+thomaspet@users.noreply.github.com> --- bot/exts/evergreen/wikipedia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/evergreen/wikipedia.py b/bot/exts/evergreen/wikipedia.py index 6087a014..7e568392 100644 --- a/bot/exts/evergreen/wikipedia.py +++ b/bot/exts/evergreen/wikipedia.py @@ -66,7 +66,7 @@ class WikipediaCog(commands.Cog): await ctx.send(embed=embed) embed = Embed(colour=Color.green(), description="Enter number to choose") msg = await ctx.send(embed=embed) - titles_len = len(titles_no_underscore) # getting length of list + titles_len = len(titles) # getting length of list for retry_count in range(1, Wikipedia.total_chance + 1): retries_left = Wikipedia.total_chance - retry_count -- cgit v1.2.3 From 095468c6ee72098ca6a79b6eaee1d03fbb60487c Mon Sep 17 00:00:00 2001 From: Anubhav <57266248+Anubhav1603@users.noreply.github.com> Date: Mon, 21 Sep 2020 11:57:04 +0530 Subject: Update bot/exts/evergreen/wikipedia.py Co-authored-by: Thomas Petersson <61778143+thomaspet@users.noreply.github.com> --- bot/exts/evergreen/wikipedia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/evergreen/wikipedia.py b/bot/exts/evergreen/wikipedia.py index 7e568392..7fac3575 100644 --- a/bot/exts/evergreen/wikipedia.py +++ b/bot/exts/evergreen/wikipedia.py @@ -60,7 +60,7 @@ class WikipediaCog(commands.Cog): titles_no_underscore = [title.replace(" ", "_") for title in titles] # wikipedia uses "_" as spaces log.info("Finished appending titles to titles_no_underscore list") - s_desc = "\n".join(self.formatted_wiki_urls(index, title)for index, title in enumerate(titles, start=1)) + s_desc = "\n".join(self.formatted_wiki_url(index, title) for index, title in enumerate(titles, start=1)) embed = Embed(colour=Color.blue(), title=f"Wikipedia results for `{search}`", description=s_desc) embed.timestamp = datetime.datetime.utcnow() await ctx.send(embed=embed) -- cgit v1.2.3 From 398425dbd881e7a3b01c3a821819873852567578 Mon Sep 17 00:00:00 2001 From: Anubhav <57266248+Anubhav1603@users.noreply.github.com> Date: Mon, 21 Sep 2020 11:58:49 +0530 Subject: made code more readable Co-authored-by: Thomas Petersson <61778143+thomaspet@users.noreply.github.com> --- bot/exts/evergreen/wikipedia.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bot/exts/evergreen/wikipedia.py b/bot/exts/evergreen/wikipedia.py index 7fac3575..e18c0b79 100644 --- a/bot/exts/evergreen/wikipedia.py +++ b/bot/exts/evergreen/wikipedia.py @@ -77,8 +77,10 @@ class WikipediaCog(commands.Cog): try: message = await ctx.bot.wait_for('message', timeout=60.0, check=check) response_from_user = await self.bot.get_context(message) + if response_from_user.command: return + response = int(message.content) if response < 0: await ctx.send(f"Sorry, but you can't give negative index, {error_msg}") -- cgit v1.2.3 From a4e949123816150f86c8dbf8a36a4a67741a4f0c Mon Sep 17 00:00:00 2001 From: Anubhav <57266248+Anubhav1603@users.noreply.github.com> Date: Mon, 21 Sep 2020 11:59:55 +0530 Subject: changed f_wiki_urls -> f_wiki_url Co-authored-by: Thomas Petersson <61778143+thomaspet@users.noreply.github.com> --- bot/exts/evergreen/wikipedia.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bot/exts/evergreen/wikipedia.py b/bot/exts/evergreen/wikipedia.py index e18c0b79..c565a404 100644 --- a/bot/exts/evergreen/wikipedia.py +++ b/bot/exts/evergreen/wikipedia.py @@ -22,10 +22,9 @@ class WikipediaCog(commands.Cog): self.http_session = bot.http_session @staticmethod - def formatted_wiki_urls(index: int, titles: str) -> List[str]: - """Making formatted wikipedia links list.""" - titles = f'`{index}` [{titles}]({WIKIPEDIA_URL.format(title=titles.replace(" ", "_"))})' - return titles + def formatted_wiki_url(index: int, titles: str) -> str: + """Making formatted wikipedia link..""" + return f'`{index}` [{title}]({WIKIPEDIA_URL.format(title=title.replace(" ", "_"))})' async def search_wikipedia(self, search_term: str) -> List[str]: """Search wikipedia and return the first page found.""" -- cgit v1.2.3