Fix Arch pkg and AUR pkg replace

This commit is contained in:
deadcade 2022-08-29 14:38:41 +02:00
parent 0ae0720663
commit 96c7236b23
1 changed files with 4 additions and 4 deletions

View File

@ -462,15 +462,15 @@ async def message_callback(room: nio.MatrixRoom, event: nio.RoomMessageText) ->
if part.startswith("r/"):
new_body = new_body.replace(part, f"<a href=\"https://reddit.com/{part}\">{part}</a>")
if event.body.count("{pkg|") > 0:
for part in event.body.split("{pkg|"):
for part in event.body.split("{pkg|")[1:]:
if "}" in part:
pkg = part.split("}")[0]
new_body = new_body.replace(part, "<a href=\"https://archlinux.org/packages/?name=" + pkg + "\">" + pkg + "</a>")
new_body = new_body.replace("{pkg|" + pkg + "}", "<a href=\"https://archlinux.org/packages/?name=" + pkg + "\">" + pkg + "</a>")
if event.body.count("{aur|") > 0:
for part in event.body.split("{aur|"):
for part in event.body.split("{aur|")[1:]:
if "}" in part:
pkg = part.split("}")[0]
new_body = new_body.replace(part, "<a href=\"https://aur.archlinux.org/packages?K=" + pkg + "\">" + pkg + "</a>")
new_body = new_body.replace("{aur|" + part + "}", "<a href=\"https://aur.archlinux.org/packages?K=" + pkg + "\">" + pkg + "</a>")
# If anything was changed processing the message, edit it
if not new_body == orig_body: