Skip to content

Commit 6d989de

Browse files
committed
0.7611 - parsing hotfixes for notifications
1 parent 26ad4ae commit 6d989de

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ If you run into any issues, consult the logs or reach out on the repository's [I
240240
---
241241

242242
# Changelog
243+
- v0.7611 - Parsing hotfix for notifications
243244
- v0.761 - **Timed notifications / user reminders**
244245
- Brand-new feature: users can set timed reminders (alerts) by requesting reminders that the bot stores in an SQLite database. A separate poller picks them up as soon as they are due, and the bot automatically notifies the user on set times.
245246
- The custom function calling view action can also list your recently passed or deleted reminders (configurable in `[Reminders]` -> `ShowPastRemindersCount`).

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99
#
1010
# version of this program
11-
version_number = "0.761"
11+
version_number = "0.7611"
1212

1313
# Add the project root directory to Python's path
1414
import sys

src/text_message_handler.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# github.com/FlyingFathead/TelegramBot-OpenAI-API/
44
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55

6+
import re
67
import configparser
78
import os
89
import sys
@@ -1157,7 +1158,7 @@ async def handle_message(bot, update: Update, context: CallbackContext, logger)
11571158
raw_result = await handle_view_reminders(user_id)
11581159
prefix = (
11591160
"Here are the user's alerts. Use the user's language when replying and Telegram-compliant "
1160-
"HTML tags instead of Markdown! List the reminders without their database id #'s to the user, "
1161+
"HTML tags (NOTE: do NOT use <br>!!). Use simple HTML tags (NO <br>, use regular newlines instead). Do NOT use Markdown! List the reminders without their database id #'s to the user, "
11611162
"since the numbers are only for database reference [i.e. to delete/edit, etc]). "
11621163
"If the user wasn't asking about past reminders, don't list them. KÄYTÄ VASTAUKSESSA HTML:ÄÄ. ÄLÄ KÄYTÄ MARKDOWNIA.\n\n"
11631164
)
@@ -1200,6 +1201,9 @@ async def handle_message(bot, update: Update, context: CallbackContext, logger)
12001201
# Provide a fallback message to avoid sending an empty string
12011202
final_reply = "🤔"
12021203

1204+
# strip <br> tags JIC
1205+
final_reply = re.sub(r'<br\s*/?>', '\n', final_reply, flags=re.IGNORECASE)
1206+
12031207
# log & send
12041208
bot.log_message(
12051209
message_type='Bot',
@@ -1585,6 +1589,10 @@ def split_message(message, max_length=4000):
15851589
def sanitize_html(content):
15861590
soup = BeautifulSoup(content, 'html.parser')
15871591

1592+
# # Replace <br> with newline (or just delete them if you prefer)
1593+
# for br in soup.find_all("br"):
1594+
# br.replace_with("\n")
1595+
15881596
# Remove unsupported tags
15891597
for tag in soup.find_all():
15901598
if tag.name not in ['b', 'i', 'u', 's', 'a', 'code', 'pre']:

0 commit comments

Comments
 (0)