From 217b42985f782a1227371296f313c4ea7402a87a Mon Sep 17 00:00:00 2001 From: AtieP <62116490+AtieP@users.noreply.github.com> Date: Sat, 13 Jun 2020 14:44:52 +0200 Subject: 6 more questions added. 6 more questions added for the quiz command on the category Evergreen. --- bot/resources/evergreen/trivia_quiz.json | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'bot') diff --git a/bot/resources/evergreen/trivia_quiz.json b/bot/resources/evergreen/trivia_quiz.json index 6100ca62..f655e39d 100644 --- a/bot/resources/evergreen/trivia_quiz.json +++ b/bot/resources/evergreen/trivia_quiz.json @@ -217,6 +217,36 @@ "question": "What does the acronym GPRS stand for?", "answer": "General Packet Radio Service", "info": "General Packet Radio Service (GPRS) is a packet-based mobile data service on the global system for mobile communications (GSM) of 3G and 2G cellular communication systems. It is a non-voice, high-speed and useful packet-switching technology intended for GSM networks." + }, + { + "id": 131, + "question": "In what country the Ebro river is located?", + "answer": "Spain", + "info": "The Ebro river is a river located in Spain. It is 930 kilometers long and it's the second longest river that ends on the Mediterranean Sea." + }, + { + "id": 132, + "question": "What year the IBM PC model 5150 was introduced in the market?", + "answer": "1981", + "info": "The IBM PC was introduced in the market on 1981. It used the Intel 8088, with a clock speed of 4.77 MHz, along with the MDA and CGA as a video card." + }, + { + "id": 133, + "question": "What's the world's largest urban area?", + "answer": "Tokio", + "info": "Tokio is the most populated city in the world, with 37 million of people. It is located on Japan." + }, + { + "id": 134, + "question": "How many planets there are on the Solar system?", + "answer": "8", + "info": "On the Solar system there are 8 planets: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus and Neptune. Pluto isn't considered a planet on the Solar System anymore." + }, + { + "id": 135, + "question": "What is the capital of Iraq?", + "answer": "Baghdad", + "info": "Baghdad is the capital of Iraq. It has a population of 7 million people." } ] } -- cgit v1.2.3 From ab63770f00783a7d12e34affefe3c3c8abce0d8f Mon Sep 17 00:00:00 2001 From: AtieP <62116490+AtieP@users.noreply.github.com> Date: Fri, 19 Jun 2020 19:12:26 +0200 Subject: Update bot/resources/evergreen/trivia_quiz.json Co-authored-by: Dennis Pham --- bot/resources/evergreen/trivia_quiz.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/resources/evergreen/trivia_quiz.json b/bot/resources/evergreen/trivia_quiz.json index f655e39d..dfffc0c2 100644 --- a/bot/resources/evergreen/trivia_quiz.json +++ b/bot/resources/evergreen/trivia_quiz.json @@ -220,7 +220,7 @@ }, { "id": 131, - "question": "In what country the Ebro river is located?", + "question": "In what country is the Ebro river located?", "answer": "Spain", "info": "The Ebro river is a river located in Spain. It is 930 kilometers long and it's the second longest river that ends on the Mediterranean Sea." }, -- cgit v1.2.3 From 9eaaf91076e564364c321e7860044e697da5dffc Mon Sep 17 00:00:00 2001 From: AtieP <62116490+AtieP@users.noreply.github.com> Date: Fri, 19 Jun 2020 19:12:38 +0200 Subject: Update bot/resources/evergreen/trivia_quiz.json Co-authored-by: Dennis Pham --- bot/resources/evergreen/trivia_quiz.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/resources/evergreen/trivia_quiz.json b/bot/resources/evergreen/trivia_quiz.json index dfffc0c2..e521f901 100644 --- a/bot/resources/evergreen/trivia_quiz.json +++ b/bot/resources/evergreen/trivia_quiz.json @@ -226,7 +226,7 @@ }, { "id": 132, - "question": "What year the IBM PC model 5150 was introduced in the market?", + "question": "What year was the IBM PC model 5150 introduced into the market?", "answer": "1981", "info": "The IBM PC was introduced in the market on 1981. It used the Intel 8088, with a clock speed of 4.77 MHz, along with the MDA and CGA as a video card." }, -- cgit v1.2.3 From 49b99331bbbb5c6532d20ae0216f0db4966f23f3 Mon Sep 17 00:00:00 2001 From: AtieP <62116490+AtieP@users.noreply.github.com> Date: Fri, 19 Jun 2020 19:12:59 +0200 Subject: Update bot/resources/evergreen/trivia_quiz.json Co-authored-by: Dennis Pham --- bot/resources/evergreen/trivia_quiz.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/resources/evergreen/trivia_quiz.json b/bot/resources/evergreen/trivia_quiz.json index e521f901..067b8fb5 100644 --- a/bot/resources/evergreen/trivia_quiz.json +++ b/bot/resources/evergreen/trivia_quiz.json @@ -233,7 +233,7 @@ { "id": 133, "question": "What's the world's largest urban area?", - "answer": "Tokio", + "answer": "Tokyo", "info": "Tokio is the most populated city in the world, with 37 million of people. It is located on Japan." }, { -- cgit v1.2.3 From 8bdf68bc67115e09a4456a82e9c8e9bca06928ab Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sat, 11 Jul 2020 10:16:55 -0700 Subject: Created the statuscat command. --- bot/exts/evergreen/status_cats.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 bot/exts/evergreen/status_cats.py (limited to 'bot') diff --git a/bot/exts/evergreen/status_cats.py b/bot/exts/evergreen/status_cats.py new file mode 100644 index 00000000..e28b0213 --- /dev/null +++ b/bot/exts/evergreen/status_cats.py @@ -0,0 +1,33 @@ +import logging + +from discord.ext import commands +from http import HTTPStatus +import discord + +log = logging.getLogger(__name__) + + +class StatusCats(commands.Cog): + """Commands that give statuses described and visualized by cats.""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + + @commands.command(aliases=['statuscat']) + async def http_cat(self, ctx, code: int) -> None: + """Sends an embed with an image of a cat, potraying the status code.""" + embed = discord.Embed(title=f'**Status: {code}**') + embed.set_image(url=f'https://http.cat/{code}.jpg') + + try: + HTTPStatus(code) + + except ValueError: + embed.set_footer(text='Inputted status code does not exist.') + + await ctx.send(embed=embed) + + +def setup(bot: commands.Bot) -> None: + """Load the StatusCats cog.""" + bot.add_cog(StatusCats(bot)) -- cgit v1.2.3 From 4c219ac7f616ef008b8deafc49819ab733d1fe4a Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sat, 11 Jul 2020 10:39:01 -0700 Subject: Fixed importing and context argument annotation. --- bot/exts/evergreen/status_cats.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/status_cats.py b/bot/exts/evergreen/status_cats.py index e28b0213..900f0ad6 100644 --- a/bot/exts/evergreen/status_cats.py +++ b/bot/exts/evergreen/status_cats.py @@ -1,8 +1,8 @@ import logging - -from discord.ext import commands from http import HTTPStatus + import discord +from discord.ext import commands log = logging.getLogger(__name__) @@ -14,7 +14,7 @@ class StatusCats(commands.Cog): self.bot = bot @commands.command(aliases=['statuscat']) - async def http_cat(self, ctx, code: int) -> None: + async def http_cat(self, ctx: commands.Context, code: int) -> None: """Sends an embed with an image of a cat, potraying the status code.""" embed = discord.Embed(title=f'**Status: {code}**') embed.set_image(url=f'https://http.cat/{code}.jpg') -- cgit v1.2.3 From 240d64e485eb90da0081597bea615676ae1f3bac Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Sun, 12 Jul 2020 17:17:58 -0700 Subject: Update bot/exts/evergreen/status_cats.py Co-authored-by: manusaurio --- bot/exts/evergreen/status_cats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/status_cats.py b/bot/exts/evergreen/status_cats.py index 900f0ad6..18777e0b 100644 --- a/bot/exts/evergreen/status_cats.py +++ b/bot/exts/evergreen/status_cats.py @@ -17,10 +17,11 @@ class StatusCats(commands.Cog): async def http_cat(self, ctx: commands.Context, code: int) -> None: """Sends an embed with an image of a cat, potraying the status code.""" embed = discord.Embed(title=f'**Status: {code}**') - embed.set_image(url=f'https://http.cat/{code}.jpg') + try: HTTPStatus(code) + embed.set_image(url=f'https://http.cat/{code}.jpg') except ValueError: embed.set_footer(text='Inputted status code does not exist.') -- cgit v1.2.3 From e459832da981e0ed6fb644cec9a244371935a540 Mon Sep 17 00:00:00 2001 From: manusaurio Date: Sun, 12 Jul 2020 21:32:18 -0300 Subject: Delete extra blank line to pass linter --- bot/exts/evergreen/status_cats.py | 1 - 1 file changed, 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/status_cats.py b/bot/exts/evergreen/status_cats.py index 18777e0b..b2077b17 100644 --- a/bot/exts/evergreen/status_cats.py +++ b/bot/exts/evergreen/status_cats.py @@ -18,7 +18,6 @@ class StatusCats(commands.Cog): """Sends an embed with an image of a cat, potraying the status code.""" embed = discord.Embed(title=f'**Status: {code}**') - try: HTTPStatus(code) embed.set_image(url=f'https://http.cat/{code}.jpg') -- cgit v1.2.3 From 51ef384b768933db3aa47ac437ac335de2f4239d Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Sun, 12 Jul 2020 18:28:48 -0700 Subject: Update bot/exts/evergreen/status_cats.py Co-authored-by: Dennis Pham --- bot/exts/evergreen/status_cats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/status_cats.py b/bot/exts/evergreen/status_cats.py index b2077b17..e1758514 100644 --- a/bot/exts/evergreen/status_cats.py +++ b/bot/exts/evergreen/status_cats.py @@ -8,7 +8,7 @@ log = logging.getLogger(__name__) class StatusCats(commands.Cog): - """Commands that give statuses described and visualized by cats.""" + """Commands that give HTTP statuses described and visualized by cats.""" def __init__(self, bot: commands.Bot): self.bot = bot -- cgit v1.2.3 From 1631d67e3a4ac11526817a862b1d65222ae753c3 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sun, 12 Jul 2020 18:33:45 -0700 Subject: Removed logging, added more explicit error catching.. --- bot/exts/evergreen/status_cats.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/status_cats.py b/bot/exts/evergreen/status_cats.py index e1758514..586b8378 100644 --- a/bot/exts/evergreen/status_cats.py +++ b/bot/exts/evergreen/status_cats.py @@ -1,11 +1,8 @@ -import logging from http import HTTPStatus import discord from discord.ext import commands -log = logging.getLogger(__name__) - class StatusCats(commands.Cog): """Commands that give HTTP statuses described and visualized by cats.""" @@ -20,12 +17,15 @@ class StatusCats(commands.Cog): try: HTTPStatus(code) - embed.set_image(url=f'https://http.cat/{code}.jpg') except ValueError: embed.set_footer(text='Inputted status code does not exist.') - await ctx.send(embed=embed) + else: + embed.set_image(url=f'https://http.cat/{code}.jpg') + + finally: + await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 From 746e4dbe67499c55e9e60dd9c5ad58ae378b1c9a Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Tue, 14 Jul 2020 11:58:30 -0700 Subject: Prevent bot from mentioning non-mod roles This was open to abuse when the bot relayed user input. The fix relies on a discord.py alpha feature. --- Pipfile | 2 +- Pipfile.lock | 199 +++++++++++++++++++++++++++++++---------------------------- bot/bot.py | 6 +- 3 files changed, 110 insertions(+), 97 deletions(-) (limited to 'bot') diff --git a/Pipfile b/Pipfile index 9e391945..37150f30 100644 --- a/Pipfile +++ b/Pipfile @@ -7,7 +7,7 @@ name = "pypi" aiodns = "~=2.0" arrow = "~=0.14" beautifulsoup4 = "~=4.8" -discord-py = "~=1.3.2" +discord-py = {git = "https://github.com/Rapptz/discord.py.git",ref = "0bc15fa130b8f01fe2d67446a2184d474b0d0ba7"} fuzzywuzzy = "~=0.17" pillow = "~=6.2" pytz = "~=2019.2" diff --git a/Pipfile.lock b/Pipfile.lock index ad92fcf1..790392a6 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "d1c0feb610f6742095c50eb3049fdd308603c17e1a785c03d9bf703eda0af985" + "sha256": "575635f8ffcd94910243ffcb4274efeebd5179b0d2e7d9bdc89a8602ab04e7f3" }, "pipfile-spec": 6, "requires": { @@ -39,21 +39,23 @@ "sha256:ae55bac364c405caa23a4f2d6cfecc6a0daada500274ffca4a9230e7129eac59", "sha256:b778ce0c909a2653741cb4b1ac7015b5c130ab9c897611df43ae6a58523cb965" ], + "markers": "python_full_version >= '3.5.3'", "version": "==3.6.2" }, "arrow": { "hashes": [ - "sha256:5390e464e2c5f76971b60ffa7ee29c598c7501a294bc9f5e6dadcb251a5d027b", - "sha256:70729bcc831da496ca3cb4b7e89472c8e2d27d398908155e0796179f6d2d41ee" + "sha256:3f1a92b25bbee5f80cc8f6bdecfeade9028219229137c559c37335b4f574a292", + "sha256:61a1af3a31f731e7993509124839ac28b91b6743bd6692a949600737900cf43b" ], "index": "pypi", - "version": "==0.15.5" + "version": "==0.15.7" }, "async-timeout": { "hashes": [ "sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f", "sha256:4291ca197d287d274d0b6cb5d6f8f8f82d434ed288f962539ff18cc9012f9ea3" ], + "markers": "python_full_version >= '3.5.3'", "version": "==3.0.1" }, "attrs": { @@ -61,23 +63,24 @@ "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==19.3.0" }, "beautifulsoup4": { "hashes": [ - "sha256:05fd825eb01c290877657a56df4c6e4c311b3965bda790c613a3d6fb01a5462a", - "sha256:9fbb4d6e48ecd30bcacc5b63b94088192dcda178513b2ae3c394229f8911b887", - "sha256:e1505eeed31b0f4ce2dbb3bc8eb256c04cc2b3b72af7d551a4ab6efd5cbe5dae" + "sha256:73cc4d115b96f79c7d77c1c7f7a0a8d4c57860d1041df407dd1aae7f07a77fd7", + "sha256:a6237df3c32ccfaee4fd201c8f5f9d9df619b93121d01353a64a73ce8c6ef9a8", + "sha256:e718f2342e2e099b640a34ab782407b7b676f47ee272d6739e60b8ea23829f2c" ], "index": "pypi", - "version": "==4.8.2" + "version": "==4.9.1" }, "certifi": { "hashes": [ - "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3", - "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f" + "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3", + "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41" ], - "version": "==2019.11.28" + "version": "==2020.6.20" }, "cffi": { "hashes": [ @@ -120,11 +123,8 @@ "version": "==3.0.4" }, "discord-py": { - "hashes": [ - "sha256:7424be26b07b37ecad4404d9383d685995a0e0b3df3f9c645bdd3a4d977b83b4" - ], - "index": "pypi", - "version": "==1.3.2" + "git": "https://github.com/Rapptz/discord.py.git", + "ref": "0bc15fa130b8f01fe2d67446a2184d474b0d0ba7" }, "fuzzywuzzy": { "hashes": [ @@ -136,32 +136,34 @@ }, "idna": { "hashes": [ - "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb", - "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa" + "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6", + "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" ], - "version": "==2.9" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.10" }, "multidict": { "hashes": [ - "sha256:317f96bc0950d249e96d8d29ab556d01dd38888fbe68324f46fd834b430169f1", - "sha256:42f56542166040b4474c0c608ed051732033cd821126493cf25b6c276df7dd35", - "sha256:4b7df040fb5fe826d689204f9b544af469593fb3ff3a069a6ad3409f742f5928", - "sha256:544fae9261232a97102e27a926019100a9db75bec7b37feedd74b3aa82f29969", - "sha256:620b37c3fea181dab09267cd5a84b0f23fa043beb8bc50d8474dd9694de1fa6e", - "sha256:6e6fef114741c4d7ca46da8449038ec8b1e880bbe68674c01ceeb1ac8a648e78", - "sha256:7774e9f6c9af3f12f296131453f7b81dabb7ebdb948483362f5afcaac8a826f1", - "sha256:85cb26c38c96f76b7ff38b86c9d560dea10cf3459bb5f4caf72fc1bb932c7136", - "sha256:a326f4240123a2ac66bb163eeba99578e9d63a8654a59f4688a79198f9aa10f8", - "sha256:ae402f43604e3b2bc41e8ea8b8526c7fa7139ed76b0d64fc48e28125925275b2", - "sha256:aee283c49601fa4c13adc64c09c978838a7e812f85377ae130a24d7198c0331e", - "sha256:b51249fdd2923739cd3efc95a3d6c363b67bbf779208e9f37fd5e68540d1a4d4", - "sha256:bb519becc46275c594410c6c28a8a0adc66fe24fef154a9addea54c1adb006f5", - "sha256:c2c37185fb0af79d5c117b8d2764f4321eeb12ba8c141a95d0aa8c2c1d0a11dd", - "sha256:dc561313279f9d05a3d0ffa89cd15ae477528ea37aa9795c4654588a3287a9ab", - "sha256:e439c9a10a95cb32abd708bb8be83b2134fa93790a4fb0535ca36db3dda94d20", - "sha256:fc3b4adc2ee8474cb3cd2a155305d5f8eda0a9c91320f83e55748e1fcb68f8e3" - ], - "version": "==4.7.5" + "sha256:1ece5a3369835c20ed57adadc663400b5525904e53bae59ec854a5d36b39b21a", + "sha256:275ca32383bc5d1894b6975bb4ca6a7ff16ab76fa622967625baeebcf8079000", + "sha256:3750f2205b800aac4bb03b5ae48025a64e474d2c6cc79547988ba1d4122a09e2", + "sha256:4538273208e7294b2659b1602490f4ed3ab1c8cf9dbdd817e0e9db8e64be2507", + "sha256:5141c13374e6b25fe6bf092052ab55c0c03d21bd66c94a0e3ae371d3e4d865a5", + "sha256:51a4d210404ac61d32dada00a50ea7ba412e6ea945bbe992e4d7a595276d2ec7", + "sha256:5cf311a0f5ef80fe73e4f4c0f0998ec08f954a6ec72b746f3c179e37de1d210d", + "sha256:6513728873f4326999429a8b00fc7ceddb2509b01d5fd3f3be7881a257b8d463", + "sha256:7388d2ef3c55a8ba80da62ecfafa06a1c097c18032a501ffd4cabbc52d7f2b19", + "sha256:9456e90649005ad40558f4cf51dbb842e32807df75146c6d940b6f5abb4a78f3", + "sha256:c026fe9a05130e44157b98fea3ab12969e5b60691a276150db9eda71710cd10b", + "sha256:d14842362ed4cf63751648e7672f7174c9818459d169231d03c56e84daf90b7c", + "sha256:e0d072ae0f2a179c375f67e3da300b47e1a83293c554450b29c900e50afaae87", + "sha256:f07acae137b71af3bb548bd8da720956a3bc9f9a0b87733e0899226a2317aeb7", + "sha256:fbb77a75e529021e7c4a8d4e823d88ef4d23674a202be4f5addffc72cbb91430", + "sha256:fcfbb44c59af3f8ea984de67ec7c306f618a3ec771c2843804069917a8f2e255", + "sha256:feed85993dbdb1dbc29102f50bca65bdc68f2c0c8d352468c25b54874f23c39d" + ], + "markers": "python_version >= '3.5'", + "version": "==4.7.6" }, "pillow": { "hashes": [ @@ -238,6 +240,7 @@ "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0", "sha256:7582ad22678f0fcd81102833f60ef8d0e57288b6b5fb00323d101be910e35705" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.20" }, "python-dateutil": { @@ -245,6 +248,7 @@ "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.8.1" }, "pytz": { @@ -257,32 +261,35 @@ }, "sentry-sdk": { "hashes": [ - "sha256:23808d571d2461a4ce3784ec12bbee5bdb8c026c143fe79d36cef8a6d653e71f", - "sha256:bb90a4e19c7233a580715fc986cc44be2c48fc10b31e71580a2037e1c94b6950" + "sha256:0e5e947d0f7a969314aa23669a94a9712be5a688ff069ff7b9fc36c66adc160c", + "sha256:799a8bf76b012e3030a881be00e97bc0b922ce35dde699c6537122b751d80e2c" ], "index": "pypi", - "version": "==0.14.3" + "version": "==0.14.4" }, "six": { "hashes": [ - "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a", - "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c" + "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", + "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" ], - "version": "==1.14.0" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.15.0" }, "soupsieve": { "hashes": [ - "sha256:e914534802d7ffd233242b785229d5ba0766a7f487385e3f714446a07bf540ae", - "sha256:fcd71e08c0aee99aca1b73f45478549ee7e7fc006d51b37bec9e9def7dc22b69" + "sha256:1634eea42ab371d3d346309b93df7870a88610f0725d47528be902a0d95ecc55", + "sha256:a59dc181727e95d25f781f0eb4fd1825ff45590ec8ff49eadfd7f1a537cc0232" ], - "version": "==2.0" + "markers": "python_version >= '3.5'", + "version": "==2.0.1" }, "urllib3": { "hashes": [ - "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc", - "sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc" + "sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527", + "sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115" ], - "version": "==1.25.8" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", + "version": "==1.25.9" }, "websockets": { "hashes": [ @@ -309,6 +316,7 @@ "sha256:e898a0863421650f0bebac8ba40840fc02258ef4714cb7e1fd76b6a6354bda36", "sha256:f8a7bff6e8664afc4e6c28b983845c5bc14965030e3fb98789734d416af77c4b" ], + "markers": "python_full_version >= '3.6.1'", "version": "==8.1" }, "yarl": { @@ -331,22 +339,24 @@ "sha256:d8cdee92bc930d8b09d8bd2043cedd544d9c8bd7436a77678dd602467a993080", "sha256:e15199cdb423316e15f108f51249e44eb156ae5dba232cb73be555324a1d49c2" ], + "markers": "python_version >= '3.5'", "version": "==1.4.2" } }, "develop": { "appdirs": { "hashes": [ - "sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92", - "sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e" + "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41", + "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128" ], - "version": "==1.4.3" + "version": "==1.4.4" }, "attrs": { "hashes": [ "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72" ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==19.3.0" }, "cfgv": { @@ -354,20 +364,15 @@ "sha256:1ccf53320421aeeb915275a196e23b3b8ae87dea8ac6698b1638001d4a486d53", "sha256:c8e8f552ffcc6194f4e18dd4f68d9aef0c0d58ae7e7be8c82bee3c5e9edfa513" ], + "markers": "python_full_version >= '3.6.1'", "version": "==3.1.0" }, "distlib": { "hashes": [ - "sha256:2e166e231a26b36d6dfe35a48c4464346620f8645ed0ace01ee31822b288de21" + "sha256:8c09de2c67b3e7deef7184574fc060ab8a793e7adbb183d942c389c8b13c52fb", + "sha256:edf6116872c863e1aa9d5bb7cb5e05a022c519a4594dc703843343a9ddd9bff1" ], - "version": "==0.3.0" - }, - "entrypoints": { - "hashes": [ - "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", - "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" - ], - "version": "==0.3" + "version": "==0.3.1" }, "filelock": { "hashes": [ @@ -378,19 +383,19 @@ }, "flake8": { "hashes": [ - "sha256:45681a117ecc81e870cbf1262835ae4af5e7a8b08e40b944a8a6e6b895914cfb", - "sha256:49356e766643ad15072a789a20915d3c91dc89fd313ccd71802303fd67e4deca" + "sha256:15e351d19611c887e482fb960eae4d44845013cc142d42896e9862f775d8cf5c", + "sha256:f04b9fcbac03b0a3e58c0ab3a0ecc462e023a9faf046d57794184028123aa208" ], "index": "pypi", - "version": "==3.7.9" + "version": "==3.8.3" }, "flake8-annotations": { "hashes": [ - "sha256:a38b44d01abd480586a92a02a2b0a36231ec42dcc5e114de78fa5db016d8d3f9", - "sha256:d5b0e8704e4e7728b352fa1464e23539ff2341ba11cc153b536fa2cf921ee659" + "sha256:7816a5d8f65ffdf37b8e21e5b17e0fd1e492aa92638573276de066e889a22b26", + "sha256:8d18db74a750dd97f40b483cc3ef80d07d03f687525bad8fd83365dcd3bfd414" ], "index": "pypi", - "version": "==2.0.1" + "version": "==2.3.0" }, "flake8-bugbear": { "hashes": [ @@ -448,10 +453,11 @@ }, "identify": { "hashes": [ - "sha256:a7577a1f55cee1d21953a5cf11a3c839ab87f5ef909a4cba6cf52ed72b4c6059", - "sha256:ab246293e6585a1c6361a505b68d5b501a0409310932b7de2c2ead667b564d89" + "sha256:882c4b08b4569517b5f2257ecca180e01f38400a17f429f5d0edff55530c41c7", + "sha256:f89add935982d5bc62913ceee16c9297d8ff14b226e9d3072383a4e38136b656" ], - "version": "==1.4.13" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.4.23" }, "mccabe": { "hashes": [ @@ -462,46 +468,49 @@ }, "nodeenv": { "hashes": [ - "sha256:5b2438f2e42af54ca968dd1b374d14a1194848955187b0e5e4be1f73813a5212" + "sha256:4b0b77afa3ba9b54f4b6396e60b0c83f59eaeb2d63dc3cc7a70f7f4af96c82bc" ], - "version": "==1.3.5" + "version": "==1.4.0" }, "pep8-naming": { "hashes": [ - "sha256:5d9f1056cb9427ce344e98d1a7f5665710e2f20f748438e308995852cfa24164", - "sha256:f3b4a5f9dd72b991bf7d8e2a341d2e1aa3a884a769b5aaac4f56825c1763bf3a" + "sha256:a1dd47dd243adfe8a83616e27cf03164960b507530f155db94e10b36a6cd6724", + "sha256:f43bfe3eea7e0d73e8b5d07d6407ab47f2476ccaeff6937c84275cd30b016738" ], "index": "pypi", - "version": "==0.10.0" + "version": "==0.11.1" }, "pre-commit": { "hashes": [ - "sha256:487c675916e6f99d355ec5595ad77b325689d423ef4839db1ed2f02f639c9522", - "sha256:c0aa11bce04a7b46c5544723aedf4e81a4d5f64ad1205a30a9ea12d5e81969e1" + "sha256:1657663fdd63a321a4a739915d7d03baedd555b25054449090f97bb0cb30a915", + "sha256:e8b1315c585052e729ab7e99dcca5698266bedce9067d21dc909c23e3ceed626" ], "index": "pypi", - "version": "==2.2.0" + "version": "==2.6.0" }, "pycodestyle": { "hashes": [ - "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", - "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" + "sha256:2295e7b2f6b5bd100585ebcb1f616591b652db8a741695b3d8f5d28bdc934367", + "sha256:c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e" ], - "version": "==2.5.0" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.6.0" }, "pydocstyle": { "hashes": [ "sha256:da7831660b7355307b32778c4a0dbfb137d89254ef31a2b2978f50fc0b4d7586", "sha256:f4f5d210610c2d153fae39093d44224c17429e2ad7da12a8b419aba5c2f614b5" ], + "markers": "python_version >= '3.5'", "version": "==5.0.2" }, "pyflakes": { "hashes": [ - "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", - "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" + "sha256:0d94e0e05a19e57a99444b6ddcf9a6eb2e5c68d3ca1e98e90707af8152c90a92", + "sha256:35b2d75ee967ea93b55750aa9edbbf72813e06a66ba54438df2cfac9e3c27fc8" ], - "version": "==2.1.1" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.2.0" }, "pyyaml": { "hashes": [ @@ -521,10 +530,11 @@ }, "six": { "hashes": [ - "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a", - "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c" + "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", + "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" ], - "version": "==1.14.0" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.15.0" }, "snowballstemmer": { "hashes": [ @@ -535,17 +545,18 @@ }, "toml": { "hashes": [ - "sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", - "sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e" + "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f", + "sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88" ], - "version": "==0.10.0" + "version": "==0.10.1" }, "virtualenv": { "hashes": [ - "sha256:6f4c2882a943d20714076679f8dcc5675e953d6c29bfea3bc5d08bb6cdea5d36", - "sha256:cb1dab893f9e39b3e68d9118c555dcd86526d531c128c3f72e1551939723b72f" + "sha256:c11a475400e98450403c0364eb3a2d25d42f71cf1493da64390487b666de4324", + "sha256:e10cc66f40cbda459720dfe1d334c4dc15add0d80f09108224f171006a97a172" ], - "version": "==20.0.14" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==20.0.26" } } } diff --git a/bot/bot.py b/bot/bot.py index 39ed8bbe..ffaf4284 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -10,7 +10,7 @@ from aiohttp import AsyncResolver, ClientSession, TCPConnector from discord import DiscordException, Embed, Guild, User from discord.ext import commands -from bot.constants import Channels, Client +from bot.constants import Channels, Client, MODERATION_ROLES from bot.utils.decorators import mock_in_debug log = logging.getLogger(__name__) @@ -103,7 +103,7 @@ class SeasonalBot(commands.Bot): return False else: - log.info(f"Asset successfully applied") + log.info("Asset successfully applied") return True @mock_in_debug(return_value=True) @@ -203,7 +203,9 @@ class SeasonalBot(commands.Bot): await self._guild_available.wait() +_allowed_roles = [discord.Object(id_) for id_ in MODERATION_ROLES] bot = SeasonalBot( command_prefix=Client.prefix, activity=discord.Game(name=f"Commands: {Client.prefix}help"), + allowed_mentions=discord.AllowedMentions(everyone=False, roles=_allowed_roles), ) -- cgit v1.2.3 From a1c1a9442730c20364d3765f3d4de64c4fd8ce36 Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Tue, 14 Jul 2020 12:15:01 -0700 Subject: Remove redundant f-strings This fixes a new lint error (F541) introduced by flake8 3.8. --- bot/exts/christmas/adventofcode.py | 2 +- bot/exts/evergreen/snakes/snakes_cog.py | 4 ++-- bot/exts/halloween/candy_collection.py | 6 +++--- bot/utils/decorators.py | 2 +- bot/utils/pagination.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'bot') diff --git a/bot/exts/christmas/adventofcode.py b/bot/exts/christmas/adventofcode.py index 00607074..b3fe0623 100644 --- a/bot/exts/christmas/adventofcode.py +++ b/bot/exts/christmas/adventofcode.py @@ -58,7 +58,7 @@ async def countdown_status(bot: commands.Bot) -> None: hours, minutes = aligned_seconds // 3600, aligned_seconds // 60 % 60 if aligned_seconds == 0: - playing = f"right now!" + playing = "right now!" elif aligned_seconds == COUNTDOWN_STEP: playing = f"in less than {minutes} minutes" elif hours == 0: diff --git a/bot/exts/evergreen/snakes/snakes_cog.py b/bot/exts/evergreen/snakes/snakes_cog.py index b3896fcd..9bbad9fe 100644 --- a/bot/exts/evergreen/snakes/snakes_cog.py +++ b/bot/exts/evergreen/snakes/snakes_cog.py @@ -567,7 +567,7 @@ class Snakes(Cog): antidote_embed = Embed(color=SNAKE_COLOR, title="Antidote") antidote_embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url) antidote_embed.set_image(url="https://i.makeagif.com/media/7-12-2015/Cj1pts.gif") - antidote_embed.add_field(name=f"You have created the snake antidote!", + antidote_embed.add_field(name="You have created the snake antidote!", value=f"The solution was: {' '.join(antidote_answer)}\n" f"You had {10 - antidote_tries} tries remaining.") await board_id.edit(embed=antidote_embed) @@ -1078,7 +1078,7 @@ class Snakes(Cog): query = snake['name'] # Build the URL and make the request - url = f'https://www.googleapis.com/youtube/v3/search' + url = 'https://www.googleapis.com/youtube/v3/search' response = await self.bot.http_session.get( url, params={ diff --git a/bot/exts/halloween/candy_collection.py b/bot/exts/halloween/candy_collection.py index 2c7d2f23..caf0df11 100644 --- a/bot/exts/halloween/candy_collection.py +++ b/bot/exts/halloween/candy_collection.py @@ -212,9 +212,9 @@ class CandyCollection(commands.Cog): e = discord.Embed(colour=discord.Colour.blurple()) e.add_field(name="Top Candy Records", value=value, inline=False) e.add_field(name='\u200b', - value=f"Candies will randomly appear on messages sent. " - f"\nHit the candy when it appears as fast as possible to get the candy! " - f"\nBut beware the ghosts...", + value="Candies will randomly appear on messages sent. " + "\nHit the candy when it appears as fast as possible to get the candy! " + "\nBut beware the ghosts...", inline=False) await ctx.send(embed=e) diff --git a/bot/utils/decorators.py b/bot/utils/decorators.py index 519e61a9..9e6ef73d 100644 --- a/bot/utils/decorators.py +++ b/bot/utils/decorators.py @@ -285,7 +285,7 @@ def locked() -> t.Union[t.Callable, None]: embed = Embed() embed.colour = Colour.red() - log.debug(f"User tried to invoke a locked command.") + log.debug("User tried to invoke a locked command.") embed.description = ( "You're already using this command. Please wait until " "it is done before you use it again." diff --git a/bot/utils/pagination.py b/bot/utils/pagination.py index 9a7a0382..a4d0cc56 100644 --- a/bot/utils/pagination.py +++ b/bot/utils/pagination.py @@ -128,7 +128,7 @@ class LinePaginator(Paginator): if not lines: if exception_on_empty_embed: - log.exception(f"Pagination asked for empty lines iterable") + log.exception("Pagination asked for empty lines iterable") raise EmptyPaginatorEmbed("No lines to paginate") log.debug("No lines to add to paginator, adding '(nothing to display)' message") @@ -335,7 +335,7 @@ class ImagePaginator(Paginator): if not pages: if exception_on_empty_embed: - log.exception(f"Pagination asked for empty image list") + log.exception("Pagination asked for empty image list") raise EmptyPaginatorEmbed("No images to paginate") log.debug("No images to add to paginator, adding '(no images to display)' message") -- cgit v1.2.3 From 6f51cf18febdfdf8d8949e3a3a91d707ed2d9dc2 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sun, 9 Aug 2020 14:06:35 -0700 Subject: Edited "topic" command for fetching python channel topics. --- bot/exts/easter/conversationstarters.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/conversationstarters.py b/bot/exts/easter/conversationstarters.py index a5f40445..0c773119 100644 --- a/bot/exts/easter/conversationstarters.py +++ b/bot/exts/easter/conversationstarters.py @@ -2,6 +2,7 @@ import json import logging import random from pathlib import Path +from discord import Embed from discord.ext import commands @@ -10,6 +11,10 @@ log = logging.getLogger(__name__) with open(Path("bot/resources/easter/starter.json"), "r", encoding="utf8") as f: starters = json.load(f) +with open(Path("bot/resources/easter/py_topics.json"), "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) + class ConvoStarters(commands.Cog): """Easter conversation topics.""" @@ -19,7 +24,25 @@ class ConvoStarters(commands.Cog): @commands.command() 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, changing depending on channel.""" + + # Fetching topics. + channel_topics = py_topic[str(ctx.channel.id)] + + if channel_topics: + return await ctx.send(random.choice(channel_topics['python-channels'])) + + else: + # If the channel ID doesn't have any topics. + embed = Embed( + description=( + "No topics found. You can suggest new ideas for topics " + "[here](https://github.com/python-discord/seasonalbot/issues/426)!" + )) + + return await ctx.send(embed=embed) + + # If the channel isn't Python. await ctx.send(random.choice(starters['starters'])) -- cgit v1.2.3 From 4d6e9f2b692939eccd8fed414f063f6bd3de858f Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sun, 9 Aug 2020 14:07:08 -0700 Subject: Added base file for python topics. With a couple suggestions for #python-general --- bot/resources/easter/py_topics.json | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 bot/resources/easter/py_topics.json (limited to 'bot') diff --git a/bot/resources/easter/py_topics.json b/bot/resources/easter/py_topics.json new file mode 100644 index 00000000..d1035b7a --- /dev/null +++ b/bot/resources/easter/py_topics.json @@ -0,0 +1,58 @@ +{ + "python-channels": { + "267624335836053506": [ + "What's your favorite PEP?", + "What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python?", + "What functionality is your text editor/IDE missing for programming Python?", + "What parts of your life has Python automated, if any?" + ], + "630504881542791169": [ + + ], + "650401909852864553": [ + + ], + "342318764227821568": [ + + ], + "366673247892275221": [ + + ], + "343944376055103488": [ + + ], + "470884583684964352": [ + + ], + "660625198390837248": [ + + ], + "545603026732318730": [ + + ], + "716325106619777044": [ + + ], + "728390945384431688": [ + + ], + "366674035876167691": [ + + ], + "463035728335732738": [ + + ], + "463035462760792066": [ + + ], + "491523972836360192": [ + + ], + "338993628049571840": [ + + ], + "366673702533988363": [ + + ] + } +} -- cgit v1.2.3 From 66061654ac708d6290c225808e6b9813051d5163 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sun, 9 Aug 2020 15:46:03 -0700 Subject: Finalized topic selection. --- bot/exts/easter/conversationstarters.py | 45 +++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/conversationstarters.py b/bot/exts/easter/conversationstarters.py index 0c773119..212e65b7 100644 --- a/bot/exts/easter/conversationstarters.py +++ b/bot/exts/easter/conversationstarters.py @@ -2,18 +2,23 @@ import json import logging import random from pathlib import Path -from discord import Embed +from discord import Embed from discord.ext import commands +from bot.utils.decorators import override_in_channel + + log = logging.getLogger(__name__) + with open(Path("bot/resources/easter/starter.json"), "r", encoding="utf8") as f: starters = json.load(f) with open(Path("bot/resources/easter/py_topics.json"), "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) + py_topics = json.load(f)["python-channels"] + all_python_channels = [int(channel_id) for channel_id in py_topics.keys()] class ConvoStarters(commands.Cog): @@ -23,27 +28,29 @@ class ConvoStarters(commands.Cog): 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.""" + """Responds with a random topic to start a conversation, changing depending on channel.""" + try: + # Fetching topics. + channel_topics = py_topics[str(ctx.channel.id)] - # Fetching topics. - channel_topics = py_topic[str(ctx.channel.id)] - - if channel_topics: - return await ctx.send(random.choice(channel_topics['python-channels'])) + if channel_topics: + return await ctx.send(random.choice(channel_topics)) - else: # If the channel ID doesn't have any topics. - embed = Embed( - description=( - "No topics found. You can suggest new ideas for topics " - "[here](https://github.com/python-discord/seasonalbot/issues/426)!" - )) - - return await ctx.send(embed=embed) - - # If the channel isn't Python. - await ctx.send(random.choice(starters['starters'])) + 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)!" + )) + + return await ctx.send(embed=embed) + + except KeyError: + # If the channel isn't Python. + await ctx.send(random.choice(starters['starters'])) def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 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/easter/conversationstarters.py | 58 ------------------------------ bot/exts/evergreen/conversationstarters.py | 57 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 58 deletions(-) delete mode 100644 bot/exts/easter/conversationstarters.py create mode 100644 bot/exts/evergreen/conversationstarters.py (limited to 'bot') diff --git a/bot/exts/easter/conversationstarters.py b/bot/exts/easter/conversationstarters.py deleted file mode 100644 index 212e65b7..00000000 --- a/bot/exts/easter/conversationstarters.py +++ /dev/null @@ -1,58 +0,0 @@ -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 - - -log = logging.getLogger(__name__) - - -with open(Path("bot/resources/easter/starter.json"), "r", encoding="utf8") as f: - starters = json.load(f) - -with open(Path("bot/resources/easter/py_topics.json"), "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 channel_topics: - return await ctx.send(random.choice(channel_topics)) - - # If the channel ID doesn't have any 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)!" - )) - - return await ctx.send(embed=embed) - - except KeyError: - # If the channel isn't Python. - await ctx.send(random.choice(starters['starters'])) - - -def setup(bot: commands.Bot) -> None: - """Conversation starters Cog load.""" - bot.add_cog(ConvoStarters(bot)) 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') 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 41f3d6fdbc2fc23f2d00a04392a00fc4736d801b Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 10 Aug 2020 13:48:46 -0700 Subject: Moved the resources to the correct folder for evergreen. --- bot/resources/easter/py_topics.json | 58 ---------------------------------- bot/resources/easter/starter.json | 24 -------------- bot/resources/evergreen/py_topics.json | 58 ++++++++++++++++++++++++++++++++++ bot/resources/evergreen/starter.json | 24 ++++++++++++++ 4 files changed, 82 insertions(+), 82 deletions(-) delete mode 100644 bot/resources/easter/py_topics.json delete mode 100644 bot/resources/easter/starter.json create mode 100644 bot/resources/evergreen/py_topics.json create mode 100644 bot/resources/evergreen/starter.json (limited to 'bot') diff --git a/bot/resources/easter/py_topics.json b/bot/resources/easter/py_topics.json deleted file mode 100644 index d1035b7a..00000000 --- a/bot/resources/easter/py_topics.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "python-channels": { - "267624335836053506": [ - "What's your favorite PEP?", - "What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python?", - "What functionality is your text editor/IDE missing for programming Python?", - "What parts of your life has Python automated, if any?" - ], - "630504881542791169": [ - - ], - "650401909852864553": [ - - ], - "342318764227821568": [ - - ], - "366673247892275221": [ - - ], - "343944376055103488": [ - - ], - "470884583684964352": [ - - ], - "660625198390837248": [ - - ], - "545603026732318730": [ - - ], - "716325106619777044": [ - - ], - "728390945384431688": [ - - ], - "366674035876167691": [ - - ], - "463035728335732738": [ - - ], - "463035462760792066": [ - - ], - "491523972836360192": [ - - ], - "338993628049571840": [ - - ], - "366673702533988363": [ - - ] - } -} diff --git a/bot/resources/easter/starter.json b/bot/resources/easter/starter.json deleted file mode 100644 index 31e2cbc9..00000000 --- a/bot/resources/easter/starter.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "starters": [ - "What is your favourite Easter candy or treat?", - "What is your earliest memory of Easter?", - "What is the title of the last book you read?", - "What is better: Milk, Dark or White chocolate?", - "What is your favourite holiday?", - "If you could have any superpower, what would it be?", - "Name one thing you like about a person to your right.", - "If you could be anyone else for one day, who would it be?", - "What Easter tradition do you enjoy most?", - "What is the best gift you've been given?", - "Name one famous person you would like to have at your easter dinner.", - "What was the last movie you saw in a cinema?", - "What is your favourite food?", - "If you could travel anywhere in the world, where would you go?", - "Tell us 5 things you do well.", - "What is your favourite place that you have visited?", - "What is your favourite color?", - "If you had $100 bill in your Easter Basket, what would you do with it?", - "What would you do if you know you could succeed at anything you chose to do?", - "If you could take only three things from your house, what would they be?" - ] -} diff --git a/bot/resources/evergreen/py_topics.json b/bot/resources/evergreen/py_topics.json new file mode 100644 index 00000000..d1035b7a --- /dev/null +++ b/bot/resources/evergreen/py_topics.json @@ -0,0 +1,58 @@ +{ + "python-channels": { + "267624335836053506": [ + "What's your favorite PEP?", + "What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python?", + "What functionality is your text editor/IDE missing for programming Python?", + "What parts of your life has Python automated, if any?" + ], + "630504881542791169": [ + + ], + "650401909852864553": [ + + ], + "342318764227821568": [ + + ], + "366673247892275221": [ + + ], + "343944376055103488": [ + + ], + "470884583684964352": [ + + ], + "660625198390837248": [ + + ], + "545603026732318730": [ + + ], + "716325106619777044": [ + + ], + "728390945384431688": [ + + ], + "366674035876167691": [ + + ], + "463035728335732738": [ + + ], + "463035462760792066": [ + + ], + "491523972836360192": [ + + ], + "338993628049571840": [ + + ], + "366673702533988363": [ + + ] + } +} diff --git a/bot/resources/evergreen/starter.json b/bot/resources/evergreen/starter.json new file mode 100644 index 00000000..31e2cbc9 --- /dev/null +++ b/bot/resources/evergreen/starter.json @@ -0,0 +1,24 @@ +{ + "starters": [ + "What is your favourite Easter candy or treat?", + "What is your earliest memory of Easter?", + "What is the title of the last book you read?", + "What is better: Milk, Dark or White chocolate?", + "What is your favourite holiday?", + "If you could have any superpower, what would it be?", + "Name one thing you like about a person to your right.", + "If you could be anyone else for one day, who would it be?", + "What Easter tradition do you enjoy most?", + "What is the best gift you've been given?", + "Name one famous person you would like to have at your easter dinner.", + "What was the last movie you saw in a cinema?", + "What is your favourite food?", + "If you could travel anywhere in the world, where would you go?", + "Tell us 5 things you do well.", + "What is your favourite place that you have visited?", + "What is your favourite color?", + "If you had $100 bill in your Easter Basket, what would you do with it?", + "What would you do if you know you could succeed at anything you chose to do?", + "If you could take only three things from your house, what would they be?" + ] +} -- 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') 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') 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') 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') 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') 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 f489a87f7f1d66983b1e495427883837c57332fe Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 17 Aug 2020 03:16:10 -0700 Subject: Changed from json to yaml config so comments can be included. --- bot/resources/evergreen/py_topics.json | 58 --------------------------- bot/resources/evergreen/py_topics.yaml | 73 ++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 58 deletions(-) delete mode 100644 bot/resources/evergreen/py_topics.json create mode 100644 bot/resources/evergreen/py_topics.yaml (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.json b/bot/resources/evergreen/py_topics.json deleted file mode 100644 index d1035b7a..00000000 --- a/bot/resources/evergreen/py_topics.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "python-channels": { - "267624335836053506": [ - "What's your favorite PEP?", - "What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python?", - "What functionality is your text editor/IDE missing for programming Python?", - "What parts of your life has Python automated, if any?" - ], - "630504881542791169": [ - - ], - "650401909852864553": [ - - ], - "342318764227821568": [ - - ], - "366673247892275221": [ - - ], - "343944376055103488": [ - - ], - "470884583684964352": [ - - ], - "660625198390837248": [ - - ], - "545603026732318730": [ - - ], - "716325106619777044": [ - - ], - "728390945384431688": [ - - ], - "366674035876167691": [ - - ], - "463035728335732738": [ - - ], - "463035462760792066": [ - - ], - "491523972836360192": [ - - ], - "338993628049571840": [ - - ], - "366673702533988363": [ - - ] - } -} diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml new file mode 100644 index 00000000..f67ce4d6 --- /dev/null +++ b/bot/resources/evergreen/py_topics.yaml @@ -0,0 +1,73 @@ +# Conversation starters for python-related channels. + +# python-general +# 267624335836053506: +476190141161930755: + - What's your favorite PEP? + - What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python? + - What functionality is your text editor/IDE missing for programming Python? + - What parts of your life has Python automated, if any? + +# async +630504881542791169: + - + +# computer-science +650401909852864553: + - + +# databases +342318764227821568: + - + +# data-science +366673247892275221: + - + +# discord.py +343944376055103488: + - + +# esoteric-python +470884583684964352: + - + +# game-development +660625198390837248: + - + +# microcontrollers +545603026732318730: + - + +# networking +716325106619777044: + - + +# python-extensions +728390945384431688: + - + +# security +366674035876167691: + - + +# software-testing +463035728335732738: + - + +# tools-and-devops +463035462760792066: + - + +# unix +491523972836360192: + - + +# user-interfaces +338993628049571840: + - + +# web-development +366673702533988363: + - -- 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') 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 3f3f713da2f72b54e095bbc2d5a39198b45ee6f8 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 17 Aug 2020 03:16:10 -0700 Subject: Revert "Changed from json to yaml config so comments can be included." This reverts commit f489a87f7f1d66983b1e495427883837c57332fe. --- bot/resources/evergreen/py_topics.json | 58 +++++++++++++++++++++++++++ bot/resources/evergreen/py_topics.yaml | 73 ---------------------------------- 2 files changed, 58 insertions(+), 73 deletions(-) create mode 100644 bot/resources/evergreen/py_topics.json delete mode 100644 bot/resources/evergreen/py_topics.yaml (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.json b/bot/resources/evergreen/py_topics.json new file mode 100644 index 00000000..d1035b7a --- /dev/null +++ b/bot/resources/evergreen/py_topics.json @@ -0,0 +1,58 @@ +{ + "python-channels": { + "267624335836053506": [ + "What's your favorite PEP?", + "What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python?", + "What functionality is your text editor/IDE missing for programming Python?", + "What parts of your life has Python automated, if any?" + ], + "630504881542791169": [ + + ], + "650401909852864553": [ + + ], + "342318764227821568": [ + + ], + "366673247892275221": [ + + ], + "343944376055103488": [ + + ], + "470884583684964352": [ + + ], + "660625198390837248": [ + + ], + "545603026732318730": [ + + ], + "716325106619777044": [ + + ], + "728390945384431688": [ + + ], + "366674035876167691": [ + + ], + "463035728335732738": [ + + ], + "463035462760792066": [ + + ], + "491523972836360192": [ + + ], + "338993628049571840": [ + + ], + "366673702533988363": [ + + ] + } +} diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml deleted file mode 100644 index f67ce4d6..00000000 --- a/bot/resources/evergreen/py_topics.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Conversation starters for python-related channels. - -# python-general -# 267624335836053506: -476190141161930755: - - What's your favorite PEP? - - What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python? - - What functionality is your text editor/IDE missing for programming Python? - - What parts of your life has Python automated, if any? - -# async -630504881542791169: - - - -# computer-science -650401909852864553: - - - -# databases -342318764227821568: - - - -# data-science -366673247892275221: - - - -# discord.py -343944376055103488: - - - -# esoteric-python -470884583684964352: - - - -# game-development -660625198390837248: - - - -# microcontrollers -545603026732318730: - - - -# networking -716325106619777044: - - - -# python-extensions -728390945384431688: - - - -# security -366674035876167691: - - - -# software-testing -463035728335732738: - - - -# tools-and-devops -463035462760792066: - - - -# unix -491523972836360192: - - - -# user-interfaces -338993628049571840: - - - -# web-development -366673702533988363: - - -- cgit v1.2.3 From 9c994c23f946f13202eb791d42cc22fdaa60912c Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 17 Aug 2020 03:21:55 -0700 Subject: Auto stash before revert of "Changed from json to yaml config so comments can be included." --- bot/resources/evergreen/py_topics.yaml | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 bot/resources/evergreen/py_topics.yaml (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml new file mode 100644 index 00000000..49cf38b5 --- /dev/null +++ b/bot/resources/evergreen/py_topics.yaml @@ -0,0 +1,72 @@ +# Conversation starters for python-related channels. + +# python-general +267624335836053506: + - What's your favorite PEP? + - What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python? + - What functionality is your text editor/IDE missing for programming Python? + - What parts of your life has Python automated, if any? + +# async +630504881542791169: + - + +# computer-science +650401909852864553: + - + +# databases +342318764227821568: + - + +# data-science +366673247892275221: + - + +# discord.py +343944376055103488: + - + +# esoteric-python +470884583684964352: + - + +# game-development +660625198390837248: + - + +# microcontrollers +545603026732318730: + - + +# networking +716325106619777044: + - + +# python-extensions +728390945384431688: + - + +# security +366674035876167691: + - + +# software-testing +463035728335732738: + - + +# tools-and-devops +463035462760792066: + - + +# unix +491523972836360192: + - + +# user-interfaces +338993628049571840: + - + +# web-development +366673702533988363: + - -- 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') 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 2cde858674fa6b4828f1a91028a62fb986c874f0 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 20 Aug 2020 22:38:34 +0100 Subject: Temporarily remove message functionality from Fun Remove message link functionality from uwu and randomcase due to a security vulnerability --- bot/exts/evergreen/fun.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/fun.py b/bot/exts/evergreen/fun.py index 67a4bae5..b2c0aad9 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/evergreen/fun.py @@ -49,8 +49,6 @@ class Fun(Cog): async def uwu_command(self, ctx: Context, *, text: str) -> None: """ Converts a given `text` into it's uwu equivalent. - - Also accepts a valid discord Message ID or link. """ conversion_func = functools.partial( utils.replace_many, replacements=UWU_WORDS, ignore_case=True, match_case=True @@ -69,8 +67,6 @@ class Fun(Cog): async def randomcase_command(self, ctx: Context, *, text: str) -> None: """ Randomly converts the casing of a given `text`. - - Also accepts a valid discord Message ID or link. """ def conversion_func(text: str) -> str: """Randomly converts the casing of a given string.""" @@ -97,12 +93,14 @@ class Fun(Cog): Union[Embed, None]: The embed if found in the valid Message, else None """ embed = None - message = await Fun._get_discord_message(ctx, text) - if isinstance(message, Message): - text = message.content - # Take first embed because we can't send multiple embeds - if message.embeds: - embed = message.embeds[0] + + # message = await Fun._get_discord_message(ctx, text) + # if isinstance(message, Message): + # text = message.content + # # Take first embed because we can't send multiple embeds + # if message.embeds: + # embed = message.embeds[0] + return (text, embed) @staticmethod -- cgit v1.2.3 From 09553df414dc225d2857c100a8cf02eaeeca4d47 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 20 Aug 2020 22:45:56 +0100 Subject: Update fun.py to satisfy the linter --- bot/exts/evergreen/fun.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/fun.py b/bot/exts/evergreen/fun.py index b2c0aad9..0a5d22f9 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/evergreen/fun.py @@ -47,9 +47,7 @@ class Fun(Cog): @commands.command(name="uwu", aliases=("uwuwize", "uwuify",)) async def uwu_command(self, ctx: Context, *, text: str) -> None: - """ - Converts a given `text` into it's uwu equivalent. - """ + """Converts a given `text` into it's uwu equivalent.""" conversion_func = functools.partial( utils.replace_many, replacements=UWU_WORDS, ignore_case=True, match_case=True ) @@ -65,9 +63,7 @@ class Fun(Cog): @commands.command(name="randomcase", aliases=("rcase", "randomcaps", "rcaps",)) async def randomcase_command(self, ctx: Context, *, text: str) -> None: - """ - Randomly converts the casing of a given `text`. - """ + """Randomly converts the casing of a given `text`.""" def conversion_func(text: str) -> str: """Randomly converts the casing of a given string.""" return "".join( -- cgit v1.2.3 From e0caf6787d862ba605a734fdf9b9363cdf100b85 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 20 Aug 2020 22:49:36 +0100 Subject: Remove whitespace from fun.py --- bot/exts/evergreen/fun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/evergreen/fun.py b/bot/exts/evergreen/fun.py index 0a5d22f9..36a13ac0 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/evergreen/fun.py @@ -89,7 +89,7 @@ class Fun(Cog): Union[Embed, None]: The embed if found in the valid Message, else None """ embed = None - + # message = await Fun._get_discord_message(ctx, text) # if isinstance(message, Message): # text = message.content -- cgit v1.2.3 From cb2eca7c5d4120006712fe2d7cf35988c6f8e024 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Fri, 21 Aug 2020 18:33:44 -0700 Subject: Added topics to py_topics.yaml, removed the json form of this file. --- bot/resources/evergreen/py_topics.json | 58 ---------------------------------- bot/resources/evergreen/py_topics.yaml | 21 +++++++++--- 2 files changed, 16 insertions(+), 63 deletions(-) delete mode 100644 bot/resources/evergreen/py_topics.json (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.json b/bot/resources/evergreen/py_topics.json deleted file mode 100644 index d1035b7a..00000000 --- a/bot/resources/evergreen/py_topics.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "python-channels": { - "267624335836053506": [ - "What's your favorite PEP?", - "What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python?", - "What functionality is your text editor/IDE missing for programming Python?", - "What parts of your life has Python automated, if any?" - ], - "630504881542791169": [ - - ], - "650401909852864553": [ - - ], - "342318764227821568": [ - - ], - "366673247892275221": [ - - ], - "343944376055103488": [ - - ], - "470884583684964352": [ - - ], - "660625198390837248": [ - - ], - "545603026732318730": [ - - ], - "716325106619777044": [ - - ], - "728390945384431688": [ - - ], - "366674035876167691": [ - - ], - "463035728335732738": [ - - ], - "463035462760792066": [ - - ], - "491523972836360192": [ - - ], - "338993628049571840": [ - - ], - "366673702533988363": [ - - ] - } -} diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml index 49cf38b5..5a2e8d89 100644 --- a/bot/resources/evergreen/py_topics.yaml +++ b/bot/resources/evergreen/py_topics.yaml @@ -6,10 +6,16 @@ - What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python? - What functionality is your text editor/IDE missing for programming Python? - What parts of your life has Python automated, if any? + - Which python project are you the most proud of making? + - What made you want to learn Python? + - When did you start learning Python? + - What reasons are you learning Python for? + - Where's the strangest place you've seen Python? + - How has learning Python changed your life? # async 630504881542791169: - - + - Are there any frameworks you wish were async? # computer-science 650401909852864553: @@ -17,7 +23,7 @@ # databases 342318764227821568: - - + - Where do you get your best data? # data-science 366673247892275221: @@ -25,11 +31,15 @@ # discord.py 343944376055103488: - - + - What unique features does your bot contain, if any? + - What commands/features are you proud of making? + - What feature would you be the most interested in making? + - What feature would you like to see added to the library? what feature in the library do you think is redundant? + - Do you think there's a way in which Discord could handle bots better? # esoteric-python 470884583684964352: - - + - What's a common part of programming we can make harder? # game-development 660625198390837248: @@ -57,7 +67,8 @@ # tools-and-devops 463035462760792066: - - + - What editor would you recommend to a beginner? Why? + - What editor would you recommend to be the most efficient? Why? # unix 491523972836360192: -- cgit v1.2.3 From c25dbfc87e7822bf14cf9b34eb7602dc511d6a68 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sun, 23 Aug 2020 06:20:30 -0700 Subject: Added one more topic to #async. --- bot/resources/evergreen/py_topics.yaml | 1 + 1 file changed, 1 insertion(+) (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml index 5a2e8d89..ae5289a7 100644 --- a/bot/resources/evergreen/py_topics.yaml +++ b/bot/resources/evergreen/py_topics.yaml @@ -16,6 +16,7 @@ # async 630504881542791169: - Are there any frameworks you wish were async? + - How have coroutines changed the way you write Python? # computer-science 650401909852864553: -- cgit v1.2.3 From d6f91f87cccfa558e948f8c8bd7aa3870e056bd2 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sat, 29 Aug 2020 00:48:51 -0700 Subject: Updated constants to include Wolfram configuration. --- bot/constants.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index bf6c5a40..4a97b9e0 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -17,6 +17,7 @@ __all__ = ( "Month", "Roles", "Tokens", + "Wolfram", "MODERATION_ROLES", "STAFF_ROLES", "WHITELISTED_CHANNELS", @@ -96,6 +97,7 @@ class Colours: soft_red = 0xcd6d6d yellow = 0xf9f586 purple = 0xb734eb + soft_orange = 0xf9cb54 class Emojis: @@ -187,6 +189,12 @@ class Tokens(NamedTuple): github = environ.get("GITHUB_TOKEN") +class Wolfram(NamedTuple): + user_limit_day = environ.get("WOLFRAM_USER_LIMIT_DAY", 10) + guild_limit_day = environ.get("WOLFRAM_GUILD_LIMIT_DAY", 67) + key = environ.get("WOLFRAM_API_KEY", None) + + # Default role combinations MODERATION_ROLES = Roles.moderator, Roles.admin, Roles.owner STAFF_ROLES = Roles.helpers, Roles.moderator, Roles.admin, Roles.owner -- cgit v1.2.3 From c373d4c8cfd1105ea590553a02c208511fc16bb8 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sat, 29 Aug 2020 00:51:00 -0700 Subject: Migrated Wolfram cog from the Python bot in Python-Discord/bot. --- bot/exts/evergreen/wolfram.py | 280 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 bot/exts/evergreen/wolfram.py (limited to 'bot') diff --git a/bot/exts/evergreen/wolfram.py b/bot/exts/evergreen/wolfram.py new file mode 100644 index 00000000..18ccc4e5 --- /dev/null +++ b/bot/exts/evergreen/wolfram.py @@ -0,0 +1,280 @@ +import logging +from io import BytesIO +from typing import Callable, List, Optional, Tuple +from urllib import parse + +import discord +from dateutil.relativedelta import relativedelta +from discord import Embed +from discord.ext import commands +from discord.ext.commands import BucketType, Cog, Context, check, group + +from bot.constants import Colours, STAFF_ROLES, Wolfram +from bot.utils.pagination import ImagePaginator +from bot.utils.time import humanize_delta + +log = logging.getLogger(__name__) + +APPID = Wolfram.key +DEFAULT_OUTPUT_FORMAT = "JSON" +QUERY = "http://api.wolframalpha.com/v2/{request}?{data}" +WOLF_IMAGE = "https://www.symbols.com/gi.php?type=1&id=2886&i=1" + +MAX_PODS = 20 + +# Allows for 10 wolfram calls pr user pr day +usercd = commands.CooldownMapping.from_cooldown(Wolfram.user_limit_day, 60 * 60 * 24, BucketType.user) + +# Allows for max api requests / days in month per day for the entire guild (Temporary) +guildcd = commands.CooldownMapping.from_cooldown(Wolfram.guild_limit_day, 60 * 60 * 24, BucketType.guild) + + +async def send_embed( + ctx: Context, + message_txt: str, + colour: int = Colours.soft_red, + footer: str = None, + img_url: str = None, + f: discord.File = None +) -> None: + """Generate & send a response embed with Wolfram as the author.""" + embed = Embed(colour=colour) + embed.description = message_txt + embed.set_author(name="Wolfram Alpha", + icon_url=WOLF_IMAGE, + url="https://www.wolframalpha.com/") + if footer: + embed.set_footer(text=footer) + + if img_url: + embed.set_image(url=img_url) + + await ctx.send(embed=embed, file=f) + + +def custom_cooldown(*ignore: List[int]) -> Callable: + """ + Implement per-user and per-guild cooldowns for requests to the Wolfram API. + + A list of roles may be provided to ignore the per-user cooldown + """ + async def predicate(ctx: Context) -> bool: + if ctx.invoked_with == 'help': + # if the invoked command is help we don't want to increase the ratelimits since it's not actually + # invoking the command/making a request, so instead just check if the user/guild are on cooldown. + guild_cooldown = not guildcd.get_bucket(ctx.message).get_tokens() == 0 # if guild is on cooldown + if not any(r.id in ignore for r in ctx.author.roles): # check user bucket if user is not ignored + return guild_cooldown and not usercd.get_bucket(ctx.message).get_tokens() == 0 + return guild_cooldown + + user_bucket = usercd.get_bucket(ctx.message) + + if all(role.id not in ignore for role in ctx.author.roles): + user_rate = user_bucket.update_rate_limit() + + if user_rate: + # Can't use api; cause: member limit + delta = relativedelta(seconds=int(user_rate)) + cooldown = humanize_delta(delta) + message = ( + "You've used up your limit for Wolfram|Alpha requests.\n" + f"Cooldown: {cooldown}" + ) + await send_embed(ctx, message) + return False + + guild_bucket = guildcd.get_bucket(ctx.message) + guild_rate = guild_bucket.update_rate_limit() + + # Repr has a token attribute to read requests left + log.debug(guild_bucket) + + if guild_rate: + # Can't use api; cause: guild limit + message = ( + "The max limit of requests for the server has been reached for today.\n" + f"Cooldown: {int(guild_rate)}" + ) + await send_embed(ctx, message) + return False + + return True + + return check(predicate) + + +async def get_pod_pages(ctx: Context, bot: commands.Bot, query: str) -> Optional[List[Tuple]]: + """Get the Wolfram API pod pages for the provided query.""" + async with ctx.channel.typing(): + url_str = parse.urlencode({ + "input": query, + "appid": APPID, + "output": DEFAULT_OUTPUT_FORMAT, + "format": "image,plaintext" + }) + request_url = QUERY.format(request="query", data=url_str) + + async with bot.http_session.get(request_url) as response: + json = await response.json(content_type='text/plain') + + result = json["queryresult"] + + if result["error"]: + # API key not set up correctly + if result["error"]["msg"] == "Invalid appid": + message = "Wolfram API key is invalid or missing." + log.warning( + "API key seems to be missing, or invalid when " + f"processing a wolfram request: {url_str}, Response: {json}" + ) + await send_embed(ctx, message) + return + + message = "Something went wrong internally with your request, please notify staff!" + log.warning(f"Something went wrong getting a response from wolfram: {url_str}, Response: {json}") + await send_embed(ctx, message) + return + + if not result["success"]: + message = f"I couldn't find anything for {query}." + await send_embed(ctx, message) + return + + if not result["numpods"]: + message = "Could not find any results." + await send_embed(ctx, message) + return + + pods = result["pods"] + pages = [] + for pod in pods[:MAX_PODS]: + subs = pod.get("subpods") + + for sub in subs: + title = sub.get("title") or sub.get("plaintext") or sub.get("id", "") + img = sub["img"]["src"] + pages.append((title, img)) + return pages + + +class Wolfram(Cog): + """Commands for interacting with the Wolfram|Alpha API.""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + + @group(name="wolfram", aliases=("wolf", "wa"), invoke_without_command=True) + @custom_cooldown(*STAFF_ROLES) + async def wolfram_command(self, ctx: Context, *, query: str) -> None: + """Requests all answers on a single image, sends an image of all related pods.""" + url_str = parse.urlencode({ + "i": query, + "appid": APPID, + }) + query = QUERY.format(request="simple", data=url_str) + + # Give feedback that the bot is working. + async with ctx.channel.typing(): + async with self.bot.http_session.get(query) as response: + status = response.status + image_bytes = await response.read() + + f = discord.File(BytesIO(image_bytes), filename="image.png") + image_url = "attachment://image.png" + + if status == 501: + message = "Failed to get response" + footer = "" + color = Colours.soft_red + elif status == 400: + message = "No input found" + footer = "" + color = Colours.soft_red + elif status == 403: + message = "Wolfram API key is invalid or missing." + footer = "" + color = Colours.soft_red + else: + message = "" + footer = "View original for a bigger picture." + color = Colours.soft_orange + + # Sends a "blank" embed if no request is received, unsure how to fix + await send_embed(ctx, message, color, footer=footer, img_url=image_url, f=f) + + @wolfram_command.command(name="page", aliases=("pa", "p")) + @custom_cooldown(*STAFF_ROLES) + async def wolfram_page_command(self, ctx: Context, *, query: str) -> None: + """ + Requests a drawn image of given query. + + Keywords worth noting are, "like curve", "curve", "graph", "pokemon", etc. + """ + pages = await get_pod_pages(ctx, self.bot, query) + + if not pages: + return + + embed = Embed() + embed.set_author(name="Wolfram Alpha", + icon_url=WOLF_IMAGE, + url="https://www.wolframalpha.com/") + embed.colour = Colours.soft_orange + + await ImagePaginator.paginate(pages, ctx, embed) + + @wolfram_command.command(name="cut", aliases=("c",)) + @custom_cooldown(*STAFF_ROLES) + async def wolfram_cut_command(self, ctx: Context, *, query: str) -> None: + """ + Requests a drawn image of given query. + + Keywords worth noting are, "like curve", "curve", "graph", "pokemon", etc. + """ + pages = await get_pod_pages(ctx, self.bot, query) + + if not pages: + return + + if len(pages) >= 2: + page = pages[1] + else: + page = pages[0] + + await send_embed(ctx, page[0], colour=Colours.soft_orange, img_url=page[1]) + + @wolfram_command.command(name="short", aliases=("sh", "s")) + @custom_cooldown(*STAFF_ROLES) + async def wolfram_short_command(self, ctx: Context, *, query: str) -> None: + """Requests an answer to a simple question.""" + url_str = parse.urlencode({ + "i": query, + "appid": APPID, + }) + query = QUERY.format(request="result", data=url_str) + + # Give feedback that the bot is working. + async with ctx.channel.typing(): + async with self.bot.http_session.get(query) as response: + status = response.status + response_text = await response.text() + + if status == 501: + message = "Failed to get response" + color = Colours.soft_red + elif status == 400: + message = "No input found" + color = Colours.soft_red + elif response_text == "Error 1: Invalid appid": + message = "Wolfram API key is invalid or missing." + color = Colours.soft_red + else: + message = response_text + color = Colours.soft_orange + + await send_embed(ctx, message, color) + + +def setup(bot: commands.Bot) -> None: + """Load the Wolfram cog.""" + bot.add_cog(Wolfram(bot)) -- cgit v1.2.3 From 38bebb3c3086de21553dc6eb838fb1fdb1e348be Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sat, 29 Aug 2020 00:51:48 -0700 Subject: Added necessary utility for Wolfram cog. --- bot/utils/time.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 bot/utils/time.py (limited to 'bot') diff --git a/bot/utils/time.py b/bot/utils/time.py new file mode 100644 index 00000000..f37a025c --- /dev/null +++ b/bot/utils/time.py @@ -0,0 +1,66 @@ +from dateutil.relativedelta import relativedelta + + +def _stringify_time_unit(value: int, unit: str) -> str: + """ + Returns a string to represent a value and time unit, ensuring that it uses the right plural form of the unit. + + >>> _stringify_time_unit(1, "seconds") + "1 second" + >>> _stringify_time_unit(24, "hours") + "24 hours" + >>> _stringify_time_unit(0, "minutes") + "less than a minute" + """ + if unit == "seconds" and value == 0: + return "0 seconds" + elif value == 1: + return f"{value} {unit[:-1]}" + elif value == 0: + return f"less than a {unit[:-1]}" + else: + return f"{value} {unit}" + + +def humanize_delta(delta: relativedelta, precision: str = "seconds", max_units: int = 6) -> str: + """ + Returns a human-readable version of the relativedelta. + + precision specifies the smallest unit of time to include (e.g. "seconds", "minutes"). + max_units specifies the maximum number of units of time to include (e.g. 1 may include days but not hours). + """ + if max_units <= 0: + raise ValueError("max_units must be positive") + + units = ( + ("years", delta.years), + ("months", delta.months), + ("days", delta.days), + ("hours", delta.hours), + ("minutes", delta.minutes), + ("seconds", delta.seconds), + ) + + # Add the time units that are >0, but stop at accuracy or max_units. + time_strings = [] + unit_count = 0 + for unit, value in units: + if value: + time_strings.append(_stringify_time_unit(value, unit)) + unit_count += 1 + + if unit == precision or unit_count >= max_units: + break + + # Add the 'and' between the last two units, if necessary + if len(time_strings) > 1: + time_strings[-1] = f"{time_strings[-2]} and {time_strings[-1]}" + del time_strings[-2] + + # If nothing has been found, just make the value 0 precision, e.g. `0 days`. + if not time_strings: + humanized = _stringify_time_unit(0, precision) + else: + humanized = ", ".join(time_strings) + + return humanized -- cgit v1.2.3 From a3941cb820803c9408a392c3207fd0483fcf6a0e Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Sat, 29 Aug 2020 15:56:41 -0700 Subject: Update bot/exts/evergreen/wolfram.py Co-authored-by: Dennis Pham --- bot/exts/evergreen/wolfram.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/wolfram.py b/bot/exts/evergreen/wolfram.py index 18ccc4e5..4e1d284b 100644 --- a/bot/exts/evergreen/wolfram.py +++ b/bot/exts/evergreen/wolfram.py @@ -74,8 +74,7 @@ def custom_cooldown(*ignore: List[int]) -> Callable: if user_rate: # Can't use api; cause: member limit - delta = relativedelta(seconds=int(user_rate)) - cooldown = humanize_delta(delta) + cooldown = arrow.utcnow().shift(seconds=int(user_rate)).humanize(only_distance=True) message = ( "You've used up your limit for Wolfram|Alpha requests.\n" f"Cooldown: {cooldown}" -- cgit v1.2.3 From d472389b564ed5e343d40750b092680fcdf1e9fc Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sat, 29 Aug 2020 16:35:45 -0700 Subject: Removed the time utility and replaced it with the arrow package. Alphabetized the "Colours" NamedTuple in the constants file. --- bot/constants.py | 10 +++---- bot/exts/evergreen/wolfram.py | 3 +- bot/utils/time.py | 66 ------------------------------------------- docker-compose.yml | 3 +- 4 files changed, 8 insertions(+), 74 deletions(-) delete mode 100644 bot/utils/time.py (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index 4a97b9e0..f841193a 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -67,7 +67,7 @@ class Channels(NamedTuple): off_topic_2 = 463035268514185226 python = 267624335836053506 reddit = 458224812528238616 - seasonalbot_commands = int(environ.get("CHANNEL_SEASONALBOT_COMMANDS", 607247579608121354)) + seasonalbot_commands = int(environ.get("CHANNEL_SEASONALBOT_COMMANDS", 704362727778418798)) seasonalbot_voice = int(environ.get("CHANNEL_SEASONALBOT_VOICE", 606259004230074378)) staff_lounge = 464905259261755392 verification = 352442727016693763 @@ -93,11 +93,11 @@ class Colours: dark_green = 0x1f8b4c orange = 0xe67e22 pink = 0xcf84e0 + purple = 0xb734eb soft_green = 0x68c290 + soft_orange = 0xf9cb54 soft_red = 0xcd6d6d yellow = 0xf9f586 - purple = 0xb734eb - soft_orange = 0xf9cb54 class Emojis: @@ -190,8 +190,8 @@ class Tokens(NamedTuple): class Wolfram(NamedTuple): - user_limit_day = environ.get("WOLFRAM_USER_LIMIT_DAY", 10) - guild_limit_day = environ.get("WOLFRAM_GUILD_LIMIT_DAY", 67) + user_limit_day = int(environ.get("WOLFRAM_USER_LIMIT_DAY", 10)) + guild_limit_day = int(environ.get("WOLFRAM_GUILD_LIMIT_DAY", 67)) key = environ.get("WOLFRAM_API_KEY", None) diff --git a/bot/exts/evergreen/wolfram.py b/bot/exts/evergreen/wolfram.py index 4e1d284b..898e8d2a 100644 --- a/bot/exts/evergreen/wolfram.py +++ b/bot/exts/evergreen/wolfram.py @@ -3,15 +3,14 @@ from io import BytesIO from typing import Callable, List, Optional, Tuple from urllib import parse +import arrow import discord -from dateutil.relativedelta import relativedelta from discord import Embed from discord.ext import commands from discord.ext.commands import BucketType, Cog, Context, check, group from bot.constants import Colours, STAFF_ROLES, Wolfram from bot.utils.pagination import ImagePaginator -from bot.utils.time import humanize_delta log = logging.getLogger(__name__) diff --git a/bot/utils/time.py b/bot/utils/time.py deleted file mode 100644 index f37a025c..00000000 --- a/bot/utils/time.py +++ /dev/null @@ -1,66 +0,0 @@ -from dateutil.relativedelta import relativedelta - - -def _stringify_time_unit(value: int, unit: str) -> str: - """ - Returns a string to represent a value and time unit, ensuring that it uses the right plural form of the unit. - - >>> _stringify_time_unit(1, "seconds") - "1 second" - >>> _stringify_time_unit(24, "hours") - "24 hours" - >>> _stringify_time_unit(0, "minutes") - "less than a minute" - """ - if unit == "seconds" and value == 0: - return "0 seconds" - elif value == 1: - return f"{value} {unit[:-1]}" - elif value == 0: - return f"less than a {unit[:-1]}" - else: - return f"{value} {unit}" - - -def humanize_delta(delta: relativedelta, precision: str = "seconds", max_units: int = 6) -> str: - """ - Returns a human-readable version of the relativedelta. - - precision specifies the smallest unit of time to include (e.g. "seconds", "minutes"). - max_units specifies the maximum number of units of time to include (e.g. 1 may include days but not hours). - """ - if max_units <= 0: - raise ValueError("max_units must be positive") - - units = ( - ("years", delta.years), - ("months", delta.months), - ("days", delta.days), - ("hours", delta.hours), - ("minutes", delta.minutes), - ("seconds", delta.seconds), - ) - - # Add the time units that are >0, but stop at accuracy or max_units. - time_strings = [] - unit_count = 0 - for unit, value in units: - if value: - time_strings.append(_stringify_time_unit(value, unit)) - unit_count += 1 - - if unit == precision or unit_count >= max_units: - break - - # Add the 'and' between the last two units, if necessary - if len(time_strings) > 1: - time_strings[-1] = f"{time_strings[-2]} and {time_strings[-1]}" - del time_strings[-2] - - # If nothing has been found, just make the value 0 precision, e.g. `0 days`. - if not time_strings: - humanized = _stringify_time_unit(0, precision) - else: - humanized = ", ".join(time_strings) - - return humanized diff --git a/docker-compose.yml b/docker-compose.yml index 6cf5e9bd..8e5a9d53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,12 +10,13 @@ services: restart: always environment: - - SEASONALBOT_TOKEN=yourtokenhere + - SEASONALBOT_TOKEN=NzQyMTI3NjUwMjM5NDE0MzUy.XzBmOw.F4UiLeZ1wH0yALV4_aov1Ol_kpg - SEASONALBOT_DEBUG=true # - SEASONALBOT_GUILD= # - SEASONALBOT_ADMIN_ROLE_ID= # - CHANNEL_ANNOUNCEMENTS= # - CHANNEL_DEVLOG= + - WOLFRAM_API_KEY=5WKXAG-W9X9TUG3J5 volumes: - /opt/pythondiscord/seasonalbot/log:/bot/bot/log -- cgit v1.2.3 From 54020cf937e4144e72fed16ba164c71f8fec83ce Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sat, 29 Aug 2020 16:46:26 -0700 Subject: Reverted the SeasonalBot commands channel. --- bot/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index f841193a..a436f17d 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -67,7 +67,7 @@ class Channels(NamedTuple): off_topic_2 = 463035268514185226 python = 267624335836053506 reddit = 458224812528238616 - seasonalbot_commands = int(environ.get("CHANNEL_SEASONALBOT_COMMANDS", 704362727778418798)) + seasonalbot_commands = int(environ.get("CHANNEL_SEASONALBOT_COMMANDS", 607247579608121354)) seasonalbot_voice = int(environ.get("CHANNEL_SEASONALBOT_VOICE", 606259004230074378)) staff_lounge = 464905259261755392 verification = 352442727016693763 -- cgit v1.2.3 From 2f1b550f1974fe5fb56e56042c3ebf51375dcf50 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Sat, 29 Aug 2020 16:58:11 -0700 Subject: Removed None from environ.get() in Wolfram NamedTuple to keep consistency throughout constants.py --- bot/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index a436f17d..295bb90b 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -192,7 +192,7 @@ class Tokens(NamedTuple): class Wolfram(NamedTuple): user_limit_day = int(environ.get("WOLFRAM_USER_LIMIT_DAY", 10)) guild_limit_day = int(environ.get("WOLFRAM_GUILD_LIMIT_DAY", 67)) - key = environ.get("WOLFRAM_API_KEY", None) + key = environ.get("WOLFRAM_API_KEY") # Default role combinations -- cgit v1.2.3 From 33ad42cef738241af7647011970d5157c8b8e4ec Mon Sep 17 00:00:00 2001 From: Xithrius Date: Wed, 9 Sep 2020 14:59:03 -0700 Subject: Changed from json formatting to yaml to get the ability for comments. --- bot/resources/evergreen/starter.json | 24 ------------------------ bot/resources/evergreen/starter.yaml | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 24 deletions(-) delete mode 100644 bot/resources/evergreen/starter.json create mode 100644 bot/resources/evergreen/starter.yaml (limited to 'bot') diff --git a/bot/resources/evergreen/starter.json b/bot/resources/evergreen/starter.json deleted file mode 100644 index 31e2cbc9..00000000 --- a/bot/resources/evergreen/starter.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "starters": [ - "What is your favourite Easter candy or treat?", - "What is your earliest memory of Easter?", - "What is the title of the last book you read?", - "What is better: Milk, Dark or White chocolate?", - "What is your favourite holiday?", - "If you could have any superpower, what would it be?", - "Name one thing you like about a person to your right.", - "If you could be anyone else for one day, who would it be?", - "What Easter tradition do you enjoy most?", - "What is the best gift you've been given?", - "Name one famous person you would like to have at your easter dinner.", - "What was the last movie you saw in a cinema?", - "What is your favourite food?", - "If you could travel anywhere in the world, where would you go?", - "Tell us 5 things you do well.", - "What is your favourite place that you have visited?", - "What is your favourite color?", - "If you had $100 bill in your Easter Basket, what would you do with it?", - "What would you do if you know you could succeed at anything you chose to do?", - "If you could take only three things from your house, what would they be?" - ] -} diff --git a/bot/resources/evergreen/starter.yaml b/bot/resources/evergreen/starter.yaml new file mode 100644 index 00000000..53c89364 --- /dev/null +++ b/bot/resources/evergreen/starter.yaml @@ -0,0 +1,22 @@ +# Conversation starters for channels that are not Python-related. + +- What is your favourite Easter candy or treat? +- What is your earliest memory of Easter? +- What is the title of the last book you read? +- "What is better: Milk, Dark or White chocolate?" +- What is your favourite holiday? +- If you could have any superpower, what would it be? +- Name one thing you like about a person to your right. +- If you could be anyone else for one day, who would it be? +- What Easter tradition do you enjoy most? +- What is the best gift you've been given? +- Name one famous person you would like to have at your easter dinner. +- What was the last movie you saw in a cinema? +- What is your favourite food? +- If you could travel anywhere in the world, where would you go? +- Tell us 5 things you do well. +- What is your favourite place that you have visited? +- What is your favourite color? +- If you had $100 bill in your Easter Basket, what would you do with it? +- What would you do if you know you could succeed at anything you chose to do? +- If you could take only three things from your house, what would they be? -- cgit v1.2.3 From 415b8bfee1f4b4301e9ad3acbea147ecb3f6c6f0 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Wed, 9 Sep 2020 15:00:23 -0700 Subject: Added more topics. --- bot/resources/evergreen/py_topics.yaml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml index ae5289a7..971be3cd 100644 --- a/bot/resources/evergreen/py_topics.yaml +++ b/bot/resources/evergreen/py_topics.yaml @@ -1,17 +1,21 @@ -# Conversation starters for python-related channels. +# Conversation starters for Python-related channels. -# python-general +# Python-general 267624335836053506: - What's your favorite PEP? - What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python? - What functionality is your text editor/IDE missing for programming Python? - What parts of your life has Python automated, if any? - - Which python project are you the most proud of making? + - Which Python project are you the most proud of making? - What made you want to learn Python? - When did you start learning Python? - What reasons are you learning Python for? - Where's the strangest place you've seen Python? - How has learning Python changed your life? + - Is there a package you wish existed but doesn't? What is it? + - What feature do you think should be added to Python? + - Has Python helped you in school? If so, how? + - What was the first thing you created with Python? # async 630504881542791169: @@ -38,9 +42,10 @@ - What feature would you like to see added to the library? what feature in the library do you think is redundant? - Do you think there's a way in which Discord could handle bots better? -# esoteric-python +# esoteric-Python 470884583684964352: - What's a common part of programming we can make harder? + - What are the pros and cons of messing with __magic__()? # game-development 660625198390837248: @@ -52,15 +57,15 @@ # networking 716325106619777044: - - + - If you could wish for a library involving networking, what would it be? -# python-extensions +# Python-extensions 728390945384431688: - # security 366674035876167691: - - + - If you could wish for a library involving net-sec, what would it be? # software-testing 463035728335732738: @@ -77,8 +82,8 @@ # user-interfaces 338993628049571840: - - + - What's the most impressive Desktop Application you've made with Python so far? # web-development 366673702533988363: - - + - How has Python helped you in web development? -- 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') 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') 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') 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') 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 189d2e3714cb532f00921d11a9908b39ca1d7955 Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Thu, 10 Sep 2020 08:43:47 -0700 Subject: Update bot/utils/randomization.py Co-authored-by: Dennis Pham --- bot/utils/randomization.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/utils/randomization.py b/bot/utils/randomization.py index 063d7e1f..8f47679a 100644 --- a/bot/utils/randomization.py +++ b/bot/utils/randomization.py @@ -4,7 +4,11 @@ import typing as t class RandomCycle: - """Cycling through jumping to random indexes in an iterable.""" + """ + Cycles through elements from a randomly shuffled iterable, repeating indefinitely. + + The iterable is reshuffled after each full cycle. + """ def __init__(self, iterable: t.Iterable) -> None: self.iterable = list(iterable) -- 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') 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 f2062902047e46e3edf05707a6cd570c6d5ddbe4 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Thu, 10 Sep 2020 08:53:33 -0700 Subject: Renamed "esoteric-Python" to "esoteric-python" --- bot/resources/evergreen/py_topics.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml index 971be3cd..52582667 100644 --- a/bot/resources/evergreen/py_topics.yaml +++ b/bot/resources/evergreen/py_topics.yaml @@ -42,7 +42,7 @@ - What feature would you like to see added to the library? what feature in the library do you think is redundant? - Do you think there's a way in which Discord could handle bots better? -# esoteric-Python +# esoteric-python 470884583684964352: - What's a common part of programming we can make harder? - What are the pros and cons of messing with __magic__()? -- 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') 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 f2cd2214e59c4c38353a2591273e5407805f491c Mon Sep 17 00:00:00 2001 From: Xithrius Date: Thu, 10 Sep 2020 11:37:33 -0700 Subject: Made all channel names lowercase. --- bot/resources/evergreen/py_topics.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml index 52582667..278e6697 100644 --- a/bot/resources/evergreen/py_topics.yaml +++ b/bot/resources/evergreen/py_topics.yaml @@ -1,7 +1,7 @@ # Conversation starters for Python-related channels. -# Python-general -267624335836053506: +# python-general +704362672644423840: - What's your favorite PEP? - What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python? - What functionality is your text editor/IDE missing for programming Python? @@ -23,7 +23,7 @@ - How have coroutines changed the way you write Python? # computer-science -650401909852864553: +704406535509639209: - # databases @@ -59,7 +59,7 @@ 716325106619777044: - If you could wish for a library involving networking, what would it be? -# Python-extensions +# python-extensions 728390945384431688: - -- 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') 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 From ca105b297ea65fafdcf26135565c23147341e243 Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Thu, 10 Sep 2020 15:55:41 -0700 Subject: Updated the #python-general channel ID. Co-authored-by: Dennis Pham --- bot/resources/evergreen/py_topics.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml index 278e6697..aaa9ba48 100644 --- a/bot/resources/evergreen/py_topics.yaml +++ b/bot/resources/evergreen/py_topics.yaml @@ -1,7 +1,7 @@ # Conversation starters for Python-related channels. # python-general -704362672644423840: +267624335836053506: - What's your favorite PEP? - What's your current text editor/IDE, and what functionality do you like about it the most when programming in Python? - What functionality is your text editor/IDE missing for programming Python? -- cgit v1.2.3 From bf09b71197bbf8f424ac5c1a9be3f6f6d698f7a9 Mon Sep 17 00:00:00 2001 From: Xithrius <15021300+Xithrius@users.noreply.github.com> Date: Thu, 10 Sep 2020 15:55:59 -0700 Subject: Updated the #computer-science channel ID. Co-authored-by: Dennis Pham --- bot/resources/evergreen/py_topics.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml index aaa9ba48..7c3df5d3 100644 --- a/bot/resources/evergreen/py_topics.yaml +++ b/bot/resources/evergreen/py_topics.yaml @@ -23,7 +23,7 @@ - How have coroutines changed the way you write Python? # computer-science -704406535509639209: +650401909852864553: - # databases -- cgit v1.2.3 From 10ad8370b2c69828869c25b41fd8a722619fa0f1 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Thu, 10 Sep 2020 16:07:57 -0700 Subject: Renamed from python-extensions to c-extensions, reordered within list. --- bot/resources/evergreen/py_topics.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/resources/evergreen/py_topics.yaml b/bot/resources/evergreen/py_topics.yaml index 7c3df5d3..1e53429a 100644 --- a/bot/resources/evergreen/py_topics.yaml +++ b/bot/resources/evergreen/py_topics.yaml @@ -22,6 +22,10 @@ - Are there any frameworks you wish were async? - How have coroutines changed the way you write Python? +# c-extensions +728390945384431688: + - + # computer-science 650401909852864553: - @@ -59,10 +63,6 @@ 716325106619777044: - If you could wish for a library involving networking, what would it be? -# python-extensions -728390945384431688: - - - # security 366674035876167691: - If you could wish for a library involving net-sec, what would it be? -- cgit v1.2.3 From d4446fb7587f5948e3979f995d1364b4503948ee Mon Sep 17 00:00:00 2001 From: AtieP <62116490+AtieP@users.noreply.github.com> Date: Sun, 13 Sep 2020 19:34:12 +0200 Subject: Apply suggestions from code review Fix grammar errors Co-authored-by: Dennis Pham --- bot/resources/evergreen/trivia_quiz.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bot') diff --git a/bot/resources/evergreen/trivia_quiz.json b/bot/resources/evergreen/trivia_quiz.json index 067b8fb5..8f0a4114 100644 --- a/bot/resources/evergreen/trivia_quiz.json +++ b/bot/resources/evergreen/trivia_quiz.json @@ -222,25 +222,25 @@ "id": 131, "question": "In what country is the Ebro river located?", "answer": "Spain", - "info": "The Ebro river is a river located in Spain. It is 930 kilometers long and it's the second longest river that ends on the Mediterranean Sea." + "info": "The Ebro river is located in Spain. It is 930 kilometers long and it's the second longest river that ends on the Mediterranean Sea." }, { "id": 132, "question": "What year was the IBM PC model 5150 introduced into the market?", "answer": "1981", - "info": "The IBM PC was introduced in the market on 1981. It used the Intel 8088, with a clock speed of 4.77 MHz, along with the MDA and CGA as a video card." + "info": "The IBM PC was introduced into the market in 1981. It used the Intel 8088, with a clock speed of 4.77 MHz, along with the MDA and CGA as a video card." }, { "id": 133, "question": "What's the world's largest urban area?", "answer": "Tokyo", - "info": "Tokio is the most populated city in the world, with 37 million of people. It is located on Japan." + "info": "Tokyo is the most populated city in the world, with a population of 37 million people. It is located in Japan." }, { "id": 134, - "question": "How many planets there are on the Solar system?", + "question": "How many planets are there in the Solar system?", "answer": "8", - "info": "On the Solar system there are 8 planets: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus and Neptune. Pluto isn't considered a planet on the Solar System anymore." + "info": "In the Solar system, there are 8 planets: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus and Neptune. Pluto isn't considered a planet in the Solar System anymore." }, { "id": 135, -- cgit v1.2.3 From c8ba498d34fbbc9cd8ac49092d19fafe1f97cefa Mon Sep 17 00:00:00 2001 From: Gustav Odinger Date: Wed, 16 Sep 2020 23:50:10 +0200 Subject: Update .roll to use new dice emojis - Resolves #440 --- bot/constants.py | 12 ++++++------ bot/exts/evergreen/fun.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index 295bb90b..6605882d 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -108,12 +108,12 @@ class Emojis: trashcan = "<:trashcan:637136429717389331>" ok_hand = ":ok_hand:" - terning1 = "<:terning1:431249668983488527>" - terning2 = "<:terning2:462339216987127808>" - terning3 = "<:terning3:431249694467948544>" - terning4 = "<:terning4:579980271475228682>" - terning5 = "<:terning5:431249716328792064>" - terning6 = "<:terning6:431249726705369098>" + dice_1 = "<:dice_1:755891608859443290>" + dice_2 = "<:dice_2:755891608741740635>" + dice_3 = "<:dice_3:755891608251138158>" + dice_4 = "<:dice_4:755891607882039327>" + dice_5 = "<:dice_5:755891608091885627>" + dice_6 = "<:dice_6:755891607680843838>" issue = "<:IssueOpen:629695470327037963>" issue_closed = "<:IssueClosed:629695470570307614>" diff --git a/bot/exts/evergreen/fun.py b/bot/exts/evergreen/fun.py index 36a13ac0..1a7ebb90 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/evergreen/fun.py @@ -41,7 +41,7 @@ class Fun(Cog): elif num_rolls < 1: output = ":no_entry: You must roll at least once." for _ in range(num_rolls): - terning = f"terning{random.randint(1, 6)}" + terning = f"dice_{random.randint(1, 6)}" output += getattr(Emojis, terning, '') await ctx.send(output) -- cgit v1.2.3 From f1ac62822d070d5df3a2cc9d13dc018149c55898 Mon Sep 17 00:00:00 2001 From: Gustav Odinger Date: Thu, 17 Sep 2020 00:32:55 +0200 Subject: Update variable name from terning to dice --- bot/exts/evergreen/fun.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/fun.py b/bot/exts/evergreen/fun.py index 1a7ebb90..b0240c45 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/evergreen/fun.py @@ -41,8 +41,8 @@ class Fun(Cog): elif num_rolls < 1: output = ":no_entry: You must roll at least once." for _ in range(num_rolls): - terning = f"dice_{random.randint(1, 6)}" - output += getattr(Emojis, terning, '') + dice = f"dice_{random.randint(1, 6)}" + output += getattr(Emojis, dice, '') await ctx.send(output) @commands.command(name="uwu", aliases=("uwuwize", "uwuify",)) -- cgit v1.2.3 From c501cdf879d039e7871fda93925c0c5d3d46b8e3 Mon Sep 17 00:00:00 2001 From: Senjan21 <53477086+Senjan21@users.noreply.github.com> Date: Thu, 17 Sep 2020 19:53:41 +0200 Subject: fix `reddit` command to use new emojis. --- bot/exts/evergreen/reddit.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bot') diff --git a/bot/exts/evergreen/reddit.py b/bot/exts/evergreen/reddit.py index fe204419..49127bea 100644 --- a/bot/exts/evergreen/reddit.py +++ b/bot/exts/evergreen/reddit.py @@ -68,9 +68,9 @@ class Reddit(commands.Cog): # ----------------------------------------------------------- # This code below is bound of change when the emojis are added. - upvote_emoji = self.bot.get_emoji(638729835245731840) - comment_emoji = self.bot.get_emoji(638729835073765387) - user_emoji = self.bot.get_emoji(638729835442602003) + upvote_emoji = self.bot.get_emoji(755845219890757644) + comment_emoji = self.bot.get_emoji(755845255001014384) + user_emoji = self.bot.get_emoji(755845303822974997) text_emoji = self.bot.get_emoji(676030265910493204) video_emoji = self.bot.get_emoji(676030265839190047) image_emoji = self.bot.get_emoji(676030265734201344) -- cgit v1.2.3