Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
v4.8.3
Browse files Browse the repository at this point in the history
- Added uptime in /status
- Added cc in /count
- Fix error if not field IMAGE_URL in config.env
- Tidying up
  • Loading branch information
breakdowns authored Jun 5, 2021
1 parent d23bcbd commit efb6c07
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Where host is the name of extractor (eg. Youtube, Twitch). Multiple accounts of
# Credits

Thanks to:
- [out386](https://github.com/out386) heavily inspired from telegram bot which is written in JS
- [out386](https://github.com/out386) heavily inspired from Telegram Bot which is written in JS
- [Izzy12](https://github.com/lzzy12/) for original repo
- [Dank-del](https://github.com/Dank-del/) for base repo
- [magneto261290](https://github.com/magneto261290/) for some features
Expand Down
2 changes: 2 additions & 0 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ def mktable():
SHORTENER_API = None
try:
IMAGE_URL = getConfig('IMAGE_URL')
if len(IMAGE_URL) == 0:
IMAGE_URL = 'https://telegra.ph/file/89a98d9634d296e516961.jpg'
except KeyError:
IMAGE_URL = 'https://telegra.ph/file/db03910496f06094f1f7a.jpg'

Expand Down
8 changes: 4 additions & 4 deletions bot/helper/mirror_utils/upload_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def clone(self, link):
dir_id = self.create_directory(meta.get('name'), parent_id)
result = self.cloneFolder(meta.get('name'), meta.get('name'), meta.get('id'), dir_id)
msg += f'<b>Filename: </b><code>{meta.get("name")}</code>\n<b>Size: </b><code>{get_readable_file_size(self.transferred_size)}</code>'
msg += f'\n\n<b>Type: </b>Folder'
msg += f'\n<b>Type: </b>Folder'
msg += f'\n<b>SubFolders: </b>{self.total_folders}'
msg += f'\n<b>Files: </b>{self.total_files}'
durl = self.__G_DRIVE_DIR_BASE_DOWNLOAD_URL.format(dir_id)
Expand Down Expand Up @@ -372,7 +372,7 @@ def clone(self, link):
typeee = 'File'
try:
msg += f'\n<b>Size: </b><code>{get_readable_file_size(int(meta.get("size")))}</code>'
msg += f'\n\n<b>Type: </b>{typeee}'
msg += f'\n<b>Type: </b>{typeee}'
except TypeError:
pass
if INDEX_URL is not None:
Expand Down Expand Up @@ -625,7 +625,7 @@ def count(self, link):
self.gDrive_directory(**drive_file)
msg += f'<b>Filename: </b><code>{name}</code>'
msg += f'\n<b>Size: </b>{get_readable_file_size(self.total_bytes)}'
msg += f'\n\n<b>Type: </b>Folder'
msg += f'\n<b>Type: </b>Folder'
msg += f'\n<b>SubFolders: </b>{self.total_folders}'
msg += f'\n<b>Files: </b>{self.total_files}'
else:
Expand All @@ -638,7 +638,7 @@ def count(self, link):
self.total_files += 1
self.gDrive_file(**drive_file)
msg += f'\n<b>Size: </b><code>{get_readable_file_size(self.total_bytes)}</code>'
msg += f'\n\n<b>Type: </b>{typee}'
msg += f'\n<b>Type: </b>{typee}'
msg += f'\n<b>Files: </b>{self.total_files}'
except TypeError:
pass
Expand Down
12 changes: 6 additions & 6 deletions bot/helper/telegram_helper/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import psutil, shutil
import time
from bot import AUTO_DELETE_MESSAGE_DURATION, LOGGER, bot, \
status_reply_dict, status_reply_dict_lock, download_dict, download_dict_lock
from bot.helper.ext_utils.bot_utils import get_readable_message, get_readable_file_size, MirrorStatus
status_reply_dict, status_reply_dict_lock, download_dict, download_dict_lock, botStartTime
from bot.helper.ext_utils.bot_utils import get_readable_message, get_readable_file_size, get_readable_time, MirrorStatus
from telegram.error import TimedOut, BadRequest


Expand Down Expand Up @@ -68,8 +68,8 @@ def delete_all_messages():

def update_all_messages():
total, used, free = shutil.disk_usage('.')
used = get_readable_file_size(used)
free = get_readable_file_size(free)
currentTime = get_readable_time(time.time() - botStartTime)
msg = get_readable_message()
msg += f"<b>CPU:</b> {psutil.cpu_percent()}%" \
f" <b>RAM:</b> {psutil.virtual_memory().percent}%" \
Expand All @@ -91,7 +91,7 @@ def update_all_messages():
uldl_bytes += float(speedy.split('M')[0]) * 1048576
dlspeed = get_readable_file_size(dlspeed_bytes)
ulspeed = get_readable_file_size(uldl_bytes)
msg += f"\n<b>USED:</b> {used} | <b>FREE:</b> {free}\n<b>DL:</b> {dlspeed}ps 🔻 | <b>UL:</b> {ulspeed}ps 🔺\n"
msg += f"\n<b>FREE:</b> {free} | <b>UPTIME:</b> {currentTime}\n<b>DL:</b> {dlspeed}ps 🔻 | <b>UL:</b> {ulspeed}ps 🔺\n"
with status_reply_dict_lock:
for chat_id in list(status_reply_dict.keys()):
if status_reply_dict[chat_id] and msg != status_reply_dict[chat_id].text:
Expand All @@ -106,8 +106,8 @@ def update_all_messages():

def sendStatusMessage(msg, bot):
total, used, free = shutil.disk_usage('.')
used = get_readable_file_size(used)
free = get_readable_file_size(free)
currentTime = get_readable_time(time.time() - botStartTime)
progress = get_readable_message()
progress += f"<b>CPU:</b> {psutil.cpu_percent()}%" \
f" <b>RAM:</b> {psutil.virtual_memory().percent}%" \
Expand All @@ -129,7 +129,7 @@ def sendStatusMessage(msg, bot):
uldl_bytes += float(speedy.split('M')[0]) * 1048576
dlspeed = get_readable_file_size(dlspeed_bytes)
ulspeed = get_readable_file_size(uldl_bytes)
progress += f"\n<b>USED:</b> {used} | <b>FREE:</b> {free}\n<b>DL:</b> {dlspeed}ps 🔻 | <b>UL:</b> {ulspeed}ps 🔺\n"
progress += f"\n<b>FREE:</b> {free} | <b>UPTIME:</b> {currentTime}\n<b>DL:</b> {dlspeed}ps 🔻 | <b>UL:</b> {ulspeed}ps 🔺\n"
with status_reply_dict_lock:
if msg.message.chat.id in list(status_reply_dict.keys()):
try:
Expand Down
8 changes: 7 additions & 1 deletion bot/modules/count.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
@run_async
def countNode(update, context):
args = update.message.text.split(" ", maxsplit=1)
if update.message.from_user.username:
uname = f"@{update.message.from_user.username}"
else:
uname = f'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}</a>'
if uname is not None:
cc = f'\n\ncc: {uname}'
if len(args) > 1:
link = args[1]
msg = sendMessage(f"Counting: <code>{link}</code>", context.bot, update)
gd = GoogleDriveHelper()
result = gd.count(link)
deleteMessage(context.bot, msg)
sendMessage(result, context.bot, update)
sendMessage(result + cc, context.bot, update)
else:
sendMessage("Provide G-Drive Shareable Link to Count.", context.bot, update)

Expand Down
4 changes: 2 additions & 2 deletions bot/modules/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ def onUploadComplete(self, link: str, size, files, folders, typ):
with download_dict_lock:
msg = f'<b>Filename: </b><code>{download_dict[self.uid].name()}</code>\n<b>Size: </b><code>{size}</code>'
if os.path.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'):
msg += '\n\n<b>Type: </b>Folder'
msg += '\n<b>Type: </b>Folder'
msg += f'\n<b>SubFolders: </b>{folders}'
msg += f'\n<b>Files: </b>{files}'
else:
msg += f'\n\n<b>Type: </b>{typ}'
msg += f'\n<b>Type: </b>{typ}'
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
Expand Down

0 comments on commit efb6c07

Please sign in to comment.