improved config from tg + added dynamical status string
This commit is contained in:
parent
4b9f24b804
commit
0a9b9ebe31
|
|
@ -164,6 +164,8 @@ Fill up rest of the fields. Meaning of each fields are discussed below:
|
|||
- **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/
|
||||
- **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:
|
||||
```
|
||||
|
|
|
|||
10
app.json
10
app.json
|
|
@ -189,6 +189,16 @@
|
|||
"BUTTON_SIX_URL": {
|
||||
"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
|
||||
}
|
||||
},
|
||||
"addons": [
|
||||
|
|
|
|||
|
|
@ -304,7 +304,18 @@ try:
|
|||
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 = '○'
|
||||
updater = tg.Updater(token=BOT_TOKEN)
|
||||
bot = updater.bot
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import threading
|
|||
import time
|
||||
|
||||
from bot.helper.telegram_helper.bot_commands import BotCommands
|
||||
from bot import download_dict, download_dict_lock
|
||||
from bot import download_dict, download_dict_lock, FINISHED_PROGRESS_STR, UNFINISHED_PROGRESS_STR
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ class MirrorStatus:
|
|||
|
||||
|
||||
PROGRESS_MAX_SIZE = 100 // 8
|
||||
PROGRESS_INCOMPLETE = ['▏', '▎', '▍', '▌', '▋', '▊', '▉']
|
||||
# PROGRESS_INCOMPLETE = ['▏', '▎', '▍', '▌', '▋', '▊', '▉']
|
||||
|
||||
SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
|
||||
|
||||
|
|
@ -87,10 +87,11 @@ def get_progress_bar_string(status):
|
|||
p = min(max(p, 0), 100)
|
||||
cFull = p // 8
|
||||
cPart = p % 8 - 1
|
||||
p_str = '█' * cFull
|
||||
p_str = FINISHED_PROGRESS_STR * cFull
|
||||
if cPart >= 0:
|
||||
p_str += PROGRESS_INCOMPLETE[cPart]
|
||||
p_str += ' ' * (PROGRESS_MAX_SIZE - cFull)
|
||||
# p_str += PROGRESS_INCOMPLETE[cPart]
|
||||
p_str += FINISHED_PROGRESS_STR
|
||||
p_str += UNFINISHED_PROGRESS_STR * (PROGRESS_MAX_SIZE - cFull)
|
||||
p_str = f"[{p_str}]"
|
||||
return p_str
|
||||
|
||||
|
|
@ -107,7 +108,8 @@ def get_readable_message():
|
|||
msg += f"\n<b>Downloaded:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
|
||||
else:
|
||||
msg += f"\n<b>Uploaded:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
|
||||
msg += f"\n<b>Speed:</b> {download.speed()}\n<b>ETA:</b> {download.eta()} "
|
||||
msg += f"\n<b>Speed:</b> {download.speed()}" \
|
||||
f" | <b>ETA:</b> {download.eta()} "
|
||||
# if hasattr(download, 'is_torrent'):
|
||||
try:
|
||||
msg += f"\n<b>Seeders:</b> {download.aria_download().num_seeders}" \
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ async def set_varr(client, message, app_):
|
|||
await msg_.edit("`Here is Usage Syntax: /setvar KEY VALUE`", parse_mode="markdown")
|
||||
return
|
||||
_varname, _varvalue = var_
|
||||
await msg_.edit(f"`Variable {_varname} Added With Value {_varvalue}!`")
|
||||
await msg_.edit(
|
||||
f"`Variable {_varname} Added With Value {_varvalue}!`" \
|
||||
f"\nYour heroku app will restart. Be patient."
|
||||
)
|
||||
heroku_var[_varname] = _varvalue
|
||||
|
||||
# Delete Variable
|
||||
|
|
@ -43,7 +46,10 @@ async def del_varr(client, message, app_):
|
|||
if not _var in heroku_var:
|
||||
await msg_.edit("`This Var Doesn't Exists!`", parse_mode="markdown")
|
||||
return
|
||||
await msg_.edit(f"`Sucessfully Deleted {_var} Var!`", parse_mode="markdown")
|
||||
await msg_.edit(
|
||||
f"`Sucessfully Deleted {_var} Var!`" \
|
||||
f"\nYour heroku app will restart. Be patient.",
|
||||
parse_mode="markdown")
|
||||
del heroku_var[_var]
|
||||
|
||||
@app.on_message(filters.command(['reboot']) & filters.user(OWNER_ID))
|
||||
|
|
@ -71,11 +77,11 @@ async def config_button(_, query):
|
|||
if data == '1':
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f"**[ Telegram Config ]**\n\n**Bot Token:** `{BOT_TOKEN}`\n\n**Telegram API:** `{TELEGRAM_API}`\n\n**Telegram HASH:** `{TELEGRAM_HASH}`\n\n**Telegraph Token:** `{telegraph_token}`",
|
||||
+ f"**[ Telegram Config ]**\n\n**Bot Token** (`BOT_TOKEN`):\n`{BOT_TOKEN}`\n\n**Telegram API** (`TELEGRAM_API`):\n`{TELEGRAM_API}`\n\n**Telegram HASH** (`TELEGRAM_HASH`):\n`{TELEGRAM_HASH}`\n\n**Telegraph Token**:\n`{telegraph_token}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
types.InlineKeyboardButton(f"{emoji.LEFT_ARROW}", callback_data='docs_9'),
|
||||
types.InlineKeyboardButton(f"{emoji.LEFT_ARROW}", callback_data='docs_10'),
|
||||
types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'),
|
||||
types.InlineKeyboardButton(f"{emoji.RIGHT_ARROW}", callback_data='docs_2')
|
||||
]
|
||||
|
|
@ -85,7 +91,7 @@ async def config_button(_, query):
|
|||
elif data == '2':
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f"**[ Drive and Index Config ]**\n\n**Drive Folder:** `{parent_id}`\n\n**Using Team Drive:** `{IS_TEAM_DRIVE}`\n\n**Using Service Account:** `{USE_SERVICE_ACCOUNTS}`\n\n**Index Url:** `{INDEX_URL}`",
|
||||
+ f"**[ Drive and Index Config ]**\n\n**Drive Folder** (`GDRIVE_FOLDER_ID`):\n`{parent_id}`\n\n**Using Team Drive** (`IS_TEAM_DRIVE`):\n`{IS_TEAM_DRIVE}`\n\n**Using Service Account** (`USE_SERVICE_ACCOUNTS`):\n`{USE_SERVICE_ACCOUNTS}`\n\n**Index Url** (`INDEX_URL`):\n`{INDEX_URL}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
|
|
@ -99,7 +105,7 @@ async def config_button(_, query):
|
|||
elif data == '3':
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f"**[ Mega and Uptobox Config ]**\n\n**Mega API:** `{MEGA_API_KEY}`\n\n**Mega Email:** `{MEGA_EMAIL_ID}`\n\n**Mega Password:** `{MEGA_PASSWORD}`\n\n**Uptobox Token:** `{UPTOBOX_TOKEN}`",
|
||||
+ f"**[ Mega and Uptobox Config ]**\n\n**Mega API** (`MEGA_API_KEY`):\n`{MEGA_API_KEY}`\n\n**Mega Email**(`MEGA_EMAIL_ID`):\n`{MEGA_EMAIL_ID}`\n\n**Mega Password** (`MEGA_PASSWORD`):\n`{MEGA_PASSWORD}`\n\n**Uptobox Token** (`UPTOBOX_TOKEN`):\n`{UPTOBOX_TOKEN}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
|
|
@ -113,7 +119,7 @@ async def config_button(_, query):
|
|||
elif data == '4':
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f"**[ Stop Duplicate Config ]**\n\n**Mirror:** `{STOP_DUPLICATE_MIRROR}`\n\n**Clone:** `{STOP_DUPLICATE_CLONE}`\n\n**Mega:** `{STOP_DUPLICATE_MEGA}`\n\n**[ Block Mega Config ]**\n\n**Folder:** `{BLOCK_MEGA_FOLDER}`\n\n**Link:** `{BLOCK_MEGA_LINKS}`\n\n",
|
||||
+ f"**[ Stop Duplicate Config ]**\n\n**Mirror** (`STOP_DUPLICATE_MIRROR`): `{STOP_DUPLICATE_MIRROR}`\n\n**Clone** (`STOP_DUPLICATE_CLONE`): `{STOP_DUPLICATE_CLONE}`\n\n**Mega** (`STOP_DUPLICATE_MEGA`): `{STOP_DUPLICATE_MEGA}`\n\n**[ Block Mega Config ]**\n\n**Folder** (`BLOCK_MEGA_FOLDER`): `{BLOCK_MEGA_FOLDER}`\n\n**Link** (`BLOCK_MEGA_LINKS`): `{BLOCK_MEGA_LINKS}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
|
|
@ -127,7 +133,7 @@ async def config_button(_, query):
|
|||
elif data == '5':
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f"**[ Limit Size Config ]**\n\n**Torrent and Direct:** `{TORRENT_DIRECT_LIMIT}`\n\n**Tar and Unzip:** `{TAR_UNZIP_LIMIT}`\n\n**Clone:** `{CLONE_LIMIT}`\n\n**Mega:** `{MEGA_LIMIT}`",
|
||||
+ f"**[ Limit Size Config ]**\n\n**Torrent and Direct** (`TORRENT_DIRECT_LIMIT`): `{TORRENT_DIRECT_LIMIT}`\n\n**Tar and Unzip** (`TAR_UNZIP_LIMIT`): `{TAR_UNZIP_LIMIT}`\n\n**Clone** (`CLONE_LIMIT`): `{CLONE_LIMIT}`\n\n**Mega** (`MEGA_LIMIT`): `{MEGA_LIMIT}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
|
|
@ -144,7 +150,7 @@ async def config_button(_, query):
|
|||
sudo += '\n'.join(str(id) for id in SUDO_USERS)
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f"**[ User ID Config ]**\n\n**Owner ID:** `{OWNER_ID}`\n\n**Authorized Chat:**\n`{user}`\n\n**Sudo Users:**\n`{sudo}`",
|
||||
+ f"**[ User ID Config ]**\n\n**Owner ID** (`OWNER_ID`): `{OWNER_ID}`\n\n**Authorized Chat** (`AUTHORIZED_CHATS`):\n`{user}`\n\n**Sudo Users** (`SUDO_USERS`):\n`{sudo}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
|
|
@ -158,7 +164,7 @@ async def config_button(_, query):
|
|||
elif data == '7':
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f"**[ Button Config ]**\n\n**Button Four Name:** `{BUTTON_FOUR_NAME}`\n\n**Button Four Url:** `{BUTTON_FOUR_URL}`\n\n**Button Five Name:** `{BUTTON_FIVE_NAME}`\n\n**Button Five Url:** `{BUTTON_FIVE_URL}`\n\n**Button Six Name:** `{BUTTON_SIX_NAME}`\n\n**Button Six Url:** `{BUTTON_SIX_URL}`",
|
||||
+ f"**[ Button Config ]**\n\n**Button Four Name** (`BUTTON_FOUR_NAME`):\n`{BUTTON_FOUR_NAME}`\n\n**Button Four Url** (`BUTTON_FOUR_URL`):\n`{BUTTON_FOUR_URL}`\n\n**Button Five Name** (`BUTTON_FIVE_NAME`):\n`{BUTTON_FIVE_NAME}`\n\n**Button Five Url** (`BUTTON_FIVE_URL`):\n`{BUTTON_FIVE_URL}`\n\n**Button Six Name** (`BUTTON_SIX_NAME`):\n`{BUTTON_SIX_NAME}`\n\n**Button Six Url** (`BUTTON_SIX_URL`):\n`{BUTTON_SIX_URL}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
|
|
@ -172,7 +178,7 @@ async def config_button(_, query):
|
|||
elif data == '8':
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f"**[ Heroku Config ]**\n\n**Heroku Name:** `{HEROKU_APP_NAME}`\n\n**Heroku API:** `{HEROKU_API_KEY}`\n\n**[ Shortener Config ]**\n\n**Shortener Name:** `{SHORTENER}`\n\n**Shortener API:** `{SHORTENER_API}`",
|
||||
+ f"**[ Heroku Config ]**\n\n**Heroku Name** (`HEROKU_APP_NAME`):\n`{HEROKU_APP_NAME}`\n\n**Heroku API** (`HEROKU_API_KEY`): `{HEROKU_API_KEY}`\n\n**[ Shortener Config ]**\n\n**Shortener Name** (`SHORTENER`): `{SHORTENER}`\n\n**Shortener API:** (`SHORTENER_API`): `{SHORTENER_API}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
|
|
@ -186,12 +192,26 @@ async def config_button(_, query):
|
|||
elif data == '9':
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f" **[ Others Config ]**\n\n**View Link:** `{VIEW_LINK}`\n\n**Status Interval:** `{DOWNLOAD_STATUS_UPDATE_INTERVAL}`\n\n**Ignore Pending Request:** `{IGNORE_PENDING_REQUESTS}`\n\n**Delete Message Duration:** `{AUTO_DELETE_MESSAGE_DURATION}`\n\n**Directory:** `{DOWNLOAD_DIR}`\n\n**Image Url:** `{IMAGE_URL}`\n\n**Database Url:** `{DB_URI}`",
|
||||
+ f" **[ Others Config ]**\n\n**View Link** (`VIEW_LINK`):\n`{VIEW_LINK}`\n\n**Status Interval** (`DOWNLOAD_STATUS_UPDATE_INTERVAL`):\n`{DOWNLOAD_STATUS_UPDATE_INTERVAL}`\n\n**Ignore Pending Request** (`IGNORE_PENDING_REQUESTS`):\n`{IGNORE_PENDING_REQUESTS}`\n\n**Delete Message Duration** (`AUTO_DELETE_MESSAGE_DURATION`):\n`{AUTO_DELETE_MESSAGE_DURATION}`\n\n**Directory** (`DOWNLOAD_DIR`):\n`{DOWNLOAD_DIR}`\n\n**Image Url** (`IMAGE_URL`):\n`{IMAGE_URL}`\n\n**Database Url** (`DB_URI`):\n`{DB_URI}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
types.InlineKeyboardButton(f"{emoji.LEFT_ARROW}", callback_data='docs_8'),
|
||||
types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'),
|
||||
types.InlineKeyboardButton(f"{emoji.RIGHT_ARROW}", callback_data='docs_10')
|
||||
]
|
||||
]
|
||||
)
|
||||
)
|
||||
elif data == '10':
|
||||
return await query.message.edit(
|
||||
__header__.format(data)
|
||||
+ f" **[ Visual Config ]**\n\n**Finished String** (`FINISHED_PROGRESS_STR`): `{FINISHED_PROGRESS_STR}`\n\n**Unfinished String** (`UNFINISHED_PROGRESS_STR`): `{UNFINISHED_PROGRESS_STR}`",
|
||||
reply_markup=types.InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
types.InlineKeyboardButton(f"{emoji.LEFT_ARROW}", callback_data='docs_9'),
|
||||
types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'),
|
||||
types.InlineKeyboardButton(f"{emoji.RIGHT_ARROW}", callback_data='docs_1')
|
||||
]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -53,3 +53,7 @@ BUTTON_FIVE_NAME = ""
|
|||
BUTTON_FIVE_URL = ""
|
||||
BUTTON_SIX_NAME = ""
|
||||
BUTTON_SIX_URL = ""
|
||||
# Single character for finished progress
|
||||
FINISHED_PROGRESS_STR = "●"
|
||||
# Single character for unfinished progress
|
||||
UNFINISHED_PROGRESS_STR = "○"
|
||||
|
|
|
|||
Loading…
Reference in New Issue