Fix tags error in aiogram

pull/1/head
hikariatama 2022-08-14 21:38:42 +00:00
parent 99f834e4dd
commit 8b04707353
4 changed files with 16 additions and 21 deletions

View File

@ -122,7 +122,7 @@ class Form(InlineUnit):
logger.error("Invalid type for `text`")
return False
text = self._sanitise_text(text)
text = self.sanitise_text(text)
if not isinstance(silent, bool):
logger.error("Invalid type for `silent`")

View File

@ -236,9 +236,11 @@ class List(InlineUnit):
try:
await self.bot.edit_message_text(
inline_message_id=call.inline_message_id,
text=self._units[unit_id]["strings"][
self._units[unit_id]["current_index"]
],
text=self.sanitise_text(
self._units[unit_id]["strings"][
self._units[unit_id]["current_index"]
]
),
reply_markup=self._list_markup(unit_id),
)
await call.answer()

View File

@ -255,7 +255,7 @@ class Utils(InlineUnit):
return reply_markup
def _sanitise_text(self, text: str) -> str:
def sanitise_text(self, text: str) -> str:
"""Replaces all animated emojis in text with normal ones, bc aiogram doesn't support them"""
return re.sub(r"</?emoji.*?>", "", text)
@ -313,7 +313,7 @@ class Utils(InlineUnit):
audio = {"url": audio}
if isinstance(text, str):
text = self._sanitise_text(text)
text = self.sanitise_text(text)
media_params = [
photo is None,

View File

@ -74,16 +74,12 @@ class UpdaterMod(loader.Module):
"origin_cfg_doc": "Git origin URL, for where to update from",
"btn_restart": "🔄 Restart",
"btn_update": "🧭 Update",
"restart_confirm": (
"<emoji document_id='5384612769716774600'>❓</emoji> <b>Are you sure you"
" want to restart?</b>"
),
"restart_confirm": "❓ <b>Are you sure you want to restart?</b>",
"secure_boot_confirm": (
"<emoji document_id='5384612769716774600'>❓</emoji> <b>Are you sure you"
" want to restart in secure boot mode?</b>"
"❓ <b>Are you sure you want to restart in secure boot mode?</b>"
),
"update_confirm": (
"<emoji document_id='5384612769716774600'></emoji> <b>Are you sure you"
"❓ <b>Are you sure you"
" want to update?\n\n<a"
' href="https://github.com/hikariatama/Hikka/commit/{}">{}</a> ⤑ <a'
' href="https://github.com/hikariatama/Hikka/commit/{}">{}</a></b>'
@ -145,16 +141,13 @@ class UpdaterMod(loader.Module):
"origin_cfg_doc": "Ссылка, из которой будут загружаться обновления",
"btn_restart": "🔄 Перезагрузиться",
"btn_update": "🧭 Обновиться",
"restart_confirm": (
"<emoji document_id='5384612769716774600'>❓</emoji> <b>Ты уверен, что"
" хочешь перезагрузиться?</b>"
),
"restart_confirm": "❓ <b>Ты уверен, что хочешь перезагрузиться?</b>",
"secure_boot_confirm": (
"<emoji document_id='5384612769716774600'></emoji> <b>Ты уверен, что"
"❓ <b>Ты уверен, что"
" хочешь перезагрузиться в режиме безопасной загрузки?</b>"
),
"update_confirm": (
"<emoji document_id='5384612769716774600'></emoji> <b>Ты уверен, что"
"❓ <b>Ты уверен, что"
" хочешь обновиться??\n\n<a"
' href="https://github.com/hikariatama/Hikka/commit/{}">{}</a> ⤑ <a'
' href="https://github.com/hikariatama/Hikka/commit/{}">{}</a></b>'
@ -566,7 +559,7 @@ class UpdaterMod(loader.Module):
await self.inline.bot.edit_message_text(
inline_message_id=ms,
text=msg,
text=self.inline.sanitise_text(msg),
)
async def full_restart_complete(self, secure_boot: bool = False):
@ -599,7 +592,7 @@ class UpdaterMod(loader.Module):
await self.inline.bot.edit_message_text(
inline_message_id=ms,
text=msg,
text=self.inline.sanitise_text(msg),
)