Skip to content

Commit

Permalink
Fix telegram message formatting (#488)
Browse files Browse the repository at this point in the history
1. Removed the `<pre></pre>` tag
2. Change the 'disable_web_page_preview' to false to avoid too many invalid infomation 避免过多的无效信息干扰

Signed-off-by: leic4u <[email protected]>
  • Loading branch information
leic4u authored Nov 18, 2023
1 parent 96bb0e1 commit 950b431
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libs/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ async def send2tg(self, tg_token, title, content):
title_sp[1] = '-'.join(title1)
title = ' '.join(title_sp)

content = content.replace('\\r\\n', '</pre>\n<pre>')
d = {'chat_id': str(chat_id), 'text': '<b>' + title + '</b>' + '\n<pre>' + content + '</pre>\n' +
'------<a href="' + picurl + '">QD提醒</a>------', 'disable_web_page_preview': 'false', 'parse_mode': 'HTML'}
content = content.replace('\\r\\n', '\n')
d = {'chat_id': str(chat_id), 'text': '<b>' + title + '</b>' + '\n' + content + '\n' +
'------<a href="' + picurl + '">QD提醒</a>------', 'disable_web_page_preview': 'true', 'parse_mode': 'HTML'}
if proxy:
async with aiohttp.ClientSession(conn_timeout=config.connect_timeout) as session:
async with session.post(link, json=d, verify_ssl=False, proxy=proxy, timeout=config.request_timeout) as res:
Expand Down

0 comments on commit 950b431

Please sign in to comment.