From e67b98a99972108d69eb15587020489f4ffeae2b Mon Sep 17 00:00:00 2001 From: hikariatama Date: Mon, 30 May 2022 20:16:07 +0000 Subject: [PATCH] Install postgresql, fix session import on heroku --- hikka/heroku.py | 4 +++- hikka/main.py | 20 +------------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/hikka/heroku.py b/hikka/heroku.py index f839d77..4acb40a 100644 --- a/hikka/heroku.py +++ b/hikka/heroku.py @@ -24,7 +24,7 @@ def publish( app, config = get_app(key, api_token, create_new) # Will be configured later in app - config["HIKKA_SESSION"] = None + config["HIKKA_SESSION"] = "None" config["heroku_api_token"] = key if api_token is not None: @@ -41,6 +41,8 @@ def publish( ] ) + app.install_addon("heroku-postgresql") + repo = get_repo() url = app.git_url.replace("https://", f"https://api:{key}@") diff --git a/hikka/main.py b/hikka/main.py index 0700447..02553d3 100755 --- a/hikka/main.py +++ b/hikka/main.py @@ -290,24 +290,6 @@ class Hikka: self._get_api_token() self._get_proxy() - if "DYNO" in os.environ and "HIKKA_SESSION" in os.environ: - try: - client = TelegramClient( - StringSession(os.environ.get("HIKKA_SESSION")), - self.api_token.ID, - self.api_token.HASH, - connection=self.conn, - proxy=self.proxy, - connection_retries=None, - device_model="Hikka", - ) - - client.start() - install_entity_caching(client) - self.clients += [client] - except Exception: - logging.exception("Failed to load session") - def _get_proxy(self): """ Get proxy tuple from --proxy-host, --proxy-port and --proxy-secret @@ -346,7 +328,7 @@ class Hikka: ) ] - if "HIKKA_SESSION" in os.environ: + if os.environ.get("HIKKA_SESSION") not in {None, "None"}: self.sessions += [StringSession(os.environ.get("HIKKA_SESSION"))] def _get_api_token(self):