Fix Arch pkg and AUR pkg link replacer not working without spaces
This commit is contained in:
parent
a592871047
commit
0ae0720663
1 changed files with 6 additions and 6 deletions
12
main.py
12
main.py
|
@ -462,14 +462,14 @@ async def message_callback(room: nio.MatrixRoom, event: nio.RoomMessageText) ->
|
||||||
if part.startswith("r/"):
|
if part.startswith("r/"):
|
||||||
new_body = new_body.replace(part, f"<a href=\"https://reddit.com/{part}\">{part}</a>")
|
new_body = new_body.replace(part, f"<a href=\"https://reddit.com/{part}\">{part}</a>")
|
||||||
if event.body.count("{pkg|") > 0:
|
if event.body.count("{pkg|") > 0:
|
||||||
for part in event.body.split(" "):
|
for part in event.body.split("{pkg|"):
|
||||||
if part.startswith("{pkg|") and part.endswith("}"):
|
if "}" in part:
|
||||||
pkg = part.split('|')[1].rstrip('}')
|
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(part, "<a href=\"https://archlinux.org/packages/?name=" + pkg + "\">" + pkg + "</a>")
|
||||||
if event.body.count("{aur|") > 0:
|
if event.body.count("{aur|") > 0:
|
||||||
for part in event.body.split(" "):
|
for part in event.body.split("{aur|"):
|
||||||
if part.startswith("{aur|") and part.endswith("}"):
|
if "}" in part:
|
||||||
pkg = part.split('|')[1].rstrip('}')
|
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(part, "<a href=\"https://aur.archlinux.org/packages?K=" + pkg + "\">" + pkg + "</a>")
|
||||||
|
|
||||||
# If anything was changed processing the message, edit it
|
# If anything was changed processing the message, edit it
|
||||||
|
|
Loading…
Reference in a new issue