- Added extra buttons
This commit is contained in:
Hafitz Setya 2021-03-05 11:47:04 +07:00 committed by GitHub
parent df192e4145
commit 4d59931629
Signed by untrusted user: GitHub
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 97 additions and 27 deletions

View File

@ -20,7 +20,6 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
COPY . .
COPY .netrc /root/.netrc
RUN chmod +x aria.sh
CMD ["bash","start.sh"]

View File

@ -33,13 +33,12 @@ Fork this repo, than upload credentials.json and token.pickle to your forks
## Features supported:
- Mirroring direct download links to Google Drive
- Mirroring Mega.nz links to google drive (In development stage)
- Download progress
- Upload progress
- Copy files/folder from someone's drive to your drive
- Download/upload progress
- Download/upload speeds and ETAs
- Docker support
- Uploading To Team Drives.
- Index Link support
- Copy files/folder from someone's drive to your drive
- Service account support
- Mirror all youtube-dl supported links
- Mirror telegram files
@ -48,6 +47,7 @@ Fork this repo, than upload credentials.json and token.pickle to your forks
- Nyaa.si and Sukebei Torrent search
- Shell and Executor
- Shortener support
- Custom Buttons
- Speedtest with picture results
- Extract these filetypes and uploads to google drive
> ZIP, RAR, TAR, 7z, ISO, WIM, CAB, GZIP, BZIP2,

View File

@ -47,11 +47,11 @@
"required": false
},
"USE_SERVICE_ACCOUNTS": {
"description": "Whether to use service accounts or not. For this to work see 'Using service accounts' section below.",
"description": "Whether to use service accounts or not. For this to work see 'Using service accounts' in repo.",
"required": false
},
"AUTHORIZED_CHATS": {
"description": "Put User ID and Chat ID of you want to authorize.",
"description": "Fill User ID and Chat ID of you want to authorize.",
"required": false
},
"INDEX_URL": {
@ -83,12 +83,36 @@
"required": false
},
"SHORTENER": {
"description": "if you want to use shortener in Gdrive and index link.",
"description": "If you want to use shortener in Gdrive and index link.",
"required": false
},
"SHORTENER_API": {
"description": "Fill your shortener api key if you are using shortener.",
"required": false
},
"BUTTON_THREE_NAME": {
"description": "Extra buttons (optional).",
"required": false
},
"BUTTON_THREE_URL": {
"description": "Fill your URL if you are using extra buttons.",
"required": false
},
"BUTTON_FOUR_NAME": {
"description": "Extra buttons (optional).",
"required": false
},
"BUTTON_FOUR_URL": {
"description": "Fill your URL if you are using extra buttons.",
"required": false
},
"BUTTON_FIVE_NAME": {
"description": "Extra buttons (optional).",
"required": false
},
"BUTTON_FIVE_URL": {
"description": "Fill your URL if you are using extra buttons.",
"required": false
}
}
}

View File

@ -136,6 +136,30 @@ try:
INDEX_URL = None
except KeyError:
INDEX_URL = None
try:
BUTTON_THREE_NAME = getConfig('BUTTON_THREE_NAME')
BUTTON_THREE_URL = getConfig('BUTTON_THREE_URL')
if len(BUTTON_THREE_NAME) == 0 or len(BUTTON_THREE_URL) == 0:
raise KeyError
except KeyError:
BUTTON_THREE_NAME = None
BUTTON_THREE_URL = None
try:
BUTTON_FOUR_NAME = getConfig('BUTTON_FOUR_NAME')
BUTTON_FOUR_URL = getConfig('BUTTON_FOUR_URL')
if len(BUTTON_FOUR_NAME) == 0 or len(BUTTON_FOUR_URL) == 0:
raise KeyError
except KeyError:
BUTTON_FOUR_NAME = None
BUTTON_FOUR_URL = None
try:
BUTTON_FIVE_NAME = getConfig('BUTTON_FIVE_NAME')
BUTTON_FIVE_URL = getConfig('BUTTON_FIVE_URL')
if len(BUTTON_FIVE_NAME) == 0 or len(BUTTON_FIVE_URL) == 0:
raise KeyError
except KeyError:
BUTTON_FIVE_NAME = None
BUTTON_FIVE_URL = None
try:
IS_TEAM_DRIVE = getConfig('IS_TEAM_DRIVE')
if IS_TEAM_DRIVE.lower() == 'true':
@ -144,7 +168,6 @@ try:
IS_TEAM_DRIVE = False
except KeyError:
IS_TEAM_DRIVE = False
try:
USE_SERVICE_ACCOUNTS = getConfig('USE_SERVICE_ACCOUNTS')
if USE_SERVICE_ACCOUNTS.lower() == 'true':
@ -153,7 +176,6 @@ try:
USE_SERVICE_ACCOUNTS = False
except KeyError:
USE_SERVICE_ACCOUNTS = False
try:
BLOCK_MEGA_LINKS = getConfig('BLOCK_MEGA_LINKS')
if BLOCK_MEGA_LINKS.lower() == 'true':
@ -162,7 +184,6 @@ try:
BLOCK_MEGA_LINKS = False
except KeyError:
BLOCK_MEGA_LINKS = False
try:
SHORTENER = getConfig('SHORTENER')
SHORTENER_API = getConfig('SHORTENER_API')

View File

@ -33,10 +33,10 @@ def stats(update, context):
f'<b>Total disk space:</b> {total}\n' \
f'<b>Used:</b> {used} ' \
f'<b>Free:</b> {free}\n\n' \
f'<b>Data Usage</b>\n<b>Upload:</b> {sent}\n' \
f'📊Data Usage📊\n<b>Upload:</b> {sent}\n' \
f'<b>Down:</b> {recv}\n\n' \
f'<b>CPU:</b> {cpuUsage}%\n' \
f'<b>RAM:</b> {memory}%\n' \
f'<b>CPU:</b> {cpuUsage}% ' \
f'<b>RAM:</b> {memory}% ' \
f'<b>Disk:</b> {disk}%'
sendMessage(stats, context.bot, update)

