diff --git a/schedulers/mc_crowdin.py b/schedulers/mc_crowdin.py index c3e98e0b..d7cf38c1 100644 --- a/schedulers/mc_crowdin.py +++ b/schedulers/mc_crowdin.py @@ -1,4 +1,5 @@ import random +import re import traceback from datetime import datetime, timezone from database.local import CrowdinActivityRecords @@ -32,7 +33,11 @@ async def check_crowdin(): if 'error' in get_json: raise Exception(get_json['msg']) for act in get_json['activity']: - m = html2text(act["message"], baseurl=base_url).strip().replace('\n', '') + m = html2text(act["message"], baseurl=base_url).strip() + # Replace newline characters in url + match_url = re.search(r'(https?://[^\s]+)', m) + if match_url: + m = m.replace(match_url.group(0), match_url.group(0).replace('\n', '')) if not any(x in m for x in filter_words): continue if act['count'] == 1: @@ -60,7 +65,11 @@ async def check_crowdin(): elif 'icon-thumbs-down' in content: content = '👎' else: - content = html2text(content, baseurl=base_url).strip().replace('\n', '') + content = html2text(content, baseurl=base_url).strip() + match_url = re.search(r'(https?://[^\s]+)', content) + if match_url: + content = content.replace(match_url.group( + 0), match_url.group(0).replace('\n', '')) identify = {detail['title']: content} identify_.update(identify) identify = f'{act["user_id"]}{str(act['timestamp'])}{m}{