Skip to content

Commit

Permalink
Remove some vars
Browse files Browse the repository at this point in the history
Signed-off-by: breakdowns <[email protected]>
  • Loading branch information
Hafitz Setya authored Jul 22, 2021
1 parent 63b476d commit 08d149e
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 79 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
- Check Heroku dynos stats
- Extracting **tar.xz** support
- Heroku config support
- Custom Image support
- Custom Progress bar
- Counting file/folder
- View Link button
- Shell and Executor
Expand Down Expand Up @@ -167,15 +165,11 @@ Fill up rest of the fields. Meaning of each fields are discussed below:
- **MEGA_LIMIT**: To limit downloading Mega (leave space between number and unit, Available units is (gb or GB, tb or TB), Examples: ```100 gb, 100 GB, 10 tb, 10 TB```
- **TORRENT_DIRECT_LIMIT**: To limit the Torrent/Direct mirror size, Leave space between number and unit. Available units is (gb or GB, tb or TB), Examples: ```100 gb, 100 GB, 10 tb, 10 TB```
- **TAR_UNZIP_LIMIT**: To limit mirroring as Tar or unzipmirror. Available units is (gb or GB, tb or TB), Examples: ```100 gb, 100 GB, 10 tb, 10 TB```
- **TIMEZONE**: To change time zone in ```/stats``` command (**NOTE**: Default time zone using ```Asia/Jakarta```)
- **IMAGE_URL**: Show Image/Logo in /start message. Fill value of image your link image, use telegra.ph or any direct link image.
- **VIEW_LINK**: View Link button to open file Index Link in browser instead of direct download link, you can figure out if it's compatible with your Index code or not, open any video from you Index and check if the END of link from browser link bar is `?a=view`, if yes make it `True` it will work (Compatible with [Bhadoo Index](https://gitlab.com/ParveenBhadooOfficial/Google-Drive-Index) Code)
- **UPTOBOX_TOKEN**: Uptobox token to mirror uptobox links. Get it from [Uptobox Premium Account](https://uptobox.com/my_account).
- **HEROKU_API_KEY**: (Only if you deploying on Heroku) Your Heroku API key, get it from https://dashboard.heroku.com/account.
- **HEROKU_APP_NAME**: (Only if you deploying on Heroku) Your Heroku app name.
- **IGNORE_PENDING_REQUESTS**: If you want the bot to ignore pending requests after it restarts, set this to `True`.
- **FINISHED_PROGRESS_STR**: Single character for finished progress. Example: ```Uploading ●●●●○○○○ %50```. This value sets: ``. You can Select any character from these listed sites: https://coolsymbol.com, https://changaco.oy.lc/unicode-progress-bars/, https://text-symbols.com/
- **UNFINISHED_PROGRESS_STR**: Single character for finished progress. Example: ```Uploading ●●●●○○○○ %50```. This value sets: ``. You can Select any character from these listed sites: https://coolsymbol.com, https://changaco.oy.lc/unicode-progress-bars/, https://text-symbols.com/
- **STATUS_LIMIT**: Status limit with buttons (**NOTE**: Recommend limit status to ```4``` tasks max).
- **SHORTENER_API**: Fill your Shortener api key if you are using Shortener.
- **SHORTENER**: if you want to use Shortener in Gdrive and index link, fill Shortener url here. Examples:
Expand Down
20 changes: 0 additions & 20 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,6 @@
"SHORTENER_API": {
"description": "Fill your shortener api key if you are using shortener.",
"required": false
},
"TIMEZONE": {
"description": "To change time zone in /stats command.",
"value": "Asia/Jakarta",
"required": false
},
"IMAGE_URL": {
"description": "Show Image/Logo in /start message, Use telegra.ph or any direct link image.",
"value": "https://telegra.ph/file/db03910496f06094f1f7a.jpg",
"required": false
},
"TOKEN_PICKLE_URL": {
"description": "(Optional) Only if you want to load your token.pickle externally from an index link. Fill this with the direct link of that file.",
Expand Down Expand Up @@ -199,16 +189,6 @@
"description": "Fill your URL if you are using extra buttons.",
"required": false
},
"FINISHED_PROGRESS_STR": {
"description": "Single character for finished progress",
"value": "",
"required": false
},
"UNFINISHED_PROGRESS_STR": {
"description": "Single character for unfinished progress",
"value": "",
"required": false
},
"STATUS_LIMIT": {
"description": "Status limit with buttons, Recommend limit status to 4 tasks max.",
"value": "",
Expand Down
24 changes: 0 additions & 24 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,37 +323,13 @@ def mktable():
except KeyError:
SHORTENER = None
SHORTENER_API = None
try:
IMAGE_URL = getConfig('IMAGE_URL')
if len(IMAGE_URL) == 0:
IMAGE_URL = 'https://telegra.ph/file/db03910496f06094f1f7a.jpg'
except KeyError:
IMAGE_URL = 'https://telegra.ph/file/db03910496f06094f1f7a.jpg'

IGNORE_PENDING_REQUESTS = False
try:
if getConfig("IGNORE_PENDING_REQUESTS").lower() == "true":
IGNORE_PENDING_REQUESTS = True
except KeyError:
pass
try:
FINISHED_PROGRESS_STR = getConfig('FINISHED_PROGRESS_STR')
if len(FINISHED_PROGRESS_STR) == 0:
FINISHED_PROGRESS_STR = '●'
except KeyError:
FINISHED_PROGRESS_STR = '●'
try:
UNFINISHED_PROGRESS_STR = getConfig('UNFINISHED_PROGRESS_STR')
if len(UNFINISHED_PROGRESS_STR) == 0:
UNFINISHED_PROGRESS_STR = '○'
except KeyError:
UNFINISHED_PROGRESS_STR = '○'
try:
TIMEZONE = getConfig('TIMEZONE')
if len(TIMEZONE) == 0:
TIMEZONE = 'Asia/Jakarta'
except KeyError:
TIMEZONE = 'Asia/Jakarta'

updater = tg.Updater(token=BOT_TOKEN)
bot = updater.bot
Expand Down
10 changes: 2 additions & 8 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
from pyrogram import idle
from bot import app
from sys import executable
from datetime import datetime
import pytz
import time

from telegram import ParseMode
from telegram.ext import CommandHandler
Expand All @@ -19,12 +16,10 @@
from .helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper import button_build
from .modules import authorize, list, cancel_mirror, mirror_status, mirror, clone, watch, shell, eval, torrent_search, delete, speedtest, usage, mediainfo, count, config, updates
now=datetime.now(pytz.timezone(f'{TIMEZONE}'))


def stats(update, context):
currentTime = get_readable_time(time.time() - botStartTime)
current = now.strftime('%Y/%m/%d %I:%M:%S %p')
total, used, free = shutil.disk_usage('.')
total = get_readable_file_size(total)
used = get_readable_file_size(used)
Expand All @@ -35,7 +30,6 @@ def stats(update, context):
memory = psutil.virtual_memory().percent
disk = psutil.disk_usage('/').percent
stats = f'<b>Bot Uptime:</b> {currentTime}\n' \
f'<b>Start Time:</b> {current}\n' \
f'<b>Total Disk Space:</b> {total}\n' \
f'<b>Used:</b> {used} ' \
f'<b>Free:</b> {free}\n\n' \
Expand All @@ -44,7 +38,7 @@ def stats(update, context):
f'<b>CPU:</b> {cpuUsage}%\n' \
f'<b>RAM:</b> {memory}%\n' \
f'<b>DISK:</b> {disk}%'
update.effective_message.reply_photo(IMAGE_URL, stats, parse_mode=ParseMode.HTML)
sendMessage(stats, context.bot, update)


def start(update, context):
Expand All @@ -62,7 +56,7 @@ def start(update, context):
if update.message.chat.type == "private" :
sendMessage(f"Hey I'm Alive 🙂\nSince: <code>{uptime}</code>", context.bot, update)
else :
update.effective_message.reply_photo(IMAGE_URL, start_string, parse_mode=ParseMode.MARKDOWN, reply_markup=reply_markup)
update.effective_message.reply_text(start_string, reply_markup=reply_markup)
else :
sendMessage(f"Oops! not a Authorized user.", context.bot, update)

Expand Down
13 changes: 6 additions & 7 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import math

from bot.helper.telegram_helper.bot_commands import BotCommands
from bot import dispatcher, download_dict, download_dict_lock, FINISHED_PROGRESS_STR, UNFINISHED_PROGRESS_STR, STATUS_LIMIT
from bot import dispatcher, download_dict, download_dict_lock, STATUS_LIMIT
from telegram import InlineKeyboardMarkup
from telegram.ext import CallbackQueryHandler
from bot.helper.telegram_helper import button_build, message_utils
Expand All @@ -31,7 +31,7 @@ class MirrorStatus:


PROGRESS_MAX_SIZE = 100 // 8
# PROGRESS_INCOMPLETE = ['▏', '▎', '▍', '▌', '▋', '▊', '▉']
PROGRESS_INCOMPLETE = ['▏', '▎', '▍', '▌', '▋', '▊', '▉']

SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']

Expand Down Expand Up @@ -94,11 +94,10 @@ def get_progress_bar_string(status):
p = min(max(p, 0), 100)
cFull = p // 8
cPart = p % 8 - 1
p_str = FINISHED_PROGRESS_STR * cFull
p_str = '█' * cFull
if cPart >= 0:
# p_str += PROGRESS_INCOMPLETE[cPart]
p_str += FINISHED_PROGRESS_STR
p_str += UNFINISHED_PROGRESS_STR * (PROGRESS_MAX_SIZE - cFull)
p_str += PROGRESS_INCOMPLETE[cPart]
p_str += ' ' * (PROGRESS_MAX_SIZE - cFull)
p_str = f"[{p_str}]"
return p_str

Expand Down Expand Up @@ -135,7 +134,7 @@ def get_readable_message():
f" | <b>Peers:</b> {download.aria_download().connections}"
except:
pass
msg += f'\n<b>User:</b> <a href="tg://user?id={download.message.from_user.id}">{download.message.from_user.first_name}</a> (<code>{download.message.from_user.id}</code>)'
msg += f'\n<b>User:</b> <a href="tg://user?id={download.message.from_user.id}">{download.message.from_user.first_name}</a>'
msg += f"\n<b>To Stop:</b> <code>/{BotCommands.CancelMirror} {download.gid()}</code>"
msg += "\n\n"
if STATUS_LIMIT is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def streamtape(url: str) -> str:
dl_url=bypasser.bypass_streamtape(url)
return dl_url


def racaty(url: str) -> str:
""" Racaty direct links generator
based on https://github.com/breakdowns/slam-mirrorbot """
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_utils/upload_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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, telegraph_token, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, BUTTON_SIX_NAME, BUTTON_SIX_URL, SHORTENER, SHORTENER_API, IMAGE_URL, VIEW_LINK
USE_SERVICE_ACCOUNTS, telegraph_token, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, BUTTON_SIX_NAME, BUTTON_SIX_URL, SHORTENER, SHORTENER_API, VIEW_LINK
from bot.helper.ext_utils.bot_utils import *
from bot.helper.ext_utils.fs_utils import get_mime_type, get_path_size

Expand Down Expand Up @@ -583,7 +583,7 @@ def drive_list(self, fileName):
orderBy='name asc').execute()
content_count = 0
if response["files"]:
msg += f'<img src="{IMAGE_URL}" /><h4>{len(response["files"])} Results: {fileName}</h4><br><br>'
msg += f'<h4>{len(response["files"])} Results: {fileName}</h4><br><br>'
for file in response.get('files', []):
if file.get('mimeType') == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File.
furl = f"https://drive.google.com/drive/folders/{file.get('id')}"
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ async def config_button(_, query):
elif data == '10':
return await query.message.edit(
__header__.format(data)
+ f"**[ Updater Config ]**\n\n**UPSTREAM_REPO:** `{UPSTREAM_REPO}`\n\n**UPSTREAM_BRANCH:** `{UPSTREAM_BRANCH}`\n\n**[ Visual Config ]**\n\n**FINISHED_PROGRESS_STR:** `{FINISHED_PROGRESS_STR}`\n\n**UNFINISHED_PROGRESS_STR:** `{UNFINISHED_PROGRESS_STR}`",
+ f"**[ Updater Config ]**\n\n**UPSTREAM_REPO:** `{UPSTREAM_REPO}`\n\n**UPSTREAM_BRANCH:** `{UPSTREAM_BRANCH}`",
reply_markup=types.InlineKeyboardMarkup(
[
[
Expand Down
6 changes: 3 additions & 3 deletions bot/modules/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from contextlib import redirect_stdout
from bot.helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper.bot_commands import BotCommands
from bot import LOGGER, dispatcher, IMAGE_URL
from bot import LOGGER, dispatcher
from telegram import ParseMode
from telegram.ext import CommandHandler

Expand Down Expand Up @@ -126,8 +126,8 @@ def exechelp(update, context):
• <code>/exec</code> <i>Run Commands In Exec</i>
• <code>/clearlocals</code> <i>Cleared locals</i>
'''
update.effective_message.reply_photo(IMAGE_URL, help_string, parse_mode=ParseMode.HTML)
update.effective_message.reply_text(help_string, parse_mode=ParseMode.HTML)


EVAL_HANDLER = CommandHandler(('eval'), evaluate, filters=CustomFilters.owner_filter, run_async=True)
EXEC_HANDLER = CommandHandler(('exec'), execute, filters=CustomFilters.owner_filter, run_async=True)
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/torrent_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram.handlers import MessageHandler, CallbackQueryHandler

from bot import app, dispatcher, IMAGE_URL
from bot import app, dispatcher
from bot.helper import custom_filters
from bot.helper.telegram_helper.bot_commands import BotCommands
from bot.helper.telegram_helper.filters import CustomFilters
Expand Down Expand Up @@ -330,7 +330,7 @@ def searchhelp(update, context):
• <code>/rarbg</code> <i>[search query]</i>
• <code>/ts</code> <i>[search query]</i>
'''
update.effective_message.reply_photo(IMAGE_URL, help_string, parse_mode=ParseMode.HTML)
update.effective_message.reply_text(help_string, parse_mode=ParseMode.HTML)


SEARCHHELP_HANDLER = CommandHandler(BotCommands.TsHelpCommand, searchhelp, filters=(CustomFilters.authorized_chat | CustomFilters.authorized_user) & CustomFilters.mirror_owner_filter, run_async=True)
Expand Down
5 changes: 0 additions & 5 deletions config_sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ STOP_DUPLICATE_CLONE = ""
STOP_DUPLICATE_MEGA = ""
SHORTENER = ""
SHORTENER_API = ""
TIMEZONE = "Asia/Jakarta"
IMAGE_URL = "https://telegra.ph/file/db03910496f06094f1f7a.jpg"
# If you want to use Credentials externally from Index Links, fill these vars with the direct links
# These are optional, if you don't know, simply leave them, don't fill anything in them.
ACCOUNTS_ZIP_URL = ""
Expand All @@ -56,6 +54,3 @@ BUTTON_FIVE_NAME = ""
BUTTON_FIVE_URL = ""
BUTTON_SIX_NAME = ""
BUTTON_SIX_URL = ""
# Single character for finished & unfinished progress
FINISHED_PROGRESS_STR = ""
UNFINISHED_PROGRESS_STR = ""
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pyrogram
python-dotenv
python-magic
python-telegram-bot
pytz
requests
speedtest-cli
telegraph
Expand Down

0 comments on commit 08d149e

Please sign in to comment.