Skip to content

Commit

Permalink
Removed random characters from the verse of the day message
Browse files Browse the repository at this point in the history
This should fix the errors with sending the verse of the day message in the MSG version of the bible since the asterisks were causing parsing issues in markdown.

Also added more information to the comment in the verse_match.pyx file, above the line that removes random characters, to state that the line is removing asterisks from the MSG version of the bible.

I feel like I should have used HTML parsing instead of markdown, it's such a pain to be replacing all the markdown reserved characters with something else or removing them entirely.
  • Loading branch information
hankertrix committed Oct 6, 2023
1 parent 7912b73 commit 362d212
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ async def get_verse_of_the_day(version = "NIV") -> Tuple[str]:
async with httpx.AsyncClient() as session:

# Gets the verse of the day page from bible gateway
verse_of_the_day_page = await session.get(f"https://www.biblegateway.com/reading-plans/verse-of-the-day/next?version={version}")
verse_of_the_day_page = await session.get(f"https://www.biblegateway.com/reading-plans/verse-of-the-day/2023/09/28?version=MSG")

# Add line breaks to the end of every heading
text = re.sub(r"</h[1-6]>", lambda match: f"\n{match.group()}" , verse_of_the_day_page.text)
Expand Down Expand Up @@ -569,6 +569,9 @@ async def get_verse_of_the_day(version = "NIV") -> Tuple[str]:
# The verse message containing the verse name and the verse of the day
verse_msg = "\n\n".join(verse_msg_list).strip()

# Remove random characters from the verse message, like the asterisks in the MSG version of the bible
verse_msg = re.sub("[¶*] *", "", verse_msg)

# If the verse message is nothing, change the version to NIV
if verse_msg == "":
version = "NIV"
Expand Down
2 changes: 1 addition & 1 deletion verse_match.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ cdef class VerseMatch:
# Gets rid of - at the back of the verses
verses = verses.strip("")

# Removes other random characters
# Removes other random characters, like the asterisks in the MSG version of the bible
verses = re.sub("[¶*] *", "", verses)

# Fixes all the hebrew characters being right to left
Expand Down

0 comments on commit 362d212

Please sign in to comment.