Add option to exclude links from the read notes

This commit is contained in:
Fotoente 2022-05-08 10:44:33 +02:00
parent fb42d536d2
commit 956e9abe59
2 changed files with 9 additions and 0 deletions

View file

@ -5,6 +5,7 @@ token=[token here]
cw=[content warning here; make "none" for no cw]
[markov]
exclude_links=false
min_notes=5000
max_notes=10000
includeReplies=true

View file

@ -84,6 +84,11 @@ def get_notes(**kwargs):
except (TypeError, ValueError, configparser.NoOptionError):
exclude_nsfw = True
try:
exclude_links = check_str_to_bool(config.get("markov", "exclude_links"))
except (TypeError, ValueError, configparser.NoOptionError):
exclude_links = False
run = True
oldnote = ""
@ -146,6 +151,9 @@ def get_notes(**kwargs):
content = content.replace("::", ": :") # Break long emoji chains
content = content.replace("@", "@" + chr(8203))
if exclude_links:
content = regex.sub(r"(http|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))", "", content)
note_dict = {"id": element["id"], "text": content, "timestamp": lastTimestamp, "user_id": userid}
return_list.append(note_dict)