fix(bible): fixing some things
This commit is contained in:
parent
e71fc9f154
commit
acc883af20
1 changed files with 6 additions and 4 deletions
|
@ -35,13 +35,15 @@ class Bible(commands.Cog):
|
||||||
self.config.register_global(bible="de4e12af7f28f599-02")
|
self.config.register_global(bible="de4e12af7f28f599-02")
|
||||||
self.config.register_user(bible=None)
|
self.config.register_user(bible=None)
|
||||||
|
|
||||||
async def translate_book_name(self, bible_id: str, book_name: str) -> str:
|
async def translate_book_name(
|
||||||
|
self, ctx: commands.Context, bible_id: str, book_name: str
|
||||||
|
) -> str:
|
||||||
"""Translate a book name to a book ID."""
|
"""Translate a book name to a book ID."""
|
||||||
book_name_list = [
|
book_name_list = [
|
||||||
w.lower() if w.lower() == "of" else w.title() for w in book_name.split()
|
w.lower() if w.lower() == "of" else w.title() for w in book_name.split()
|
||||||
]
|
]
|
||||||
book_name = " ".join(book_name_list)
|
book_name = " ".join(book_name_list)
|
||||||
books = await self._get_books(bible_id)
|
books = await self._get_books(ctx, bible_id)
|
||||||
for book in books:
|
for book in books:
|
||||||
if book_name in (book["abbreviation"], book["name"]):
|
if book_name in (book["abbreviation"], book["name"]):
|
||||||
return book["id"]
|
return book["id"]
|
||||||
|
@ -58,6 +60,7 @@ class Bible(commands.Cog):
|
||||||
url = f"https://api.scripture.api.bible/v1/bibles/{bible_id}/passages/{passage_id}"
|
url = f"https://api.scripture.api.bible/v1/bibles/{bible_id}/passages/{passage_id}"
|
||||||
headers = await self.bot.get_shared_api_tokens("api.bible")
|
headers = await self.bot.get_shared_api_tokens("api.bible")
|
||||||
params = {
|
params = {
|
||||||
|
"fums-version": "3",
|
||||||
"content-type": "text",
|
"content-type": "text",
|
||||||
"include-notes": "false",
|
"include-notes": "false",
|
||||||
"include-titles": "false",
|
"include-titles": "false",
|
||||||
|
@ -65,7 +68,6 @@ class Bible(commands.Cog):
|
||||||
"include-verse-numbers": str(include_verse_numbers).lower(),
|
"include-verse-numbers": str(include_verse_numbers).lower(),
|
||||||
"include-verse-spans": "false",
|
"include-verse-spans": "false",
|
||||||
"use-org-id": "false",
|
"use-org-id": "false",
|
||||||
"fums-version": "3",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async with self.session.get(url, headers=headers, params=params) as response:
|
async with self.session.get(url, headers=headers, params=params) as response:
|
||||||
|
@ -236,7 +238,7 @@ class Bible(commands.Cog):
|
||||||
bible_id = await self.config.bible()
|
bible_id = await self.config.bible()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
book_id = await self.translate_book_name(bible_id, book)
|
book_id = await self.translate_book_name(ctx, bible_id, book)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
await ctx.send(str(e))
|
await ctx.send(str(e))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue