From 09945d75ccf1253f24f4e04da54835bf206a622b Mon Sep 17 00:00:00 2001 From: Max Sandholm Date: Thu, 21 Sep 2017 13:50:17 +0300 Subject: [PATCH] Replace Matrix mentions with Telegram mentions (ping) --- .gitignore | 55 ++++++++++++++++++++++-------------------- telematrix/__init__.py | 2 ++ 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 69815ce..b9bca15 100644 --- a/.gitignore +++ b/.gitignore @@ -122,33 +122,36 @@ Session.vim tags +#VSCode +.vscode + ### macOS ### -*.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk # Config config.json diff --git a/telematrix/__init__.py b/telematrix/__init__.py index bea6220..bdb7154 100644 --- a/telematrix/__init__.py +++ b/telematrix/__init__.py @@ -12,6 +12,7 @@ from datetime import datetime from time import time from urllib.parse import unquote, quote, urlparse, parse_qs from io import BytesIO +import re from PIL import Image from aiohttp import web, ClientSession @@ -97,6 +98,7 @@ def format_matrix_msg(form, username, content): :return: The formatted string. """ if 'format' in content and content['format'] == 'org.matrix.custom.html': + re.sub("(.+?)".format(MATRIX_HOST_BARE), "\\2", content['formatted_body']) sanitized = sanitize_html(content['formatted_body']) return html.escape(form).format(username, sanitized), 'HTML' else: