forked from rahulkhatri137/mirrorbot137
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ae1bbb
commit b9c986b
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ This project is heavily inspired from @out386 's telegram bot which is written i | |
- Count Drive Files. | ||
- Extract password protected files (It's not hack, you have to enter password) | ||
- For extracting password protected files, using custom filename and download | ||
- Update bot at startup and with restart command using `UPSTREAM_REPO` | ||
|
||
## Multi Search IDs | ||
To use list from multi TD/folder. Run driveid.py in your terminal and follow it. It will generate **drive_folder** file or u can simply create `drive_folder` file in working directory and fill it, check below format: | ||
|
@@ -134,6 +135,9 @@ Fill up rest of the fields. Meaning of each field is discussed below: | |
**2. Optional Fields** | ||
- `UPSTREAM_REPO`: Your github repository link, if your repo is private add `https://username:{githubtoken}@github.com/{username}/{reponame}` format. Get token from [Github settings](https://github.com/settings/tokens). So you can update your bot from filled repository on each restart. | ||
- **NOTE**: Any change in docker or requirements you need to deploy/build again with updated repo to take effect. DON'T delete .gitignore file. | ||
- `UPSTREAM_BRANCH`: Upstream branch for update. Default is `master`. | ||
- `ACCOUNTS_ZIP_URL`: Only if you want to load your Service Account externally from an Index Link or by any direct download link NOT webpage link. Archive the accounts folder to ZIP file. Fill this with the direct download link of zip file. If index need authentication so add direct download as shown below: | ||
- `https://username:[email protected]/...` | ||
- `TOKEN_PICKLE_URL`: Only if you want to load your **token.pickle** externally from an Index Link. Fill this with the direct link of that file. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python3 update.py && python3 -m bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from logging import FileHandler, error as log_error, info as log_info | ||
import os | ||
import requests | ||
from subprocess import run as srun | ||
from dotenv import load_dotenv | ||
|
||
CONFIG_FILE_URL = os.environ.get('CONFIG_FILE_URL') | ||
try: | ||
if len(CONFIG_FILE_URL) == 0: | ||
raise TypeError | ||
try: | ||
res = requests.get(CONFIG_FILE_URL) | ||
if res.status_code == 200: | ||
with open('config.env', 'wb+') as f: | ||
f.write(res.content) | ||
else: | ||
log_error(f"Failed to download config.env {res.status_code}") | ||
except Exception as e: | ||
log_error(f"CONFIG_FILE_URL: {e}") | ||
except: | ||
pass | ||
|
||
load_dotenv('config.env', override=True) | ||
|
||
UPSTREAM_REPO = os.environ.get('UPSTREAM_REPO') | ||
UPSTREAM_BRANCH = os.environ.get('UPSTREAM_BRANCH') | ||
try: | ||
if len(UPSTREAM_REPO) == 0: | ||
raise TypeError | ||
except: | ||
UPSTREAM_REPO = None | ||
try: | ||
if len(UPSTREAM_BRANCH) == 0: | ||
raise TypeError | ||
except: | ||
UPSTREAM_BRANCH = 'master' | ||
|
||
if UPSTREAM_REPO is not None: | ||
if os.path.exists('.git'): | ||
srun(["rm", "-rf", ".git"]) | ||
|
||
update = srun([f"git init -q \ | ||
&& git config --global user.email [email protected] \ | ||
&& git config --global user.name mirrorbot137 \ | ||
&& git add . \ | ||
&& git commit -sm update -q \ | ||
&& git remote add origin {UPSTREAM_REPO} \ | ||
&& git fetch origin -q \ | ||
&& git reset --hard origin/{UPSTREAM_BRANCH} -q"], shell=True) | ||
|
||
if update.returncode == 0: | ||
log_info('Successfully updated from UPSTREAM_REPO') | ||
else: | ||
log_error('Something went wrong, Check UPSTREAM_REPO if valid or not!') |