From 1e240e7fbac71b0546ef090732c7417bab4e1563 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 2 Mar 2021 14:27:58 -0600 Subject: initial commit of earth_photos --- bot/exts/easter/earth_photos.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 bot/exts/easter/earth_photos.py (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py new file mode 100644 index 00000000..ceffeb48 --- /dev/null +++ b/bot/exts/easter/earth_photos.py @@ -0,0 +1,27 @@ +import asyncio +import logging +import random +from unsplash.api import Api +from unsplash.auth import Auth + +import discord +from discord.ext import commands + +log = logging.getLogger(__name__) + +class EarthPhotos(commands.Cog): + """This cog contains the command for earth photos.""" + + def init(self, bot: commands.Bot): + self.bot = bot + self.current_channel = None + + @commands.command(aliases=["earth"]) + async def earth_photos(self, ctx: commands.Context): + """ + Returns a random photo of earth. + """ + + + + -- cgit v1.2.3 From 99a9d7a1b7651caea4cf1587c89485497c061387 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 2 Mar 2021 15:22:39 -0600 Subject: Update earth_photos.py --- bot/exts/easter/earth_photos.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index ceffeb48..436b39a7 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,14 +1,24 @@ import asyncio import logging import random -from unsplash.api import Api -from unsplash.auth import Auth +from unsplash.api import Api as uApi +from unsplash.auth import Auth as uAuth import discord from discord.ext import commands +from bot.constants import Tokens + log = logging.getLogger(__name__) +UnClient_id = Tokens.UNSPLASH_API + +UnClient_secret = Tokens.UNSPLASH_SECRET + +redirect_uri = "urn:ietf:wg:oauth:2.0:oob" + +unsplash_auth = uAuth(client_id, + class EarthPhotos(commands.Cog): """This cog contains the command for earth photos.""" @@ -19,7 +29,7 @@ class EarthPhotos(commands.Cog): @commands.command(aliases=["earth"]) async def earth_photos(self, ctx: commands.Context): """ - Returns a random photo of earth. + Returns a random photo of earth, sourced from Unsplash. """ -- cgit v1.2.3 From 0260ad04af6e98c7fd804c58913412b6b936eb73 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 2 Mar 2021 21:39:01 -0600 Subject: finished function --- Pipfile | 1 + Pipfile.lock | 26 +++++++++++++++++--------- bot/constants.py | 1 + bot/exts/easter/earth_photos.py | 35 +++++++++++++++++++---------------- 4 files changed, 38 insertions(+), 25 deletions(-) (limited to 'bot') diff --git a/Pipfile b/Pipfile index e7e01a31..1a2d464e 100644 --- a/Pipfile +++ b/Pipfile @@ -15,6 +15,7 @@ PyYAML = "~=5.3.1" "discord.py" = {extras = ["voice"], version = "~=1.5.1"} async-rediscache = {extras = ["fakeredis"], version = "~=0.1.4"} emojis = "~=0.6.0" +requests = "~=2.25.1" [dev-packages] flake8 = "~=3.8" diff --git a/Pipfile.lock b/Pipfile.lock index ec801979..34cd08cf 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "b4aaaacbab13179145e36d7b86c736db512286f6cce8e513cc30c48d68fe3810" + "sha256": "53409f1c6726e95cf348740b1dc55124b77a1f327aea273dce041b5056270b2e" }, "pipfile-spec": 6, "requires": { @@ -238,11 +238,11 @@ }, "idna": { "hashes": [ - "sha256:5205d03e7bcbb919cc9c19885f9920d622ca52448306f2377daede5cf3faac16", - "sha256:c5b02147e01ea9920e6b0a3f1f7bb833612d507592c837a6c49552768f4054e1" + "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6", + "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" ], - "markers": "python_version >= '3.4'", - "version": "==3.1" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.10" }, "multidict": { "hashes": [ @@ -412,6 +412,14 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==3.5.3" }, + "requests": { + "hashes": [ + "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804", + "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e" + ], + "index": "pypi", + "version": "==2.25.1" + }, "sentry-sdk": { "hashes": [ "sha256:4ae8d1ced6c67f1c8ea51d82a16721c166c489b76876c9f2c202b8a50334b237", @@ -585,11 +593,11 @@ }, "identify": { "hashes": [ - "sha256:de7129142a5c86d75a52b96f394d94d96d497881d2aaf8eafe320cdbe8ac4bcc", - "sha256:e0dae57c0397629ce13c289f6ddde0204edf518f557bfdb1e56474aa143e77c3" + "sha256:9cdd81e5d2b6e76c3006d5226316dd947bd6324fbeebb881bec489202fa09d3a", + "sha256:b99aa309329c4fea679463eb35d169f3fbe13e66e9dd6162ad1856cbeb03dcbd" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.5.14" + "markers": "python_full_version >= '3.6.1'", + "version": "==2.0.0" }, "mccabe": { "hashes": [ diff --git a/bot/constants.py b/bot/constants.py index db34b55a..f8ea5743 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -271,6 +271,7 @@ class Tokens(NamedTuple): igdb_client_id = environ.get("IGDB_CLIENT_ID") igdb_client_secret = environ.get("IGDB_CLIENT_SECRET") github = environ.get("GITHUB_TOKEN") + unsplash_key = environ.get("UNSPLASH_KEY") class Wolfram(NamedTuple): diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 436b39a7..478502eb 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,8 +1,5 @@ -import asyncio import logging -import random -from unsplash.api import Api as uApi -from unsplash.auth import Auth as uAuth +import requests import discord from discord.ext import commands @@ -11,27 +8,33 @@ from bot.constants import Tokens log = logging.getLogger(__name__) -UnClient_id = Tokens.UNSPLASH_API +UnClient_id = Tokens.unsplash_key -UnClient_secret = Tokens.UNSPLASH_SECRET - -redirect_uri = "urn:ietf:wg:oauth:2.0:oob" - -unsplash_auth = uAuth(client_id, class EarthPhotos(commands.Cog): """This cog contains the command for earth photos.""" - + def init(self, bot: commands.Bot): self.bot = bot self.current_channel = None - + @commands.command(aliases=["earth"]) async def earth_photos(self, ctx: commands.Context): """ Returns a random photo of earth, sourced from Unsplash. """ - - - - + photorequest = requests.get("https://api.unsplash.com/photos/random?query=earth&client_id=" + UnClient_id) + photojson = photorequest.json() + photourls = photojson.get('urls') + urltosend = photourls.get('regular') + userjson = photojson.get('user') + userName = userjson.get('name') + embed = discord.Embed(title="Earth Photo", description="A photo of Earth from Unsplash.", color=0x66ff00) + embed.set_image(url=urltosend) + embed.set_footer(text="Image by " + userName + " on Unsplash.") + await ctx.send(embed=embed) + + +def setup(bot: commands.Bot) -> None: + """Cog load""" + bot.add_cog(EarthPhotos(bot)) -- cgit v1.2.3 From 51f16ed0a4e1ce43d7ce4cef1701a886d1b8492d Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 2 Mar 2021 21:58:27 -0600 Subject: Update earth_photos.py --- bot/exts/easter/earth_photos.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 478502eb..2ca43e42 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,9 +1,10 @@ -import logging -import requests - import discord from discord.ext import commands +import logging + +import requests + from bot.constants import Tokens log = logging.getLogger(__name__) @@ -15,6 +16,7 @@ class EarthPhotos(commands.Cog): """This cog contains the command for earth photos.""" def init(self, bot: commands.Bot): + """Init function.""" self.bot = bot self.current_channel = None @@ -28,13 +30,13 @@ class EarthPhotos(commands.Cog): photourls = photojson.get('urls') urltosend = photourls.get('regular') userjson = photojson.get('user') - userName = userjson.get('name') + username = userjson.get('name') embed = discord.Embed(title="Earth Photo", description="A photo of Earth from Unsplash.", color=0x66ff00) embed.set_image(url=urltosend) - embed.set_footer(text="Image by " + userName + " on Unsplash.") + embed.set_footer(text="Image by " + username + " on Unsplash.") await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: - """Cog load""" + """Cog load.""" bot.add_cog(EarthPhotos(bot)) -- cgit v1.2.3 From 286d40bb887246216da23857b4eeb8364fcbf9c7 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:04:47 -0600 Subject: linting changes --- bot/exts/easter/earth_photos.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 2ca43e42..e660112f 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,8 +1,10 @@ import discord -from discord.ext import commands import logging +from discord.ext import commands + + import requests from bot.constants import Tokens @@ -22,9 +24,7 @@ class EarthPhotos(commands.Cog): @commands.command(aliases=["earth"]) async def earth_photos(self, ctx: commands.Context): - """ - Returns a random photo of earth, sourced from Unsplash. - """ + """Returns a random photo of earth, sourced from Unsplash.""" photorequest = requests.get("https://api.unsplash.com/photos/random?query=earth&client_id=" + UnClient_id) photojson = photorequest.json() photourls = photojson.get('urls') -- cgit v1.2.3 From 8220661e8ef65ef4bbe92613ed2d3f273d43d76f Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:09:10 -0600 Subject: more linting fixes --- bot/exts/easter/earth_photos.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index e660112f..c9cfc9c8 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,11 +1,9 @@ -import discord - import logging -from discord.ext import commands - +import discord import requests +from discord.ext import commands from bot.constants import Tokens -- cgit v1.2.3 From da54e5181cbf2ab3406be4a8ab9628e346d3c328 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:15:57 -0600 Subject: lint fixes --- bot/exts/easter/earth_photos.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index c9cfc9c8..909fcbd8 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,7 +1,6 @@ import logging import discord - import requests from discord.ext import commands @@ -15,13 +14,13 @@ UnClient_id = Tokens.unsplash_key class EarthPhotos(commands.Cog): """This cog contains the command for earth photos.""" - def init(self, bot: commands.Bot): + def init(self, bot: commands.Bot) -> None: """Init function.""" self.bot = bot self.current_channel = None @commands.command(aliases=["earth"]) - async def earth_photos(self, ctx: commands.Context): + async def earth_photos(self, ctx: commands.Context) -> None: """Returns a random photo of earth, sourced from Unsplash.""" photorequest = requests.get("https://api.unsplash.com/photos/random?query=earth&client_id=" + UnClient_id) photojson = photorequest.json() -- cgit v1.2.3 From 029f5f0d6b38f70000013ca52c859a3486cdf544 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 07:14:06 -0600 Subject: Update bot/exts/easter/earth_photos.py Co-authored-by: Shivansh-007 <69356296+Shivansh-007@users.noreply.github.com> --- bot/exts/easter/earth_photos.py | 1 - 1 file changed, 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 909fcbd8..b41b277c 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -15,7 +15,6 @@ class EarthPhotos(commands.Cog): """This cog contains the command for earth photos.""" def init(self, bot: commands.Bot) -> None: - """Init function.""" self.bot = bot self.current_channel = None -- cgit v1.2.3 From 883405e6f419ebfe4799086bf4e7516fd1588c4d Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 07:43:41 -0600 Subject: init to __init__ Co-authored-by: Shivansh-007 <69356296+Shivansh-007@users.noreply.github.com> --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index b41b277c..db295285 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -14,7 +14,7 @@ UnClient_id = Tokens.unsplash_key class EarthPhotos(commands.Cog): """This cog contains the command for earth photos.""" - def init(self, bot: commands.Bot) -> None: + def __init__(self, bot: commands.Bot) -> None: self.bot = bot self.current_channel = None -- cgit v1.2.3 From 246e5bd7109ba906162989e42c77d68402359106 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:26:48 -0600 Subject: Fix docstrings Co-authored-by: Shivansh-007 <69356296+Shivansh-007@users.noreply.github.com> --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index db295285..4c319eaa 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -34,5 +34,5 @@ class EarthPhotos(commands.Cog): def setup(bot: commands.Bot) -> None: - """Cog load.""" + """Load the Earth Photos cog.""" bot.add_cog(EarthPhotos(bot)) -- cgit v1.2.3 From 4a0401ddb322fba53e2025a63fdf8d0a52e12076 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:32:47 -0600 Subject: Update earth_photos.py --- bot/exts/easter/earth_photos.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 4c319eaa..52bbaf36 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,13 +1,9 @@ -import logging - +import aiohttp import discord -import requests from discord.ext import commands from bot.constants import Tokens -log = logging.getLogger(__name__) - UnClient_id = Tokens.unsplash_key @@ -21,16 +17,14 @@ class EarthPhotos(commands.Cog): @commands.command(aliases=["earth"]) async def earth_photos(self, ctx: commands.Context) -> None: """Returns a random photo of earth, sourced from Unsplash.""" - photorequest = requests.get("https://api.unsplash.com/photos/random?query=earth&client_id=" + UnClient_id) - photojson = photorequest.json() - photourls = photojson.get('urls') - urltosend = photourls.get('regular') - userjson = photojson.get('user') - username = userjson.get('name') - embed = discord.Embed(title="Earth Photo", description="A photo of Earth from Unsplash.", color=0x66ff00) - embed.set_image(url=urltosend) - embed.set_footer(text="Image by " + username + " on Unsplash.") - await ctx.send(embed=embed) + async with ctx.typing(): + async with aiohttp.ClientSession as session: + async with session.get( + 'https://api.unsplash.com/photos/random?query=earth&client_id=' + UnClientId + ) as r: + jsondata = await r.json() + await ctx.send("Still a placeholder") + def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 From a2c68caf0e39e6947372d303dcc707f26f1a744f Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:57:07 -0600 Subject: Update earth_photos.py --- bot/exts/easter/earth_photos.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 52bbaf36..adae0dcd 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -20,10 +20,18 @@ class EarthPhotos(commands.Cog): async with ctx.typing(): async with aiohttp.ClientSession as session: async with session.get( - 'https://api.unsplash.com/photos/random?query=earth&client_id=' + UnClientId - ) as r: + 'https://api.unsplash.com/photos/random?query=earth&client_id=' + UnClientId) as r: jsondata = await r.json() - await ctx.send("Still a placeholder") + linksdata = jsondata.get("urls") + downloadlinksdata = jsondata.get("links") + async with session.get( + downloadlinksdata.get("download_location") + "?client_id=" + UnClient_id) as er: + pass + await ctx.send("Still a work in progress") + + + + -- cgit v1.2.3 From 01a1624b14cc5d60b2e76871361e14f9cbfd69ce Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:57:49 -0600 Subject: asyncio start --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index adae0dcd..26beda79 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -27,7 +27,7 @@ class EarthPhotos(commands.Cog): async with session.get( downloadlinksdata.get("download_location") + "?client_id=" + UnClient_id) as er: pass - await ctx.send("Still a work in progress") + await ctx.send("Still a work in progress, coming soon.") -- cgit v1.2.3 From 3b0949c96926fa30aa650bfd9c9a43e4fd52521f Mon Sep 17 00:00:00 2001 From: Kronifer Date: Wed, 3 Mar 2021 16:39:05 +0000 Subject: linting --- Pipfile | 1 + Pipfile.lock | 76 ++++++++++++++++++++++++++++++++++++++--- bot/exts/easter/earth_photos.py | 14 ++++---- 3 files changed, 79 insertions(+), 12 deletions(-) (limited to 'bot') diff --git a/Pipfile b/Pipfile index 1a2d464e..1d1df3d7 100644 --- a/Pipfile +++ b/Pipfile @@ -16,6 +16,7 @@ PyYAML = "~=5.3.1" async-rediscache = {extras = ["fakeredis"], version = "~=0.1.4"} emojis = "~=0.6.0" requests = "~=2.25.1" +pre-commit = "*" [dev-packages] flake8 = "~=3.8" diff --git a/Pipfile.lock b/Pipfile.lock index 34cd08cf..b58db761 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "53409f1c6726e95cf348740b1dc55124b77a1f327aea273dce041b5056270b2e" + "sha256": "434b76f6a372bf3ddc418d7b6bdba4d8906cbebb76553ffebf0b15d572e83487" }, "pipfile-spec": 6, "requires": { @@ -50,6 +50,13 @@ ], "version": "==1.3.1" }, + "appdirs": { + "hashes": [ + "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41", + "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128" + ], + "version": "==1.4.4" + }, "arrow": { "hashes": [ "sha256:e098abbd9af3665aea81bdd6c869e93af4feb078e98468dd351c383af187aac5", @@ -143,6 +150,14 @@ ], "version": "==1.14.5" }, + "cfgv": { + "hashes": [ + "sha256:32e43d604bbe7896fe7c248a9c2276447dbef840feb28fe20494f62af110211d", + "sha256:cf22deb93d4bcf92f345a5c3cd39d3d41d6340adc60c78bbbd6588c384fda6a1" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==3.2.0" + }, "chardet": { "hashes": [ "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", @@ -161,6 +176,13 @@ "index": "pypi", "version": "==1.5.1" }, + "distlib": { + "hashes": [ + "sha256:8c09de2c67b3e7deef7184574fc060ab8a793e7adbb183d942c389c8b13c52fb", + "sha256:edf6116872c863e1aa9d5bb7cb5e05a022c519a4594dc703843343a9ddd9bff1" + ], + "version": "==0.3.1" + }, "emojis": { "hashes": [ "sha256:7da34c8a78ae262fd68cef9e2c78a3c1feb59784489eeea0f54ba1d4b7111c7c", @@ -176,6 +198,13 @@ ], "version": "==1.4.5" }, + "filelock": { + "hashes": [ + "sha256:18d82244ee114f543149c66a6e0c14e9c4f8a1044b5cdaadd0f82159d6a6ff59", + "sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836" + ], + "version": "==3.0.12" + }, "fuzzywuzzy": { "hashes": [ "sha256:45016e92264780e58972dca1b3d939ac864b78437422beecebb3095f8efd00e8", @@ -236,6 +265,14 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.1.0" }, + "identify": { + "hashes": [ + "sha256:2179e7359471ab55729f201b3fdf7dc2778e221f868410fedcb0987b791ba552", + "sha256:2a5fdf2f5319cc357eda2550bea713a404392495961022cf2462624ce62f0f46" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==2.1.0" + }, "idna": { "hashes": [ "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6", @@ -267,6 +304,13 @@ "markers": "python_version >= '3.5'", "version": "==4.7.6" }, + "nodeenv": { + "hashes": [ + "sha256:5304d424c529c997bc888453aeaa6362d242b6b4631e90f3d4bf1b290f1c84a9", + "sha256:ab45090ae383b716c4ef89e690c41ff8c2b257b85b309f01f3654df3d084bd7c" + ], + "version": "==1.5.0" + }, "pillow": { "hashes": [ "sha256:0295442429645fa16d05bd567ef5cff178482439c9aad0411d3f0ce9b88b3a6f", @@ -301,6 +345,14 @@ "index": "pypi", "version": "==7.2.0" }, + "pre-commit": { + "hashes": [ + "sha256:16212d1fde2bed88159287da88ff03796863854b04dc9f838a55979325a3d20e", + "sha256:399baf78f13f4de82a29b649afd74bef2c4e28eb4f021661fc7f29246e8c7a3a" + ], + "index": "pypi", + "version": "==2.10.1" + }, "pycares": { "hashes": [ "sha256:050f00b39ed77ea8a4e555f09417d4b1a6b5baa24bb9531a3e15d003d2319b3f", @@ -451,6 +503,14 @@ "markers": "python_version >= '3.0'", "version": "==2.2" }, + "toml": { + "hashes": [ + "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", + "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==0.10.2" + }, "urllib3": { "hashes": [ "sha256:1b465e494e3e0d8939b50680403e3aedaa2bc434b7d5af64dfd3c958d7f5ae80", @@ -459,6 +519,14 @@ "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.26.3" }, + "virtualenv": { + "hashes": [ + "sha256:147b43894e51dd6bba882cf9c282447f780e2251cd35172403745fc381a0a80d", + "sha256:2be72df684b74df0ea47679a7df93fd0e04e72520022c57b479d8f881485dbe3" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==20.4.2" + }, "yarl": { "hashes": [ "sha256:040b237f58ff7d800e6e0fd89c8439b841f777dd99b4a9cca04d6935564b9409", @@ -593,11 +661,11 @@ }, "identify": { "hashes": [ - "sha256:9cdd81e5d2b6e76c3006d5226316dd947bd6324fbeebb881bec489202fa09d3a", - "sha256:b99aa309329c4fea679463eb35d169f3fbe13e66e9dd6162ad1856cbeb03dcbd" + "sha256:2179e7359471ab55729f201b3fdf7dc2778e221f868410fedcb0987b791ba552", + "sha256:2a5fdf2f5319cc357eda2550bea713a404392495961022cf2462624ce62f0f46" ], "markers": "python_full_version >= '3.6.1'", - "version": "==2.0.0" + "version": "==2.1.0" }, "mccabe": { "hashes": [ diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 26beda79..8e90c9e7 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -20,19 +20,17 @@ class EarthPhotos(commands.Cog): async with ctx.typing(): async with aiohttp.ClientSession as session: async with session.get( - 'https://api.unsplash.com/photos/random?query=earth&client_id=' + UnClientId) as r: + 'https://api.unsplash.com/photos/random?query=earth&client_id=' + UnClient_id) as r: jsondata = await r.json() linksdata = jsondata.get("urls") + embedlink = linksdata.get("full") downloadlinksdata = jsondata.get("links") async with session.get( downloadlinksdata.get("download_location") + "?client_id=" + UnClient_id) as er: - pass - await ctx.send("Still a work in progress, coming soon.") - - - - - + er.status() + embed = discord.Embed(title="In progress") + embed.set_photo(url=embedlink) + await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 From 443c623548caf8edb82d0b9cfe41afcf594f0161 Mon Sep 17 00:00:00 2001 From: Kronifer Date: Wed, 3 Mar 2021 16:48:19 +0000 Subject: final lint fix --- bot/exts/easter/earth_photos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 8e90c9e7..e3d5936e 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -20,13 +20,13 @@ class EarthPhotos(commands.Cog): async with ctx.typing(): async with aiohttp.ClientSession as session: async with session.get( - 'https://api.unsplash.com/photos/random?query=earth&client_id=' + UnClient_id) as r: + 'https://api.unsplash.com/photos/random?query=earth&client_id=' + UnClient_id) as r: jsondata = await r.json() linksdata = jsondata.get("urls") embedlink = linksdata.get("full") downloadlinksdata = jsondata.get("links") async with session.get( - downloadlinksdata.get("download_location") + "?client_id=" + UnClient_id) as er: + downloadlinksdata.get("download_location") + "?client_id=" + UnClient_id) as er: er.status() embed = discord.Embed(title="In progress") embed.set_photo(url=embedlink) -- cgit v1.2.3 From f0cd29587f29731286be8c29d1ee0ca20d37d42f Mon Sep 17 00:00:00 2001 From: Kronifer Date: Wed, 3 Mar 2021 17:07:20 +0000 Subject: possible final update --- bot/exts/easter/earth_photos.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index e3d5936e..0ac470ce 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -18,19 +18,27 @@ class EarthPhotos(commands.Cog): async def earth_photos(self, ctx: commands.Context) -> None: """Returns a random photo of earth, sourced from Unsplash.""" async with ctx.typing(): - async with aiohttp.ClientSession as session: + async with aiohttp.ClientSession() as session: async with session.get( 'https://api.unsplash.com/photos/random?query=earth&client_id=' + UnClient_id) as r: jsondata = await r.json() linksdata = jsondata.get("urls") embedlink = linksdata.get("full") downloadlinksdata = jsondata.get("links") + userdata = jsondata.get("user") + username = userdata.get("name") + userlinks = userdata.get("links") + profile = userlinks.get("html") async with session.get( downloadlinksdata.get("download_location") + "?client_id=" + UnClient_id) as er: - er.status() - embed = discord.Embed(title="In progress") - embed.set_photo(url=embedlink) - await ctx.send(embed=embed) + er.status + embed = discord.Embed( + title="Earth Photo", + description="A photo of earth from Unsplash.", + color=0x66ff00) + embed.set_image(url=embedlink) + embed.add_field(title="Author", value="Made by [" + username + "](" + profile + ") on Unsplash.") + await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 From b2ee1b9e79766b8cfe7b45670f6c86e7166ee84f Mon Sep 17 00:00:00 2001 From: Kronifer Date: Wed, 3 Mar 2021 20:20:22 +0000 Subject: fstrings, colours, and self.bot --- Pipfile | 2 -- bot/constants.py | 1 + bot/exts/easter/earth_photos.py | 48 ++++++++++++++++++++--------------------- 3 files changed, 25 insertions(+), 26 deletions(-) (limited to 'bot') diff --git a/Pipfile b/Pipfile index 1d1df3d7..e7e01a31 100644 --- a/Pipfile +++ b/Pipfile @@ -15,8 +15,6 @@ PyYAML = "~=5.3.1" "discord.py" = {extras = ["voice"], version = "~=1.5.1"} async-rediscache = {extras = ["fakeredis"], version = "~=0.1.4"} emojis = "~=0.6.0" -requests = "~=2.25.1" -pre-commit = "*" [dev-packages] flake8 = "~=3.8" diff --git a/bot/constants.py b/bot/constants.py index f8ea5743..c570b17f 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -158,6 +158,7 @@ class Colours: soft_orange = 0xf9cb54 soft_red = 0xcd6d6d yellow = 0xf9f586 + grass_green = 0x66ff00 class Emojis: diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 0ac470ce..a49e666c 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,8 +1,8 @@ -import aiohttp import discord from discord.ext import commands from bot.constants import Tokens +from bot.constants import Colours UnClient_id = Tokens.unsplash_key @@ -10,35 +10,35 @@ UnClient_id = Tokens.unsplash_key class EarthPhotos(commands.Cog): """This cog contains the command for earth photos.""" - def __init__(self, bot: commands.Bot) -> None: + def __init__(self, bot: commands.Bot): self.bot = bot - self.current_channel = None @commands.command(aliases=["earth"]) async def earth_photos(self, ctx: commands.Context) -> None: """Returns a random photo of earth, sourced from Unsplash.""" async with ctx.typing(): - async with aiohttp.ClientSession() as session: - async with session.get( - 'https://api.unsplash.com/photos/random?query=earth&client_id=' + UnClient_id) as r: - jsondata = await r.json() - linksdata = jsondata.get("urls") - embedlink = linksdata.get("full") - downloadlinksdata = jsondata.get("links") - userdata = jsondata.get("user") - username = userdata.get("name") - userlinks = userdata.get("links") - profile = userlinks.get("html") - async with session.get( - downloadlinksdata.get("download_location") + "?client_id=" + UnClient_id) as er: - er.status - embed = discord.Embed( - title="Earth Photo", - description="A photo of earth from Unsplash.", - color=0x66ff00) - embed.set_image(url=embedlink) - embed.add_field(title="Author", value="Made by [" + username + "](" + profile + ") on Unsplash.") - await ctx.send(embed=embed) + async with self.bot.http_session.get( + 'https://api.unsplash.com/photos/random', + params={"query": "planet_earth", "client_id": UnClient_id}) as r: + jsondata = await r.json() + linksdata = jsondata.get("urls") + embedlink = linksdata.get("full") + downloadlinksdata = jsondata.get("links") + userdata = jsondata.get("user") + username = userdata.get("name") + userlinks = userdata.get("links") + profile = userlinks.get("html") + async with self.bot.http_session.get( + downloadlinksdata.get("download_location"), + params={"client_id": UnClient_id}) as er: + er.status + embed = discord.Embed( + title="Earth Photo", + description="A photo of earth from Unsplash.", + color=Colours.grass_green) + embed.set_image(url=embedlink) + embed.add_field(name="Author", value=f"Made by [{username}]({profile}) on Unsplash.") + await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 From 4cf72b014efbd8141e30482984e68e65c08e312d Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 14:28:43 -0600 Subject: Fixed import --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index a49e666c..b496cbea 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,8 +1,8 @@ import discord from discord.ext import commands -from bot.constants import Tokens from bot.constants import Colours +from bot.constants import Tokens UnClient_id = Tokens.unsplash_key -- cgit v1.2.3 From 6c46dca3525758f1c1841f1dba312bb45c28531e Mon Sep 17 00:00:00 2001 From: Kronifer Date: Wed, 3 Mar 2021 22:27:37 +0000 Subject: minor change to getting image --- bot/exts/easter/earth_photos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index a49e666c..66780f6a 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -19,10 +19,10 @@ class EarthPhotos(commands.Cog): async with ctx.typing(): async with self.bot.http_session.get( 'https://api.unsplash.com/photos/random', - params={"query": "planet_earth", "client_id": UnClient_id}) as r: + params={"query": "earth", "client_id": UnClient_id}) as r: jsondata = await r.json() linksdata = jsondata.get("urls") - embedlink = linksdata.get("full") + embedlink = linksdata.get("regular") downloadlinksdata = jsondata.get("links") userdata = jsondata.get("user") username = userdata.get("name") -- cgit v1.2.3 From 01c380754e7466654924238dcee2f2077dd752a7 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 19:03:40 -0600 Subject: Format change Co-authored-by: Shivansh-007 <69356296+Shivansh-007@users.noreply.github.com> --- bot/exts/easter/earth_photos.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index efc5081a..a544ab59 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -35,7 +35,8 @@ class EarthPhotos(commands.Cog): embed = discord.Embed( title="Earth Photo", description="A photo of earth from Unsplash.", - color=Colours.grass_green) + color=Colours.grass_green + ) embed.set_image(url=embedlink) embed.add_field(name="Author", value=f"Made by [{username}]({profile}) on Unsplash.") await ctx.send(embed=embed) -- cgit v1.2.3 From fa38d70fc16e34ff3aff58bfbc7533f586a8eb97 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 19:05:16 -0600 Subject: More formatting Co-authored-by: Shivansh-007 <69356296+Shivansh-007@users.noreply.github.com> --- bot/exts/easter/earth_photos.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index a544ab59..f0c57fc5 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -30,7 +30,8 @@ class EarthPhotos(commands.Cog): profile = userlinks.get("html") async with self.bot.http_session.get( downloadlinksdata.get("download_location"), - params={"client_id": UnClient_id}) as er: + params={"client_id": UnClient_id} + ) as er: er.status embed = discord.Embed( title="Earth Photo", -- cgit v1.2.3 From 825080e805787afc1f36a80b4fa3f73040ebdc75 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 19:05:37 -0600 Subject: Format change Co-authored-by: Shivansh-007 <69356296+Shivansh-007@users.noreply.github.com> --- bot/exts/easter/earth_photos.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index f0c57fc5..6bfc26b0 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -19,7 +19,8 @@ class EarthPhotos(commands.Cog): async with ctx.typing(): async with self.bot.http_session.get( 'https://api.unsplash.com/photos/random', - params={"query": "earth", "client_id": UnClient_id}) as r: + params={"query": "earth", "client_id": UnClient_id} + ) as r: jsondata = await r.json() linksdata = jsondata.get("urls") embedlink = linksdata.get("regular") -- cgit v1.2.3 From 05e18c02cd076a70e3aac370e7d120a16c84aab7 Mon Sep 17 00:00:00 2001 From: Kronifer Date: Thu, 4 Mar 2021 01:31:14 +0000 Subject: Revert "Format change" This reverts commit 825080e805787afc1f36a80b4fa3f73040ebdc75. --- bot/exts/easter/earth_photos.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 6bfc26b0..f0c57fc5 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -19,8 +19,7 @@ class EarthPhotos(commands.Cog): async with ctx.typing(): async with self.bot.http_session.get( 'https://api.unsplash.com/photos/random', - params={"query": "earth", "client_id": UnClient_id} - ) as r: + params={"query": "earth", "client_id": UnClient_id}) as r: jsondata = await r.json() linksdata = jsondata.get("urls") embedlink = linksdata.get("regular") -- cgit v1.2.3 From 60712f67c3e0f77023a481e5cbf0ce9816a7368e Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Wed, 3 Mar 2021 20:16:59 -0600 Subject: requested changes by @Shivansh-007 --- bot/exts/easter/earth_photos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index f0c57fc5..001f8f41 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -31,8 +31,8 @@ class EarthPhotos(commands.Cog): async with self.bot.http_session.get( downloadlinksdata.get("download_location"), params={"client_id": UnClient_id} - ) as er: - er.status + ) as _: + pass embed = discord.Embed( title="Earth Photo", description="A photo of earth from Unsplash.", -- cgit v1.2.3 From e222ece92b4d14f4a9bb148f28acf9770da44d1b Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 10:35:38 -0600 Subject: Changes requested by @ChrisLovering --- bot/exts/easter/earth_photos.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 001f8f41..3ab8e7d9 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -1,10 +1,12 @@ +import logging + import discord from discord.ext import commands from bot.constants import Colours from bot.constants import Tokens -UnClient_id = Tokens.unsplash_key +log = logging.getLogger(__name__) class EarthPhotos(commands.Cog): @@ -19,7 +21,7 @@ class EarthPhotos(commands.Cog): async with ctx.typing(): async with self.bot.http_session.get( 'https://api.unsplash.com/photos/random', - params={"query": "earth", "client_id": UnClient_id}) as r: + params={"query": "earth", "client_id": Tokens.unsplash_access_key}) as r: jsondata = await r.json() linksdata = jsondata.get("urls") embedlink = linksdata.get("regular") @@ -30,9 +32,10 @@ class EarthPhotos(commands.Cog): profile = userlinks.get("html") async with self.bot.http_session.get( downloadlinksdata.get("download_location"), - params={"client_id": UnClient_id} - ) as _: + params={"client_id": Tokens.unsplash_access_key} + ) as er: pass + embed = discord.Embed( title="Earth Photo", description="A photo of earth from Unsplash.", @@ -45,4 +48,7 @@ class EarthPhotos(commands.Cog): def setup(bot: commands.Bot) -> None: """Load the Earth Photos cog.""" + if not Tokens.unsplash_access_key: + log.warning("No Unsplash access key found. Cog not loading.") + return bot.add_cog(EarthPhotos(bot)) -- cgit v1.2.3 From 512a5b3f085510d5862589ecc21bd253cb219207 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 10:37:53 -0600 Subject: Changes requested by @ChrisLovering --- 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 c570b17f..721defc8 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -272,7 +272,7 @@ class Tokens(NamedTuple): igdb_client_id = environ.get("IGDB_CLIENT_ID") igdb_client_secret = environ.get("IGDB_CLIENT_SECRET") github = environ.get("GITHUB_TOKEN") - unsplash_key = environ.get("UNSPLASH_KEY") + unsplash_access_key = environ.get("UNSPLASH_KEY") class Wolfram(NamedTuple): -- cgit v1.2.3 From 8b05f80392174a1a8b47e872b955d59bdcd4472f Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 10:40:42 -0600 Subject: small lint fix --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 3ab8e7d9..beb16772 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -33,7 +33,7 @@ class EarthPhotos(commands.Cog): async with self.bot.http_session.get( downloadlinksdata.get("download_location"), params={"client_id": Tokens.unsplash_access_key} - ) as er: + ) as _: pass embed = discord.Embed( -- cgit v1.2.3 From f22aa5bd3f706751556def22d5660cdc8d93fde1 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 10:56:06 -0600 Subject: Format fix Co-authored-by: Shivansh-007 <69356296+Shivansh-007@users.noreply.github.com> --- bot/exts/easter/earth_photos.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index beb16772..3abedd0c 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -21,7 +21,8 @@ class EarthPhotos(commands.Cog): async with ctx.typing(): async with self.bot.http_session.get( 'https://api.unsplash.com/photos/random', - params={"query": "earth", "client_id": Tokens.unsplash_access_key}) as r: + params={"query": "earth", "client_id": Tokens.unsplash_access_key} + ) as r: jsondata = await r.json() linksdata = jsondata.get("urls") embedlink = linksdata.get("regular") -- cgit v1.2.3 From 1e1f4035f14592d7beaf93cbd3ae8e3895de588c Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 10:56:36 -0600 Subject: String upgrade Co-authored-by: Shivansh-007 <69356296+Shivansh-007@users.noreply.github.com> --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 3abedd0c..d3b21644 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -39,7 +39,7 @@ class EarthPhotos(commands.Cog): embed = discord.Embed( title="Earth Photo", - description="A photo of earth from Unsplash.", + description="A photo of Earth 🌎 from Unsplash.", color=Colours.grass_green ) embed.set_image(url=embedlink) -- cgit v1.2.3 From 3fa4049b0c16777c7a9349dc9058d89a4a44b5c7 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 10:58:25 -0600 Subject: Update earth_photos.py --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index d3b21644..71fb1313 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -43,7 +43,7 @@ class EarthPhotos(commands.Cog): color=Colours.grass_green ) embed.set_image(url=embedlink) - embed.add_field(name="Author", value=f"Made by [{username}]({profile}) on Unsplash.") + embed.add_field(name="Author", value=f"Photo by [{username}]({profile}) on Unsplash.") await ctx.send(embed=embed) -- cgit v1.2.3 From c25381fffd3b42bd1345dd9a910218c70877d2d3 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 10:59:36 -0600 Subject: suggestion by @Shivansh-007 --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 71fb1313..1cf2d11a 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -44,7 +44,7 @@ class EarthPhotos(commands.Cog): ) embed.set_image(url=embedlink) embed.add_field(name="Author", value=f"Photo by [{username}]({profile}) on Unsplash.") - await ctx.send(embed=embed) + await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 From 68ff4f3a524e90099e6953bd601321623e789e66 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 11:04:05 -0600 Subject: clarification in some areas --- bot/exts/easter/earth_photos.py | 1 + 1 file changed, 1 insertion(+) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 1cf2d11a..c1704e12 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -31,6 +31,7 @@ class EarthPhotos(commands.Cog): username = userdata.get("name") userlinks = userdata.get("links") profile = userlinks.get("html") + # Extra request as per Unsplash Guidelines async with self.bot.http_session.get( downloadlinksdata.get("download_location"), params={"client_id": Tokens.unsplash_access_key} -- cgit v1.2.3 From cce1b2cb25b572ac3e976b190d7eae417240ae76 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 13:26:42 -0600 Subject: API guideline fix for Unsplash --- bot/exts/easter/earth_photos.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index c1704e12..39bb627e 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -31,7 +31,6 @@ class EarthPhotos(commands.Cog): username = userdata.get("name") userlinks = userdata.get("links") profile = userlinks.get("html") - # Extra request as per Unsplash Guidelines async with self.bot.http_session.get( downloadlinksdata.get("download_location"), params={"client_id": Tokens.unsplash_access_key} @@ -44,7 +43,9 @@ class EarthPhotos(commands.Cog): color=Colours.grass_green ) embed.set_image(url=embedlink) - embed.add_field(name="Author", value=f"Photo by [{username}]({profile}) on Unsplash.") + embed.add_field(name="Author", + value=f"Photo by [{username}]({profile}?utm_source=sir_lancebot&utm_medium=referral)\ + on [Unsplash](https://unsplash.com?utm_source=sir_lancebot&utm_medium=referral).") await ctx.send(embed=embed) -- cgit v1.2.3 From 6b8a81e7a698eb362b4bea7bb73ef369d589cbfc Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 13:30:17 -0600 Subject: whitespace fix --- bot/exts/easter/earth_photos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 39bb627e..9bcca583 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -39,11 +39,11 @@ class EarthPhotos(commands.Cog): embed = discord.Embed( title="Earth Photo", - description="A photo of Earth 🌎 from Unsplash.", + description="A photo of Earth 🌎 from Unsplash.", color=Colours.grass_green ) embed.set_image(url=embedlink) - embed.add_field(name="Author", + embed.add_field(name="Author", value=f"Photo by [{username}]({profile}?utm_source=sir_lancebot&utm_medium=referral)\ on [Unsplash](https://unsplash.com?utm_source=sir_lancebot&utm_medium=referral).") await ctx.send(embed=embed) -- cgit v1.2.3 From 43d42c9fc254e79ecb8e98e42ff4ea9aa43c707a Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 13:44:31 -0600 Subject: linting fix --- bot/exts/easter/earth_photos.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 9bcca583..26f3d115 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -21,7 +21,7 @@ class EarthPhotos(commands.Cog): async with ctx.typing(): async with self.bot.http_session.get( 'https://api.unsplash.com/photos/random', - params={"query": "earth", "client_id": Tokens.unsplash_access_key} + params={"query": "planet_earth", "client_id": Tokens.unsplash_access_key} ) as r: jsondata = await r.json() linksdata = jsondata.get("urls") @@ -31,6 +31,8 @@ class EarthPhotos(commands.Cog): username = userdata.get("name") userlinks = userdata.get("links") profile = userlinks.get("html") + # Referral flags + rf = "?utm_source=sir_lancebot&utm_medium=referral" async with self.bot.http_session.get( downloadlinksdata.get("download_location"), params={"client_id": Tokens.unsplash_access_key} @@ -39,13 +41,13 @@ class EarthPhotos(commands.Cog): embed = discord.Embed( title="Earth Photo", - description="A photo of Earth 🌎 from Unsplash.", + description="A photo of Earth 🌎 from Unsplash.", color=Colours.grass_green ) embed.set_image(url=embedlink) embed.add_field(name="Author", - value=f"Photo by [{username}]({profile}?utm_source=sir_lancebot&utm_medium=referral)\ - on [Unsplash](https://unsplash.com?utm_source=sir_lancebot&utm_medium=referral).") + value=f"Photo by [{username}]({profile}" + rf + ") \ +on [Unsplash](https://unsplash.com?" + rf + ").") await ctx.send(embed=embed) -- cgit v1.2.3 From e6f2d51cfc35ae8bafc160fb3449911457442252 Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 13:53:45 -0600 Subject: style guidelines --- bot/exts/easter/earth_photos.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 26f3d115..96282d24 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -45,9 +45,11 @@ class EarthPhotos(commands.Cog): color=Colours.grass_green ) embed.set_image(url=embedlink) - embed.add_field(name="Author", - value=f"Photo by [{username}]({profile}" + rf + ") \ -on [Unsplash](https://unsplash.com?" + rf + ").") + embed.add_field( + name="Author", + value=f"Photo by [{username}]({profile}{rf}) \ + on [Unsplash](https://unsplash.com{rf})." + ) await ctx.send(embed=embed) -- cgit v1.2.3 From 1ae9948c04257c27fb2e71e5ae03a05bcd1db60e Mon Sep 17 00:00:00 2001 From: Kronifer <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 13:57:26 -0600 Subject: single space fix --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 96282d24..12fe6f1c 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -41,7 +41,7 @@ class EarthPhotos(commands.Cog): embed = discord.Embed( title="Earth Photo", - description="A photo of Earth 🌎 from Unsplash.", + description="A photo of Earth 🌎 from Unsplash.", color=Colours.grass_green ) embed.set_image(url=embedlink) -- cgit v1.2.3 From 334885c1b98ac4dcd475baac358eb8981a65b9c5 Mon Sep 17 00:00:00 2001 From: Dillon Runke <44979306+Kronifer@users.noreply.github.com> Date: Thu, 4 Mar 2021 16:17:42 -0600 Subject: Update earth_photos.py --- bot/exts/easter/earth_photos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py index 12fe6f1c..60e34b15 100644 --- a/bot/exts/easter/earth_photos.py +++ b/bot/exts/easter/earth_photos.py @@ -32,7 +32,7 @@ class EarthPhotos(commands.Cog): userlinks = userdata.get("links") profile = userlinks.get("html") # Referral flags - rf = "?utm_source=sir_lancebot&utm_medium=referral" + rf = "?utm_source=Sir%20Lancebot&utm_medium=referral" async with self.bot.http_session.get( downloadlinksdata.get("download_location"), params={"client_id": Tokens.unsplash_access_key} -- cgit v1.2.3