diff --git a/CHANGELOG.md b/CHANGELOG.md index 404c423..1f2b0f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,6 @@ ## 🌑 Hikka 1.2.1 - Add termux specific requirements -- Ignore `heroku3` import error on non-heroku platforms - Refactor `heroku.py` app searching algorithm - Refactor postgresql database saving process - Fix heroku restart message not being edited diff --git a/hikka/heroku.py b/hikka/heroku.py index af9f95e..0b5d75a 100644 --- a/hikka/heroku.py +++ b/hikka/heroku.py @@ -14,17 +14,18 @@ from . import utils def publish( - key: str, + key: Optional[str] = None, api_token: Optional[str] = None, create_new: Optional[bool] = True, ): """Push to heroku""" logging.debug("Configuring heroku...") + if key is None: + key = os.environ.get("heroku_api_token") + app, config = get_app(key, api_token, create_new) - # Will be configured later in app - config["hikka_session"] = None config["heroku_api_token"] = key if api_token is not None: @@ -41,7 +42,10 @@ def publish( ] ) - app.install_addon("heroku-postgresql") + if not any( + addon.plan.name.startswith("heroku-buildpack-") for addon in app.addons() + ): + app.install_addon("heroku-postgresql") repo = get_repo() url = app.git_url.replace("https://", f"https://api:{key}@") @@ -71,8 +75,7 @@ def get_app( config = poss_app.config() if api_token is None or ( - config["api_id"] == api_token.ID - and config["api_hash"] == api_token.HASH + config["api_id"] == api_token.ID and config["api_hash"] == api_token.HASH ): return app, config diff --git a/hikka/modules/updater.py b/hikka/modules/updater.py index 5c4824c..27da080 100755 --- a/hikka/modules/updater.py +++ b/hikka/modules/updater.py @@ -288,6 +288,11 @@ class UpdaterMod(loader.Module): os.system("lavhost update") return + if "DYNO" in os.environ: + await self._db.postgre_force_save() + heroku.publish(api_token=main.hikka.api_token, create_new=False) + return + try: msg_obj = await utils.answer(msg_obj, self.strings("downloading")) except Exception: