Replace Matrix mentions with Telegram mentions (ping)
This commit is contained in:
parent
b0aeb11e8a
commit
09945d75cc
55
.gitignore
vendored
55
.gitignore
vendored
@ -122,33 +122,36 @@ Session.vim
|
|||||||
tags
|
tags
|
||||||
|
|
||||||
|
|
||||||
|
#VSCode
|
||||||
|
.vscode
|
||||||
|
|
||||||
### macOS ###
|
### macOS ###
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
.AppleDouble
|
.AppleDouble
|
||||||
.LSOverride
|
.LSOverride
|
||||||
|
|
||||||
# Icon must end with two \r
|
# Icon must end with two \r
|
||||||
Icon
|
Icon
|
||||||
|
|
||||||
|
|
||||||
# Thumbnails
|
# Thumbnails
|
||||||
._*
|
._*
|
||||||
|
|
||||||
# Files that might appear in the root of a volume
|
# Files that might appear in the root of a volume
|
||||||
.DocumentRevisions-V100
|
.DocumentRevisions-V100
|
||||||
.fseventsd
|
.fseventsd
|
||||||
.Spotlight-V100
|
.Spotlight-V100
|
||||||
.TemporaryItems
|
.TemporaryItems
|
||||||
.Trashes
|
.Trashes
|
||||||
.VolumeIcon.icns
|
.VolumeIcon.icns
|
||||||
.com.apple.timemachine.donotpresent
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
# Directories potentially created on remote AFP share
|
# Directories potentially created on remote AFP share
|
||||||
.AppleDB
|
.AppleDB
|
||||||
.AppleDesktop
|
.AppleDesktop
|
||||||
Network Trash Folder
|
Network Trash Folder
|
||||||
Temporary Items
|
Temporary Items
|
||||||
.apdisk
|
.apdisk
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
config.json
|
config.json
|
||||||
|
@ -12,6 +12,7 @@ from datetime import datetime
|
|||||||
from time import time
|
from time import time
|
||||||
from urllib.parse import unquote, quote, urlparse, parse_qs
|
from urllib.parse import unquote, quote, urlparse, parse_qs
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
import re
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from aiohttp import web, ClientSession
|
from aiohttp import web, ClientSession
|
||||||
@ -97,6 +98,7 @@ def format_matrix_msg(form, username, content):
|
|||||||
:return: The formatted string.
|
:return: The formatted string.
|
||||||
"""
|
"""
|
||||||
if 'format' in content and content['format'] == 'org.matrix.custom.html':
|
if 'format' in content and content['format'] == 'org.matrix.custom.html':
|
||||||
|
re.sub("<a href=\"https://matrix.to/#/@telegram_([0-9]+):{}\">(.+?)</a>".format(MATRIX_HOST_BARE), "<a href=\"tg://user?id=\\1\">\\2</a>", content['formatted_body'])
|
||||||
sanitized = sanitize_html(content['formatted_body'])
|
sanitized = sanitize_html(content['formatted_body'])
|
||||||
return html.escape(form).format(username, sanitized), 'HTML'
|
return html.escape(form).format(username, sanitized), 'HTML'
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user