Compare commits

..

No commits in common. "a0e1aaa7796d55ecc55871abdcf5a968fb8c6f30" and "3097594482e704d09d2bc77ce05ff630305b4249" have entirely different histories.

3 changed files with 4 additions and 31 deletions

View File

@ -2,8 +2,6 @@ import os
from telegram.ext import ConversationHandler, CommandHandler, MessageHandler, filters, CallbackQueryHandler, CallbackContext
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, InputMediaPhoto
import models
from telegram.constants import ParseMode
# ACTION_CHOICE, DATE_ENTRY, ADD_CONTENT = range(3)
MEMORY_CHOICE = range(1)
@ -76,15 +74,13 @@ class MemoryHandler(BaseHandler):
caption=
f"On {chosen_match.date_pretty}, "
f"{chosen_match.author} wrote: \n"
f"{chosen_match.spoiler_text}",
parse_mode=ParseMode.HTML
f"{chosen_match.text}"
)
else:
await query.edit_message_text(
f"On {chosen_match.date_pretty}, "
f"{chosen_match.author} wrote: \n"
f"{chosen_match.spoiler_text}",
parse_mode=ParseMode.HTML
f"{chosen_match.text}"
)
return ConversationHandler.END

View File

@ -1,5 +1,4 @@
from datetime import time, timedelta, timezone, datetime, date
from telegram.constants import ParseMode
import os
from peewee import fn
import logging
@ -49,8 +48,7 @@ class RandomMemoryJob():
caption =
f"On {chosen_entry.date_pretty}, "
f"{chosen_entry.author} wrote: \n"
f"{chosen_entry.spoiler_text}",
parse_mode=ParseMode.HTML
f"{chosen_entry.text}"
)
else:
await self.bot.send_message(
@ -58,7 +56,6 @@ class RandomMemoryJob():
text =
f"On {chosen_entry.date_pretty}, "
f"{chosen_entry.author} wrote: \n"
f"{chosen_entry.spoiler_text}",
parse_mode=ParseMode.HTML
f"{chosen_entry.text}"
)

View File

@ -1,6 +1,5 @@
from peewee import *
from pathlib import Path
import re
import os
import datetime
@ -61,25 +60,6 @@ class JournalEntry(BaseModel):
except ValueError: #fck windows
return self.date.strftime('%a, %d. %b %Y')
@property
def spoiler_text(self) -> str:
"""Returns the text with all the frisky details hidden away"""
new_text = self.text.replace("<", "&lt;").replace(">", "&gt;").replace("&", "&amp;")
pattern = re.compile(
"("
"(((?<=(\.|\!|\?)\s)[A-Z])|(^[A-Z]))" # beginning of a sentence
"([^\.\!\?])+" # any character being part of a sentence
"\:\)" # the smiley
"([^\.\!\?])*" # continuation of sentence
"(\.|\!|\?|\,|$)" # end of the sentence
")"
)
matches = pattern.findall(new_text)
for match in matches:
group_to_replace = match[0]
new_text = new_text.replace(group_to_replace, f"<tg-spoiler>{group_to_replace}</tg-spoiler>")
return new_text
def set_db(db_path):
db.initialize(SqliteDatabase(db_path))