fix max lenght message

This commit is contained in:
sam 2023-02-03 10:21:56 +04:00
parent 19af8cdbed
commit 6b3ef3d102
3 changed files with 5 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
datetime.json
# ---> Python # ---> Python
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/

View File

@ -1 +1 @@
"2022-06-24 22:11:28.713372" "2023-02-01 22:11:28.713372"

View File

@ -35,6 +35,8 @@ def main():
while row: while row:
soup = BeautifulSoup(row[2], features="html.parser") soup = BeautifulSoup(row[2], features="html.parser")
textNews = soup.get_text('\n').replace("\n\n\n\n", "\n").replace("\n\n\n", "\n").replace("\n\n", "\n") textNews = soup.get_text('\n').replace("\n\n\n\n", "\n").replace("\n\n\n", "\n").replace("\n\n", "\n")
if len(textNews) > 3000:
textNews = textNews[:3000] + '...'
params = {'chat_id': messageTo.get('is'), params = {'chat_id': messageTo.get('is'),
'text': f'{row[1]}\n{textNews}\nhttp://is.ulstu.ru/News/ShowNews/{row[0]}'} 'text': f'{row[1]}\n{textNews}\nhttp://is.ulstu.ru/News/ShowNews/{row[0]}'}
requests.get('https://api.telegram.org/bot5567223643:AAG6DYNUNq7BNqm7-pI2p-SdvEmAKielViE/sendMessage', requests.get('https://api.telegram.org/bot5567223643:AAG6DYNUNq7BNqm7-pI2p-SdvEmAKielViE/sendMessage',