View File

@ -20,7 +20,7 @@ from telegram import InlineKeyboardMarkup
from bot.helper.telegram_helper import button_build
from telegraph import Telegraph
from bot import parent_id, DOWNLOAD_DIR, IS_TEAM_DRIVE, INDEX_URL, \
USE_SERVICE_ACCOUNTS, download_dict, telegraph_token, SHORTENER, SHORTENER_API
USE_SERVICE_ACCOUNTS, download_dict, telegraph_token, BUTTON_THREE_NAME, BUTTON_THREE_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, SHORTENER, SHORTENER_API
from bot.helper.ext_utils.bot_utils import *
from bot.helper.ext_utils.fs_utils import get_mime_type, get_path_size
@ -322,16 +322,22 @@ class GoogleDriveHelper:
buttons = button_build.ButtonMaker()
if SHORTENER is not None and SHORTENER_API is not None:
surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, durl)).text
buttons.buildbutton("✨Drive Link✨", surl)
buttons.buildbutton("Drive Link", surl)
else:
buttons.buildbutton("✨Drive Link✨", durl)
buttons.buildbutton("Drive Link", durl)
if INDEX_URL is not None:
url = requests.utils.requote_uri(f'{INDEX_URL}/{meta.get("name")}/')
if SHORTENER is not None and SHORTENER_API is not None:
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
buttons.buildbutton("⚡Index Link⚡", siurl)
buttons.buildbutton("Index Link", siurl)
else:
buttons.buildbutton("⚡Index Link⚡", url)
buttons.buildbutton("Index Link", url)
if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None:
buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}")
if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None:
buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}")
if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None:
buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}")
else:
file = self.copyFile(meta.get('id'), parent_id)
msg += f'<b>Filename : </b><code>{file.get("name")}</code>'
@ -339,9 +345,9 @@ class GoogleDriveHelper:
buttons = button_build.ButtonMaker()
if SHORTENER is not None and SHORTENER_API is not None:
surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, durl)).text
buttons.buildbutton("✨Drive Link ✨", surl)
buttons.buildbutton("Drive Link ", surl)
else:
buttons.buildbutton("✨Drive Link✨", durl)
buttons.buildbutton("Drive Link", durl)
try:
msg += f'\n<b>Size : </b><code>{get_readable_file_size(int(meta.get("size")))}</code>'
except TypeError:
@ -350,9 +356,15 @@ class GoogleDriveHelper:
url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}')
if SHORTENER is not None and SHORTENER_API is not None:
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
buttons.buildbutton("⚡Index Link⚡", siurl)
buttons.buildbutton("Index Link", siurl)
else:
buttons.buildbutton("⚡Index Link⚡", url)
buttons.buildbutton("Index Link", url)
if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None:
buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}")
if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None:
buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}")
if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None:
buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}")
except Exception as err:
if isinstance(err, RetryError):
LOGGER.info(f"Total Attempts: {err.last_attempt.attempt_number}")

View File

@ -2,7 +2,7 @@ import requests
from telegram.ext import CommandHandler, run_async
from telegram import InlineKeyboardMarkup
from bot import Interval, INDEX_URL, BLOCK_MEGA_LINKS
from bot import Interval, INDEX_URL, BUTTON_THREE_NAME, BUTTON_THREE_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, BLOCK_MEGA_LINKS
from bot import dispatcher, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, download_dict, download_dict_lock, SHORTENER, SHORTENER_API
from bot.helper.ext_utils import fs_utils, bot_utils
from bot.helper.ext_utils.bot_utils import setInterval
@ -143,9 +143,9 @@ class MirrorListener(listeners.MirrorListeners):
buttons = button_build.ButtonMaker()
if SHORTENER is not None and SHORTENER_API is not None:
surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, link)).text
buttons.buildbutton("✨Drive Link✨", surl)
buttons.buildbutton("Drive Link", surl)
else:
buttons.buildbutton("✨Drive Link✨", link)
buttons.buildbutton("Drive Link", link)
LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}')
if INDEX_URL is not None:
share_url = requests.utils.requote_uri(f'{INDEX_URL}/{download_dict[self.uid].name()}')
@ -153,9 +153,15 @@ class MirrorListener(listeners.MirrorListeners):
share_url += '/'
if SHORTENER is not None and SHORTENER_API is not None:
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, share_url)).text
buttons.buildbutton("⚡Index Link⚡", siurl)
buttons.buildbutton("Index Link", siurl)
else:
buttons.buildbutton("⚡Index Link⚡", share_url)
buttons.buildbutton("Index Link", share_url)
if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None:
buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}")
if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None:
buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}")
if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None:
buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}")
if self.message.from_user.username:
uname = f"@{self.message.from_user.username}"
else:

View File

@ -21,3 +21,11 @@ MEGA_PASSWORD = ""
BLOCK_MEGA_LINKS = ""
SHORTENER = ""
SHORTENER_API = ""
# Add more buttons (two buttons are already added of file link and index link, you can add extra buttons too, these are optional)
# If you don't know what are below entries, simply leave them, Don't fill anything in them.
BUTTON_THREE_NAME = ""
BUTTON_THREE_URL = ""
BUTTON_FOUR_NAME = ""
BUTTON_FOUR_URL = ""
BUTTON_FIVE_NAME = ""
BUTTON_FIVE_URL = ""