From 05c36af560b30ff47c931bc88e8846b4e7d9b57e Mon Sep 17 00:00:00 2001 From: "ZetGo | Aleksej K." Date: Thu, 5 Jun 2025 23:29:24 +0300 Subject: [PATCH 1/8] [test] logger ignoring NetworkError | Backup period buttons fix(?) --- heroku/log.py | 6 ++++++ heroku/modules/heroku_backup.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/heroku/log.py b/heroku/log.py index bf09a48..6b816ae 100644 --- a/heroku/log.py +++ b/heroku/log.py @@ -527,6 +527,12 @@ rotating_handler.setFormatter(_main_formatter) def init(): + class NoFetchUpdatesFilter(logging.Filter): + def filter(self, record: logging.LogRecord) -> bool: + msg = record.getMessage() + return "Failed to fetch updates" not in msg + + logging.getLogger("aiogram.dispatcher").addFilter(NoFetchUpdatesFilter()) handler = logging.StreamHandler() handler.setLevel(logging.INFO) handler.setFormatter(_main_formatter) diff --git a/heroku/modules/heroku_backup.py b/heroku/modules/heroku_backup.py index 066041d..e3371a4 100644 --- a/heroku/modules/heroku_backup.py +++ b/heroku/modules/heroku_backup.py @@ -80,7 +80,7 @@ class HerokuBackupMod(loader.Module): async def _set_backup_period(self, call: BotInlineCall, value: int): if not value: self.set("period", "disabled") - await call.answer(self.strings("never"), show_alert=True) + await self.inline.bot(call.answer(self.strings("never"), show_alert=True)) await call.delete() return From 32fa27e9ad62eeb33b3b09c29be82b344e9d63ea Mon Sep 17 00:00:00 2001 From: "ZetGo | Aleksej K." Date: Fri, 6 Jun 2025 00:40:19 +0300 Subject: [PATCH 2/8] [+] Fixing a heroku folder creation | Update language strings for quickstart guide | Requirements fix thx rilliat.t.me --- heroku/langpacks/de.yml | 2 +- heroku/langpacks/en.yml | 2 +- heroku/langpacks/ua.yml | 2 +- heroku/modules/updater.py | 2 +- optional_requirements.txt | 1 - requirements.txt | 1 + 6 files changed, 5 insertions(+), 5 deletions(-) diff --git a/heroku/langpacks/de.yml b/heroku/langpacks/de.yml index ccdeb2a..3e2e495 100644 --- a/heroku/langpacks/de.yml +++ b/heroku/langpacks/de.yml @@ -556,7 +556,7 @@ translate: _cmd_doc_tr: "[Sprache] [Text] - Übersetzt den Text" quickstart: - base: "🪐 Hallo. Ihr Heroku-Userbot ist jetzt installiert.\n\n❓ Benötigen Sie Hilfe? Nehmen Sie an unserem Support-Chat teil. Wir helfen jedem.\n\n💁‍♀️ Kurzanleitung:\n\n1️⃣ Schreiben Sie .help, um die Liste der Module anzuzeigen\n2️⃣ Schreiben Sie .help , um die Beschreibung des Moduls anzuzeigen\n3️⃣ Schreiben Sie .dlmod um ein Modul von einem Link zu laden\n4️⃣ Schreiben .loadmod als Antwort auf eine Datei, um ein Modul daraus zu laden\n5️⃣ Schreiben .unloadmod um ein Modul zu entladen\n\n💡 Heroku unterstützt Module von Heroku, Friendly-Telegram und GeekTG sowie seine eigenen.\n" + base: "🪐 Hallo. Ihr Heroku-Userbot ist jetzt installiert.\n\n❓ Benötigen Sie Hilfe? Nehmen Sie an unserem Support-Chat teil. Wir helfen jedem.\n\n💁‍♀️ Kurzanleitung:\n\n1️⃣ Schreiben Sie .help, um die Liste der Module anzuzeigen\n2️⃣ Schreiben Sie .help <Modulname/Befehl>, um die Beschreibung des Moduls anzuzeigen\n3️⃣ Schreiben Sie .dlmod <link> um ein Modul von einem Link zu laden\n4️⃣ Schreiben .loadmod als Antwort auf eine Datei, um ein Modul daraus zu laden\n5️⃣ Schreiben .unloadmod <Modulname< um ein Modul zu entladen\n\n💡 Heroku unterstützt Module von Heroku, Friendly-Telegram und GeekTG sowie seine eigenen.\n" railway: "🚂 Dein Userbot ist auf Railway installiert. Auf dieser Plattform erhältst du nur 500 kostenlose Stunden pro Monat. Wenn das Limit erreicht ist, wird dein Userbot eingefroren. Im nächsten Monat musst du zu https://railway.app gehen und ihn neu starten." lavhost: "✌️ Dein Userbot ist auf lavHost installiert. Trete @lavhost bei, um wichtige Benachrichtigungen und Updates zu erhalten. Alle Fragen zur Plattform sollten in @lavhostchat gestellt werden." language_saved: "🇩🇪 Sprache gespeichert!" diff --git a/heroku/langpacks/en.yml b/heroku/langpacks/en.yml index 1375bc0..9307f33 100644 --- a/heroku/langpacks/en.yml +++ b/heroku/langpacks/en.yml @@ -594,7 +594,7 @@ translate: quickstart: name: "Quickstart" - base: "🪐 Hello. Your Heroku userbot is now installed.\n\n❓ Need help? Join our support chat. We help everyone.\n\n💁‍♀️ Quick Guide:\n\n1️⃣ Write .help to see the list of modules\n2️⃣ Write .help to see the description of the module\n3️⃣ Write .dlmod to load a module from a link\n4️⃣ Write .loadmod in response to a file to load a module from it\n5️⃣ Write .unloadmod to unload a module\n\n💡 Heroku supports modules from Heroku, Friendly-Telegram, and GeekTG, as well as its own.\n" + base: "🪐 Hello. Your Heroku userbot is now installed.\n\n❓ Need help? Join our support chat. We help everyone.\n\n💁‍♀️ Quick Guide:\n\n1️⃣ Write .help to see the list of modules\n2️⃣ Write .help <Module name/command> to see the description of the module\n3️⃣ Write .dlmod <link> to load a module from a link\n4️⃣ Write .loadmod in response to a file to load a module from it\n5️⃣ Write .unloadmod <Module name> to unload a module\n\n💡 Heroku supports modules from Heroku, Friendly-Telegram, and GeekTG, as well as its own.\n" lavhost: "✌️ Your userbot is installed on lavHost. Make sure to join @lavhost for important notifications and updates. All questions regarding the platform should be asked in @lavhostchat." language_saved: "🇬🇧 Language saved!" language: "🇬🇧 English" diff --git a/heroku/langpacks/ua.yml b/heroku/langpacks/ua.yml index 8865733..e1a9404 100644 --- a/heroku/langpacks/ua.yml +++ b/heroku/langpacks/ua.yml @@ -558,7 +558,7 @@ translate: _cmd_doc_tr: "[мова] [текст] - Перекласти текст" quickstart: - base: "🪐 Привет. Твой юзербот Heroku установлен.\n\n❓ Нужна помощь? Вступай в наш чат поддержки. Мы помогаем всем.\n\n💁‍♀️ Быстрый гайд:\n\n1️⃣ Напиши .help чтобы увидеть список модулей\n2️⃣ Напиши .help <Название модуля/команда> чтобы увидеть описание модуля\n3️⃣ Напиши .dlmod <посилання> щоб завантажити модуль із посилання\n4️⃣ Напиши .loadmod відповіддю на файл, щоб завантажити модуль з нього\n5️⃣ Напиши .unloadmod 💡 Heroku підтримує модулі з Heroku, Friendly-Telegram та GeekTG, а також свої власні.\n" + base: "🪐 Привет. Твой юзербот Heroku установлен.\n\n❓ Нужна помощь? Вступай в наш чат поддержки. Мы помогаем всем.\n\n💁‍♀️ Быстрый гайд:\n\n1️⃣ Напиши .help чтобы увидеть список модулей\n2️⃣ Напиши .help <Название модуля/команда> чтобы увидеть описание модуля\n3️⃣ Напиши .dlmod <посилання> щоб завантажити модуль із посилання\n4️⃣ Напиши .loadmod відповіддю на файл, щоб завантажити модуль з нього\n5️⃣ Напиши .unloadmod <Назва модуля> , щоб вивантажити модуль \n\n💡 Heroku підтримує модулі з Heroku, Friendly-Telegram та GeekTG, а також свої власні.\n" railway: "🚂 Ти встановив юзербота на Railway, вітаю!. На цій платформі ти отримуєш лише 500 безкоштовних годин на місяць. Коли ліміт буде досягнуто, твій юзербот буде заморожено. Наступного місяця ти повинен будеш перейти на https://railway.app і перезапустити його." lavhost: "✌️ Ти встановив юзербота на LavHost, вітаю!. Усі новини про хост - @lavhost. Усі питання про хост - @lavhostchat" language_saved: "🇺🇦 Мова збережена!" diff --git a/heroku/modules/updater.py b/heroku/modules/updater.py index bb0b5d7..f2f8500 100644 --- a/heroku/modules/updater.py +++ b/heroku/modules/updater.py @@ -422,7 +422,7 @@ class UpdaterMod(loader.Module): async def _add_folder(self): folders = await self._client(GetDialogFiltersRequest()) - if any(getattr(folder, "title", None) == "heroku" for folder in folders): + if any(getattr(folder, "title", None) == "heroku" for folder in folders.filters): return try: diff --git a/optional_requirements.txt b/optional_requirements.txt index 1c34683..9824778 100644 --- a/optional_requirements.txt +++ b/optional_requirements.txt @@ -1,4 +1,3 @@ -Pillow requests emoji moviepy diff --git a/requirements.txt b/requirements.txt index ff77c39..b23d788 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ heroku-tl-new==1.0.8 pycloudflared==0.2.0 +Pillow # Python 3.9+ \ No newline at end of file From 5f8f69dd5f3002eb57cfe78009eccc10939c6cb2 Mon Sep 17 00:00:00 2001 From: "ZetGo | Aleksej K." Date: Fri, 6 Jun 2025 01:16:00 +0300 Subject: [PATCH 3/8] [+] ending ALL tasks on SIGINT signal --- heroku/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/heroku/main.py b/heroku/main.py index 1859fa4..a18d2fc 100644 --- a/heroku/main.py +++ b/heroku/main.py @@ -1000,6 +1000,9 @@ class Heroku: except: pass for c in self.clients: await c.disconnect() + for task in asyncio.all_tasks(): + if task is not asyncio.current_task(): + task.cancel() def main(self): """Main entrypoint""" From 0731aa4c359976b205fe86e67dc5ad56dcaad7ec Mon Sep 17 00:00:00 2001 From: "ZetGo | Aleksej K." Date: Fri, 6 Jun 2025 01:28:55 +0300 Subject: [PATCH 4/8] [test] Shutdown handler --- heroku/main.py | 48 ++++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/heroku/main.py b/heroku/main.py index a18d2fc..f725ffc 100644 --- a/heroku/main.py +++ b/heroku/main.py @@ -972,37 +972,21 @@ class Heroku: await asyncio.gather(*[self.amain_wrapper(client) for client in self.clients]) - async def _shutdown_handler(self, final: bool = False): - if not final: - logging.info("Ctrl + C....... Bye?") - for client in self.clients: - inline = getattr(client.loader, "inline", None) - if inline: - for t in (inline._task, inline._cleaner_task): - if t: - t.cancel() - await inline._dp.stop_polling() - await inline.bot.session.close() - for c in self.clients: - await c.disconnect() - logging.info("Bye!") - else: - for client in self.clients: - inline = getattr(client.loader, "inline", None) - if inline: - inline._task.cancel() - inline._cleaner_task.cancel() - try: - await inline._dp.stop_polling() - except: pass - try: - await inline.bot.session.close() - except: pass - for c in self.clients: - await c.disconnect() - for task in asyncio.all_tasks(): - if task is not asyncio.current_task(): - task.cancel() + async def _shutdown_handler(self): + for client in self.clients: + inline = getattr(client.loader, "inline", None) + if inline: + for t in (inline._task, inline._cleaner_task): + if t: + t.cancel() + await inline._dp.stop_polling() + await inline.bot.session.close() + for c in self.clients: + await c.disconnect() + for task in asyncio.all_tasks(): + if task is not asyncio.current_task(): + task.cancel() + self.loop.stop() def main(self): """Main entrypoint""" @@ -1013,7 +997,7 @@ class Heroku: try: self.loop.run_until_complete(self._main()) finally: - self.loop.run_until_complete(self._shutdown_handler(True)) + self.loop.run_until_complete(self._shutdown_handler()) herokutl.extensions.html.CUSTOM_EMOJIS = not get_config_key("disable_custom_emojis") From 42f10b6674951f436c133612610f1d7958507428 Mon Sep 17 00:00:00 2001 From: "ZetGo | Aleksej K." Date: Fri, 6 Jun 2025 01:31:38 +0300 Subject: [PATCH 5/8] [test] Final shutdown --- heroku/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku/main.py b/heroku/main.py index f725ffc..10dbd34 100644 --- a/heroku/main.py +++ b/heroku/main.py @@ -996,6 +996,8 @@ class Heroku: ) try: self.loop.run_until_complete(self._main()) + except: + pass finally: self.loop.run_until_complete(self._shutdown_handler()) From 756dc6aa361b1735ecb8808c3e033cf87bebbedb Mon Sep 17 00:00:00 2001 From: "ZetGo | Aleksej K." Date: Fri, 6 Jun 2025 01:58:39 +0300 Subject: [PATCH 6/8] [+] Update preset links | fix folder filtering in updater module --- heroku/modules/presets.py | 14 +++++++------- heroku/modules/quickstart.py | 2 +- heroku/modules/updater.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/heroku/modules/presets.py b/heroku/modules/presets.py index 5b10ae1..2d5bc2b 100644 --- a/heroku/modules/presets.py +++ b/heroku/modules/presets.py @@ -45,10 +45,10 @@ PRESETS = { "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/Complements.py", "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/Compliments.py", "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/mazemod.py", - "https://mods.codrago.top/dice.py", - "https://mods.codrago.top/loli.py", - "https://mods.codrago.top/DoxTool.py", - "https://mods.codrago.top/randomizer.py", + "https://mods.codrago.life/dice.py", + "https://mods.codrago.life/loli.py", + "https://mods.codrago.life/DoxTool.py", + "https://mods.codrago.life/randomizer.py", ], "chat": [ "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/activists.py", @@ -62,8 +62,8 @@ PRESETS = { "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/BanMedia.py", "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/swmute.py", "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/filter.py", - "https://mods.codrago.top/id.py", - "https://mods.codrago.top/clickon.py", + "https://mods.codrago.life/id.py", + "https://mods.codrago.life/clickon.py", ], "service": [ "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/account_switcher.py", @@ -78,7 +78,7 @@ PRESETS = { "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/accounttime.py", "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/searx.py", "https://github.com/amm1edev/ame_repo/raw/refs/heads/main/swmute.py", - "https://mods.codrago.top/modlist.py", + "https://mods.codrago.life/modlist.py", ], "downloaders": [ "https://heta.dan.tatar/musicdl.py", diff --git a/heroku/modules/quickstart.py b/heroku/modules/quickstart.py index ae64462..f1e12a4 100644 --- a/heroku/modules/quickstart.py +++ b/heroku/modules/quickstart.py @@ -93,5 +93,5 @@ class Quickstart(loader.Module): self._db.set(translations.__name__, "lang", lang) await self.allmodules.reload_translations() - await call.answer(self.strings("language_saved")) + await self.inline.bot(call.answer(self.strings("language_saved"))) await call.edit(text=self.text(), reply_markup=self.mark()) diff --git a/heroku/modules/updater.py b/heroku/modules/updater.py index f2f8500..7bb1897 100644 --- a/heroku/modules/updater.py +++ b/heroku/modules/updater.py @@ -428,7 +428,7 @@ class UpdaterMod(loader.Module): try: folder_id = ( max( - (folder for folder in folders if hasattr(folder, "id")), + (folder for folder in folders.filters if hasattr(folder, "id")), key=lambda x: x.id, ).id + 1 From 6b8f48adada160322fa66c67f150a9e4860ec1ff Mon Sep 17 00:00:00 2001 From: "ZetGo | Aleksej K." Date: Fri, 6 Jun 2025 02:19:54 +0300 Subject: [PATCH 7/8] [test] --- CHANGELOG.md | 3 +-- heroku/main.py | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dda6f01..aa16594 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,6 @@ # Heroku Changelog ## 🪐 Heroku 1.7.0 -- First sex with a designer - added banner to ping - added config for emoji in config (.cfg herokuconfig) - fixed close button in .update @@ -21,7 +20,7 @@ - fix close btn - fix native imports - added converting Hikka backups to Heroku -- updatet to aiogram 3.20.0 +- updated to aiogram 3.20.0 - fix some bugs with buttons in inline ## 🪐 Heroku 1.6.8 diff --git a/heroku/main.py b/heroku/main.py index 10dbd34..a42352a 100644 --- a/heroku/main.py +++ b/heroku/main.py @@ -979,8 +979,10 @@ class Heroku: for t in (inline._task, inline._cleaner_task): if t: t.cancel() - await inline._dp.stop_polling() - await inline.bot.session.close() + try: + await inline._dp.stop_polling() + await inline.bot.session.close() + except: pass for c in self.clients: await c.disconnect() for task in asyncio.all_tasks(): From ef2084155178c6d39a3c46072668ad578075be47 Mon Sep 17 00:00:00 2001 From: "ZetGo | Aleksej K." <73279716+ZetGoHack@users.noreply.github.com> Date: Fri, 6 Jun 2025 13:33:59 +0600 Subject: [PATCH 8/8] [+] SIGINT says 'bye!' --- heroku/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku/main.py b/heroku/main.py index a42352a..63b5488 100644 --- a/heroku/main.py +++ b/heroku/main.py @@ -988,6 +988,7 @@ class Heroku: for task in asyncio.all_tasks(): if task is not asyncio.current_task(): task.cancel() + logging.info("Bye!") self.loop.stop() def main(self):