Add heroku specific update

pull/1/head
hikariatama 2022-06-01 22:27:40 +00:00
parent 071f88db5e
commit f622bf93c8
3 changed files with 14 additions and 7 deletions

View File

@ -3,7 +3,6 @@
## 🌑 Hikka 1.2.1 ## 🌑 Hikka 1.2.1
- Add termux specific requirements - Add termux specific requirements
- Ignore `heroku3` import error on non-heroku platforms
- Refactor `heroku.py` app searching algorithm - Refactor `heroku.py` app searching algorithm
- Refactor postgresql database saving process - Refactor postgresql database saving process
- Fix heroku restart message not being edited - Fix heroku restart message not being edited

View File

@ -14,17 +14,18 @@ from . import utils
def publish( def publish(
key: str, key: Optional[str] = None,
api_token: Optional[str] = None, api_token: Optional[str] = None,
create_new: Optional[bool] = True, create_new: Optional[bool] = True,
): ):
"""Push to heroku""" """Push to heroku"""
logging.debug("Configuring 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) app, config = get_app(key, api_token, create_new)
# Will be configured later in app
config["hikka_session"] = None
config["heroku_api_token"] = key config["heroku_api_token"] = key
if api_token is not None: 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() repo = get_repo()
url = app.git_url.replace("https://", f"https://api:{key}@") url = app.git_url.replace("https://", f"https://api:{key}@")
@ -71,8 +75,7 @@ def get_app(
config = poss_app.config() config = poss_app.config()
if api_token is None or ( if api_token is None or (
config["api_id"] == api_token.ID config["api_id"] == api_token.ID and config["api_hash"] == api_token.HASH
and config["api_hash"] == api_token.HASH
): ):
return app, config return app, config

View File

@ -288,6 +288,11 @@ class UpdaterMod(loader.Module):
os.system("lavhost update") os.system("lavhost update")
return 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: try:
msg_obj = await utils.answer(msg_obj, self.strings("downloading")) msg_obj = await utils.answer(msg_obj, self.strings("downloading"))
except Exception: except Exception: