diff --git a/README.md b/README.md index 30e91ff..f0db9b9 100644 --- a/README.md +++ b/README.md @@ -54,8 +54,6 @@ Fill up rest of the fields. Meaning of each fields are discussed below: - AUTO_DELETE_MESSAGE_DURATION : Interval of time (in seconds), after which the bot deletes it's message (and command message) which is expected to be viewed instantly. Note: Set to -1 to never automatically delete messages - IS_TEAM_DRIVE : (Optional field) Set to "True" if GDRIVE_FOLDER_ID is from a Team Drive else False or Leave it empty. - INDEX_URL : (Optional field) Refer to https://github.com/maple3142/GDIndex/ The URL should not have any trailing '/' -- API_KEY : This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org DO NOT put this in quotes. -- API_HASH : This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org - USER_SESSION_STRING : Session string generated by running: ``` python3 generate_string_session.py @@ -108,9 +106,6 @@ Note: 1 service account can copy around 750gb a day, 1 project makes 100 service A folder named accounts will be created which will contain keys for the service accounts created ``` We highly recommend to zip this folder and store it somewhere safe, so that you do not have to create a new project everytime you want to deploy the bot - -**However** If you lose it anyway, you can redownload it by running script: -python3 download_service_accounts.py project_id ``` ### Adding service accounts to Google Groups: We use Google Groups to manager our service accounts considering the diff --git a/download_service_accounts.py b/download_service_accounts.py deleted file mode 100644 index 4fe1abb..0000000 --- a/download_service_accounts.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -import sys -import pickle - -from google_auth_oauthlib.flow import InstalledAppFlow -from google.auth.transport.requests import Request -from googleapiclient import discovery - -OAUTH_SCOPE = ['https://www.googleapis.com/auth/cloud-platform'] - - -# noinspection DuplicatedCode -def authorize(): - # Get credentials - credentials = None - if os.path.exists('token-iam.pickle'): - with open('token-iam.pickle', 'rb') as f: - credentials = pickle.load(f) - if credentials is None or not credentials.valid: - if credentials and credentials.expired and credentials.refresh_token: - credentials.refresh(Request()) - else: - flow = InstalledAppFlow.from_client_secrets_file( - 'credentials.json', OAUTH_SCOPE) - credentials = flow.run_console(port=0) - - # Save the credentials for the next run - with open('token-iam.pickle', 'wb') as token: - pickle.dump(credentials, token) - return discovery.build('iam', 'v1', credentials=credentials) - - -def get_service_accounts(project_id): - """Returns a list of service accounts in project with id == project_id""" - accounts = service.projects().serviceAccounts().list( - name=f'projects/{project_id}').execute() - return accounts['accounts'] - - -def download_keys(project_id): - accounts = get_service_accounts(project_id) - print(f'{len(accounts)} service accounts found! Dumping now') - i = 0 - for acc in accounts: - if not os.path.exists('accounts/'): - os.mkdir('accounts/') - if os.path.isfile('accounts/'): - os.remove('accounts') - os.mkdir('accounts/') - print("Dumping " + acc['email']) - key = service.projects().serviceAccounts().keys().create( - name='projects/-/serviceAccounts/' + acc['email'], body={} - ).execute() - with open(f'accounts/{i}.json', 'w') as f: - f.write(str(key)) - i += 1 - - -service = authorize() - -if __name__ == '__main__': - download_keys(sys.argv[1])