fix: version displaying wrong and some shit idk

This commit is contained in:
2026-04-18 13:41:49 +03:00
parent be47e59d97
commit f3682ed87a

View File

@@ -489,6 +489,8 @@ class Limoka(loader.Module):
"New Limoka Version {version} already available. Please update for better performance, bug fixes, and new features.\n" "New Limoka Version {version} already available. Please update for better performance, bug fixes, and new features.\n"
"Press the button below to update the module." "Press the button below to update the module."
), ),
"no_updates_available": "No updates available. You are using the latest version of Limoka.",
"module_update_available": "Notification about module update has been sent, check @{bot}.",
} }
strings_ru = { strings_ru = {
"name": "Limoka", "name": "Limoka",
@@ -611,7 +613,7 @@ class Limoka(loader.Module):
"Нажмите кнопку ниже, чтобы обновить модуль." "Нажмите кнопку ниже, чтобы обновить модуль."
), ),
"no_updates_available": "Нет доступных обновлений. У вас установлена последняя версия Limoka.", "no_updates_available": "Нет доступных обновлений. У вас установлена последняя версия Limoka.",
"module_update_available": "Уведомление об обновлении модуля было отправлено, проверьте {bot}.", "module_update_available": "Уведомление об обновлении модуля было отправлено, проверьте @{bot}.",
"_cls_doc": "Модули теперь в одном месте с простым и удобным поиском!", "_cls_doc": "Модули теперь в одном месте с простым и удобным поиском!",
} }
@@ -680,11 +682,20 @@ class Limoka(loader.Module):
if response.status == 200: if response.status == 200:
version = _parse_version_from_source(await response.text()) version = _parse_version_from_source(await response.text())
if version is not None and version > __version__: if version is not None and version > __version__:
# TODO: TODO markup = InlineKeyboardMarkup(
inline_keyboard=[
[
InlineKeyboardButton(
text=self.strings.get("install_button", "Install"),
callback_data="limoka:update_module"
)
]
]
)
await self.inline.bot.send_message( await self.inline.bot.send_message(
self._tg_id, self._tg_id,
self.strings["update_available"].format(version=version), self.strings["update_available"].format(version='.'.join(str(v) for v in version)),
reply_markup=InlineKeyboardMarkup().add(InlineKeyboardButton("Update Now", callback_data="limoka:update_module")) reply_markup=markup
) )
return True return True
return False return False
@@ -694,7 +705,13 @@ class Limoka(loader.Module):
@loader.callback_handler() @loader.callback_handler()
async def callback_handler(self, call: BotInlineCall): async def callback_handler(self, call: BotInlineCall):
if call.data == "limoka:update_module": if call.data == "limoka:update_module":
await self._install_module_limoka(call) result = await self._install_module_limoka()
call.as_(self.inline.bot)
if result:
await call.answer(f"{self.strings['install_succeeded']}")
else:
await call.answer(f"{self.strings['install_failed']}")
def _create_search_session( def _create_search_session(
self, self,
@@ -1183,18 +1200,17 @@ class Limoka(loader.Module):
else: else:
await call.answer(f"{self.strings['install_succeeded']}", alert=True) await call.answer(f"{self.strings['install_succeeded']}", alert=True)
async def _install_module_limoka(self, call: InlineCall): async def _install_module_limoka(self):
try: try:
loader = self.lookup("Loader") loader = self.lookup("Loader")
await loader.download_and_install(f"{self.config['limokaurl']}Limoka.py") await loader.download_and_install(f"{self.config['limokaurl']}Limoka.py")
logger.info(f"Downloading and installing: {self.config['limokaurl']}Limoka.py") logger.info(f"Downloading and installing: {self.config['limokaurl']}Limoka.py")
if getattr(loader, "fully_loaded", False): if getattr(loader, "fully_loaded", False):
loader.update_modules_in_db() loader.update_modules_in_db()
return True
except Exception: except Exception as e:
await call.answer(f"{self.strings['install_failed']}", alert=True) logger.exception(f"Error updating Limoka module: {e}")
else: return False
await call.answer(f"{self.strings['install_succeeded']}", alert=True)
async def _display_filter_menu(self, call: InlineCall, session: Dict[str, Any]): async def _display_filter_menu(self, call: InlineCall, session: Dict[str, Any]):
query = session["query"] query = session["query"]