Updated run script and require aiohttp optional recommended dependencies.

This commit is contained in:
RedoX 2021-07-04 11:01:01 +00:00
parent 8c5b73c3a8
commit eba3054a5c
5 changed files with 29 additions and 38 deletions

View File

@ -3,8 +3,8 @@ import os
from telethon.sync import TelegramClient from telethon.sync import TelegramClient
from telethon.sessions import StringSession from telethon.sessions import StringSession
api_id = int(os.environ.get('API_ID') or input("Enter your API_ID: ")) api_id = int(os.getenv('API_ID') or input("Enter your API_ID: "))
api_hash = os.environ.get('API_HASH') or input("Enter your API_HASH: ") api_hash = os.getenv('API_HASH') or input("Enter your API_HASH: ")
with TelegramClient(StringSession(), api_id, api_hash) as client: with TelegramClient(StringSession(), api_id, api_hash) as client:
print(client.session.save()) print("\n" + client.session.save())

8
poetry.lock generated
View File

@ -134,7 +134,7 @@ python-versions = "*"
[[package]] [[package]]
name = "python-dotenv" name = "python-dotenv"
version = "0.17.1" version = "0.18.0"
description = "Read key-value pairs from a .env file and set them as environment variables" description = "Read key-value pairs from a .env file and set them as environment variables"
category = "main" category = "main"
optional = false optional = false
@ -192,7 +192,7 @@ multidict = ">=4.0"
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.8" python-versions = "^3.8"
content-hash = "92e2ad6db6a5f87406f6790eb064f5c943fc3b24e60ad02586aae3790fce3bee" content-hash = "422fb1b4353f5fa977e395da869403ba1478d48b4e147489f404bfcab97a232f"
[metadata.files] [metadata.files]
aiohttp = [ aiohttp = [
@ -356,8 +356,8 @@ pyasn1 = [
{file = "pyasn1-0.4.8.tar.gz", hash = "sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba"}, {file = "pyasn1-0.4.8.tar.gz", hash = "sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba"},
] ]
python-dotenv = [ python-dotenv = [
{file = "python-dotenv-0.17.1.tar.gz", hash = "sha256:b1ae5e9643d5ed987fc57cc2583021e38db531946518130777734f9589b3141f"}, {file = "python-dotenv-0.18.0.tar.gz", hash = "sha256:effaac3c1e58d89b3ccb4d04a40dc7ad6e0275fda25fd75ae9d323e2465e202d"},
{file = "python_dotenv-0.17.1-py2.py3-none-any.whl", hash = "sha256:00aa34e92d992e9f8383730816359647f358f4a3be1ba45e5a5cefd27ee91544"}, {file = "python_dotenv-0.18.0-py2.py3-none-any.whl", hash = "sha256:dd8fe852847f4fbfadabf6183ddd4c824a9651f02d51714fa075c95561959c7d"},
] ]
rsa = [ rsa = [
{file = "rsa-4.7.2-py3-none-any.whl", hash = "sha256:78f9a9bf4e7be0c5ded4583326e7461e3a3c5aae24073648b4bdfa797d78c9d2"}, {file = "rsa-4.7.2-py3-none-any.whl", hash = "sha256:78f9a9bf4e7be0c5ded4583326e7461e3a3c5aae24073648b4bdfa797d78c9d2"},

View File

@ -1,4 +1,4 @@
aiohttp aiohttp[speedups]
aiohttp-jinja2 aiohttp-jinja2
telethon>=1.16.4 telethon>=1.16.4
cryptg cryptg

View File

@ -8,26 +8,26 @@ load_dotenv() # take environment variables from .env.
# os.system("alias python3=python") # os.system("alias python3=python")
def runSetup(): def runSetup():
def alert(missing="API_ID , API_HASH"): def alert(missing):
print( print(
f"\nCopy your {missing} and save it into Secrets(Environment variables) Sidebar!\n" f"\nCopy your {missing} and save it into Secrets (Environment variables) Sidebar!\n"
) )
api_id = os.getenv("API_ID") req_env_vars = ["API_ID", "API_HASH", "INDEX_SETTINGS"]
if api_id is None:
alert() for env_var in req_env_vars:
env_value = os.getenv(env_var)
if env_value is None:
alert(env_var)
return return
session_string = os.getenv("SESSION_STRING") if os.getenv("SESSION_STRRING") is None:
if session_string is None:
os.system("python app/generate_session_string.py") os.system("python app/generate_session_string.py")
alert(missing="SESSION_STRING") print("\nCopy your SESSION_STRING from above and save it into Secrets (Environment variables) Sidebar!")
return return
os.system("python -m app") os.system("python -m app")
if __name__ == "__main__": if __name__ == "__main__":
runSetup() runSetup()

View File

@ -1,39 +1,30 @@
import os import os
# from dotenv import load_dotenv
# load_dotenv() # take environment variables from .env.
# Code of your application, which uses environment variables (e.g. from `os.environ` or # Code of your application, which uses environment variables (e.g. from `os.environ` or
# `os.getenv`) as if they came from the actual environment. # `os.getenv`) as if they came from the actual environment.
os.system("alias python3=python") os.system("alias python3=python")
def runSetup(): def runSetup():
def alert(missing="API_ID , API_HASH"): def alert(missing):
print( print(
f"\nCopy your {missing} and save it into Secrets(Environment variables) Sidebar!\n" f"\nCopy your {missing} and save it into Secrets (Environment variables) Sidebar!\n"
) )
req_env_vars = ["API_ID", "API_HASH", "INDEX_SETTINGS"] req_env_vars = ["API_ID", "API_HASH", "INDEX_SETTINGS"]
misssing_envs = False
for env_var in req_env_vars:
env_value = os.getenv(env_var )
if env_value is None:
misssing_envs = True
alert(env_var)
if misssing_envs: for env_var in req_env_vars:
env_value = os.getenv(env_var)
if env_value is None:
alert(env_var)
return return
session_string = os.getenv("SESSION_STRING") if os.getenv("SESSION_STRING") is None:
if session_string is None:
os.system("python app/generate_session_string.py") os.system("python app/generate_session_string.py")
alert(missing="SESSION_STRING") print("\nCopy your SESSION_STRING from above and save it into Secrets (Environment variables) Sidebar!")
return return
os.system("python -m app") os.system("python -m app")
if __name__ == "__main__": if __name__ == "__main__":
runSetup() runSetup()