Skip to content

Commit

Permalink
Updates the dead stuffs and added some stuffs for user competibilty (#13
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kaif-00z authored Oct 15, 2022
1 parent 2af2aa2 commit 50a3bc7
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.2-slim-buster
FROM python:3.9.7-slim-buster
RUN mkdir /bot && chmod 777 /bot
WORKDIR /bot
ENV DEBIAN_FRONTEND=noninteractive
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Queue Compressor Bot (For Single Users)

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?button-url=https%3A%2F%2Fgithub.com%2F1Danish-00%2FCompressorQueue&template=https%3A%2F%2Fgithub.com%2F1Danish-00%2FCompressorQueue)
### Fork Repo Then click on below button of ur fork repo.
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

### Variables
`APP_ID` `API_HASH` `BOT_TOKEN`
Expand Down
7 changes: 7 additions & 0 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@
LOGS.info("Bot is quiting...")
LOGS.info(str(e))
exit()

async def startup():
for x in OWNER.split():
try:
await bot.send_message(int(x), "**Bot is Successfully Deployed**")
except:
pass
32 changes: 30 additions & 2 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,32 @@ async def _(e):
async def _(e):
await bash(e)

@bot.on(events.NewMessage(pattern="/usage"))
async def _(e):
if str(e.sender_id) not in OWNER:
if e.sender_id != DEV:
return
total, used, free = shutil.disk_usage(".")
cpuUsage = psutil.cpu_percent()
memory = psutil.virtual_memory().percent
disk = psutil.disk_usage("/").percent
upload = hbs(psutil.net_io_counters().bytes_sent)
down = hbs(psutil.net_io_counters().bytes_recv)
TOTAL = hbs(total)
USED = hbs(used)
FREE = hbs(free)
await e.reply("**TOTAL DISK SPACE**: `{}`\n**USED**: `{}`\n**FREE**: {}\n**UPLOAD**: `{}`\n**DOWNLOAD**: `{}`\n**CPU**: `{}%`\n**RAM**: `{}%`\n**DISK**: `{}%`".format(
TOTAL,
USED,
FREE,
upload,
down,
cpuUsage,
memory,
disk,
))



########## AUTO ###########

Expand All @@ -101,7 +127,7 @@ async def something():
try:
if not WORKING and QUEUE:
user = int(OWNER.split()[0])
e = await bot.send_message(user, "Downloding Queue Files")
e = await bot.send_message(user, "`Downloding Queue Files...`")
s = dt.now()
try:
if isinstance(QUEUE[list(QUEUE.keys())[0]], str):
Expand Down Expand Up @@ -176,8 +202,9 @@ async def something():
progress(d, t, nnn, ttt, "uploading..")
),
)
fname = out.split("/")[1]
ds = await e.client.send_file(
e.chat_id, file=ok, force_document=True, thumb=thum
e.chat_id, file=ok, force_document=True, thumb=thum, caption=f"`{fname}`"
)
await nnn.delete()
org = int(Path(dl).stat().st_size)
Expand Down Expand Up @@ -207,5 +234,6 @@ async def something():

LOGS.info("Bot has started.")
with bot:
bot.loop.run_until_complete(startup())
bot.loop.run_until_complete(something())
bot.loop.run_forever()
6 changes: 3 additions & 3 deletions bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from decouple import config

try:
APP_ID = config("APP_ID", cast=int)
API_HASH = config("API_HASH")
APP_ID = config("APP_ID", default=6, cast=int)
API_HASH = config("API_HASH", default="eb06d4abfb49dc3eeb1aeb98ae0f581e")
BOT_TOKEN = config("BOT_TOKEN")
DEV = 1322549723
OWNER = config("OWNER")
Expand All @@ -26,7 +26,7 @@
default='ffmpeg -i "{}" -preset ultrafast -c:v libx265 -crf 27 -map 0:v -c:a aac -map 0:a -c:s copy -map 0:s? "{}"',
)
THUMB = config(
"THUMBNAIL", default="https://telegra.ph/file/75ee20ec8d8c8bba84f02.jpg"
"THUMBNAIL", default="https://graph.org/file/75ee20ec8d8c8bba84f02.jpg"
)
except Exception as e:
print("Environment vars Missing")
Expand Down
10 changes: 6 additions & 4 deletions bot/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def dl_link(event):
return
if WORKING or QUEUE:
QUEUE.update({link: name})
return await event.reply(f"Added {link} in QUEUE")
return await event.reply(f"`Added {link} in QUEUE #{len(QUEUE)}`")
WORKING.append(1)
s = dt.now()
xxx = await event.reply("`Downloading...`")
Expand Down Expand Up @@ -101,8 +101,9 @@ async def dl_link(event):
progress(d, t, nnn, ttt, "uploading..")
),
)
fname = out.split("/")[1]
ds = await xxx.client.send_file(
xxx.chat_id, file=ok, force_document=True, thumb=thum
xxx.chat_id, file=ok, force_document=True, thumb=thum, caption=f"`{fname}`"
)
await nnn.delete()
org = int(Path(dl).stat().st_size)
Expand Down Expand Up @@ -156,7 +157,7 @@ async def encod(event):
if not name:
name = "video_" + dt.now().isoformat("_", "seconds") + ".mp4"
QUEUE.update({doc.id: [name, doc]})
return await xxx.edit("`Added This File in Queue`")
return await xxx.edit(f"`Added This File in Queue #{len(QUEUE)}`")
WORKING.append(1)
xxx = await event.reply("`Downloading...`")
s = dt.now()
Expand Down Expand Up @@ -241,8 +242,9 @@ async def encod(event):
progress(d, t, nnn, ttt, "uploading..")
),
)
fname = out.split("/")[1]
ds = await e.client.send_file(
e.chat_id, file=ok, force_document=True, thumb=thum
e.chat_id, file=ok, force_document=True, thumb=thum, caption=f"`{fname}`"
)
await nnn.delete()
org = int(Path(dl).stat().st_size)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ aiohttp
python-decouple
psutil
tgcrypto
https://github.com/1Danish-00/Telethon/archive/master.zip
html_telegraph_poster
https://github.com/New-dev0/Telethon/archive/diamond.zip
git+https://github.com/kaif-00z/html-telegraph-poster

0 comments on commit 50a3bc7

Please sign in to comment.