This commit is contained in:
user 2024-04-05 16:43:49 +03:00
parent 8ad43043da
commit 946b098867
3 changed files with 15 additions and 5 deletions

View File

@ -75,4 +75,4 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
traceback.print_exc() traceback.print_exc()
return await query.answer([]) return await query.answer([])
router.inline_query.register(t_inline_query_node_content) router.inline_query.register(t_inline_query_node_content, lambda: True)

View File

@ -4,6 +4,7 @@ from app.core.logger import make_log
from app.core._utils.tg_process_template import tg_process_template from app.core._utils.tg_process_template import tg_process_template
from app.core._config import PROJECT_HOST, CLIENT_TELEGRAM_BOT_USERNAME from app.core._config import PROJECT_HOST, CLIENT_TELEGRAM_BOT_USERNAME
from app.core._keyboards import get_inline_keyboard from app.core._keyboards import get_inline_keyboard
from app.core.models.messages import KnownTelegramMessage
from aiogram.types import URLInputFile from aiogram.types import URLInputFile
import json import json
@ -88,6 +89,14 @@ class PlayerTemplates:
extra_buttons = [] extra_buttons = []
make_log("TG-Player", f"Send content {content_type} ({content_encoding}) to chat {self._chat_id}. {cd_log}") make_log("TG-Player", f"Send content {content_type} ({content_encoding}) to chat {self._chat_id}. {cd_log}")
for kmsg in self.db_session.query(KnownTelegramMessage).filter_by(
content_id=content.id,
chat_id=self._chat_id,
message_type=f'content/{content_type}',
deleted=False
).all():
await self.delete_message(kmsg.message_id)
return await tg_process_template( return await tg_process_template(
self, text, message_id=message_id, **template_kwargs, self, text, message_id=message_id, **template_kwargs,
keyboard=get_inline_keyboard([*inline_keyboard_array, *extra_buttons]) if inline_keyboard_array else None, keyboard=get_inline_keyboard([*inline_keyboard_array, *extra_buttons]) if inline_keyboard_array else None,
@ -97,3 +106,4 @@ class PlayerTemplates:
) )

View File

@ -148,7 +148,7 @@ class Wrapped_CBotChat(T, PlayerTemplates):
file_id, file_id,
**kwargs **kwargs
) )
return await self.return_result(r, message_type=message_type, message_meta=message_meta) return await self.return_result(r, message_type=message_type, message_meta=message_meta, content_id=content_id)
except Exception as e: except Exception as e:
make_log(self, f"Error sending photo to {self._chat_id}. Error: {e}", level='warning') make_log(self, f"Error sending photo to {self._chat_id}. Error: {e}", level='warning')
return None return None
@ -162,7 +162,7 @@ class Wrapped_CBotChat(T, PlayerTemplates):
file_id, file_id,
**kwargs **kwargs
) )
return await self.return_result(r, message_type=message_type, message_meta=message_meta) return await self.return_result(r, message_type=message_type, message_meta=message_meta, content_id=content_id)
except Exception as e: except Exception as e:
make_log(self, f"Error sending document to {self._chat_id}. Error: {e}", level='warning') make_log(self, f"Error sending document to {self._chat_id}. Error: {e}", level='warning')
return None return None
@ -176,7 +176,7 @@ class Wrapped_CBotChat(T, PlayerTemplates):
file_id, file_id,
**kwargs **kwargs
) )
return await self.return_result(r, message_type=message_type, message_meta=message_meta) return await self.return_result(r, message_type=message_type, message_meta=message_meta, content_id=content_id)
except Exception as e: except Exception as e:
make_log(self, f"Error sending video to {self._chat_id}. Error: {e}", level='warning') make_log(self, f"Error sending video to {self._chat_id}. Error: {e}", level='warning')
return None return None
@ -190,7 +190,7 @@ class Wrapped_CBotChat(T, PlayerTemplates):
file_id, file_id,
**kwargs **kwargs
) )
return await self.return_result(r, message_type=message_type, message_meta=message_meta) return await self.return_result(r, message_type=message_type, message_meta=message_meta, content_id=content_id)
except Exception as e: except Exception as e:
make_log(self, f"Error sending audio to {self._chat_id}. Error: {e}", level='warning') make_log(self, f"Error sending audio to {self._chat_id}. Error: {e}", level='warning')
return None return None