фикс войсов

This commit is contained in:
Sergey 2020-10-08 22:39:39 +03:00
parent de5d0c91f0
commit 298140d884

View File

@ -606,13 +606,14 @@ async def process_message(msg, token=None, is_multichat=None, vk_chat_id=None, u
body += first_text_attach['content'] body += first_text_attach['content']
attaches_scheme.remove(first_text_attach) attaches_scheme.remove(first_text_attach)
first_voice_attach = next( # ТК у некоторых войсов транскрипт не происходит, то мы можем их потерять. Так делать больше не будем.
(attach for attach in attaches_scheme if attach and attach['type'] == 'audio_message'), # first_voice_attach = next(
None) # (attach for attach in attaches_scheme if attach and attach['type'] == 'audio_message'),
if first_voice_attach: # None)
# Будем отправлять только те войсы, в которых завершен транскрипт сообщений # if first_voice_attach:
if first_voice_attach.get('transcript_state') != 'done': # # Будем отправлять только те войсы, в которых завершен транскрипт сообщений
return # if first_voice_attach.get('transcript_state') != 'done':
# return
if body_parts: if body_parts:
for body_part in range(len(body_parts)): for body_part in range(len(body_parts)):
@ -830,9 +831,7 @@ async def process_attachment(attachment, token=None):
res = {'content': voice_url, 'type': 'audio_message'} res = {'content': voice_url, 'type': 'audio_message'}
if attachment[atype].get('transcript'): if attachment[atype].get('transcript'):
res['transcript'] = attachment[atype]['transcript'] return {'content': f'<i>Войс:</i>{atype[atype]["transcript"]}', 'type': 'text'}
if attachment[atype].get('transcript_state'):
res['transcript_state'] = attachment[atype]['transcript_state']
return res return res
elif atype == 'audio': elif atype == 'audio':
@ -925,7 +924,7 @@ async def process_attachment(attachment, token=None):
elif atype == 'doc': elif atype == 'doc':
ext = attachment[atype]['ext'] ext = attachment[atype]['ext']
if ext == 'gif': if ext == 'gif':
size = attachment[atype]['preview']['video']['file_size'] size = attachment[atype]['file_size']
gif_url = attachment[atype]['url'] + '&mp4=1' gif_url = attachment[atype]['url'] + '&mp4=1'
if size > MAX_FILE_SIZE: if size > MAX_FILE_SIZE:
return {'content': f'<a href="{gif_url}">GIF</a>', 'type': 'text'} return {'content': f'<a href="{gif_url}">GIF</a>', 'type': 'text'}