fix(bible): do not use fums on routes that don't support it (part 3)
All checks were successful
Actions / Lint Code (Pylint) (push) Successful in 15s
Actions / Build Documentation (MkDocs) (push) Successful in 16s

This commit is contained in:
Seaswimmer 2024-02-02 01:51:47 -05:00
parent 09e91da62f
commit 08b3553c2c
Signed by: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -141,17 +141,12 @@ class Bible(commands.Cog):
raise bible.errors.ServiceUnavailable()
return data["data"]
async def _get_verses(
self, ctx: commands.Context, bible_id: str, book_id: str, chapter: int
) -> dict:
async def _get_verses(self, bible_id: str, book_id: str, chapter: int) -> dict:
"""Get the verses of a chapter from the API.bible API."""
url = f"https://api.scripture.api.bible/v1/bibles/{bible_id}/chapters/{book_id}.{chapter}/verses"
headers = await self.bot.get_shared_api_tokens("api.bible")
params = {
"fums-version": "3",
}
async with self.session.get(url, headers=headers, params=params) as response:
async with self.session.get(url, headers=headers) as response:
data = await response.json()
self.logger.debug(
"_get_verses executed with a response code of: %s\n%s",
@ -164,23 +159,7 @@ class Bible(commands.Cog):
raise bible.errors.BibleAccessError()
if response.status == 503:
raise bible.errors.ServiceUnavailable()
fums_url = "https://fums.api.bible/f3"
fums_params = {
"t": data["meta"]["fumsToken"],
"dId": "discord-" + str(self.bot.user.id),
"sId": "discord-" + str(ctx.message.created_at.timestamp()),
"uId": ctx.author.id,
}
async with self.session.get(fums_url, params=fums_params) as response:
fums_data = await response.json()
self.logger.debug(
"_get_verses FUMS executed with a response code of: %s\n%s",
response.status,
json.dumps(fums_data),
)
return data["data"]
return data["data"]
@commands.group(autohelp=True)
async def bible(self, ctx: commands.Context):
@ -249,9 +228,7 @@ class Bible(commands.Cog):
chapters = await self._get_chapters(bible_id, book["id"])
chapter = random.choice(chapters)
verses = await self._get_verses(
ctx, bible_id, book["id"], chapter["number"]
)
verses = await self._get_verses(bible_id, book["id"], chapter["number"])
verse = random.choice(verses)["id"]
passage = await self._get_passage(ctx, bible_id, verse, False)