commit
72d1cc6afd
@ -1,3 +1,4 @@
|
||||
import traceback
|
||||
from typing import Callable
|
||||
from pyrogram import Client
|
||||
from pyrogram.types import Message
|
||||
@ -19,6 +20,7 @@ def errors(func: Callable) -> Callable:
|
||||
try:
|
||||
return await func(client, message)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await message.reply(f"{type(e).__name__}: {e}")
|
||||
|
||||
return decorator
|
||||
|
@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import os
|
||||
from driver.core import bot, calls
|
||||
from driver.database.dbqueue import remove_active_chat
|
||||
from driver.queues import (
|
||||
@ -152,3 +153,8 @@ async def bash(cmd):
|
||||
err = stderr.decode().strip()
|
||||
out = stdout.decode().strip()
|
||||
return out, err
|
||||
|
||||
|
||||
def remove_if_exists(path):
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import traceback
|
||||
|
||||
from cache.admins import admins
|
||||
from driver.core import calls, bot
|
||||
from pyrogram import Client, filters
|
||||
@ -7,7 +8,7 @@ from driver.design.chatname import CHAT_TITLE
|
||||
from driver.queues import QUEUE, clear_queue
|
||||
from driver.filters import command, other_filters
|
||||
from driver.decorators import authorized_users_only
|
||||
from driver.utils import skip_current_song, skip_item
|
||||
from driver.utils import skip_current_song, skip_item, remove_if_exists
|
||||
from driver.database.dbpunish import is_gbanned_user
|
||||
|
||||
from driver.database.dbqueue import (
|
||||
@ -71,6 +72,7 @@ async def stop(client, m: Message):
|
||||
clear_queue(chat_id)
|
||||
await m.reply("✅ The userbot has disconnected from the video chat.")
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await m.reply(f"🚫 **error:**\n\n`{e}`")
|
||||
else:
|
||||
await m.reply("❌ **nothing is streaming**")
|
||||
@ -97,6 +99,7 @@ async def pause(client, m: Message):
|
||||
"⏸ **Track paused.**\n\n• **To resume the stream, use the**\n» /resume command."
|
||||
)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await m.reply(f"🚫 **error:**\n\n`{e}`")
|
||||
else:
|
||||
await m.reply("❌ **nothing is streaming**")
|
||||
@ -123,6 +126,7 @@ async def resume(client, m: Message):
|
||||
"▶️ **Track resumed.**\n\n• **To pause the stream, use the**\n» /pause command."
|
||||
)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await m.reply(f"🚫 **error:**\n\n`{e}`")
|
||||
else:
|
||||
await m.reply("❌ **nothing is streaming**")
|
||||
@ -161,7 +165,7 @@ async def skip(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"⏭ **Skipped** to the next track.\n\n🗂 **Name:** [{op[0]}]({op[1]})\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
else:
|
||||
skip = m.text.split(None, 1)[1]
|
||||
track = "🗑 removed song from queue:"
|
||||
@ -201,6 +205,7 @@ async def mute(client, m: Message):
|
||||
"🔇 **Userbot muted.**\n\n• **To unmute the userbot, use the**\n» /unmute command."
|
||||
)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await m.reply(f"🚫 **error:**\n\n`{e}`")
|
||||
else:
|
||||
await m.reply("❌ **nothing is streaming**")
|
||||
@ -227,6 +232,7 @@ async def unmute(client, m: Message):
|
||||
"🔊 **Userbot unmuted.**\n\n• **To mute the userbot, use the**\n» /mute command."
|
||||
)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await m.reply(f"🚫 **error:**\n\n`{e}`")
|
||||
else:
|
||||
await m.reply("❌ **nothing is streaming**")
|
||||
@ -251,6 +257,7 @@ async def cbpause(_, query: CallbackQuery):
|
||||
await music_off(chat_id)
|
||||
await query.answer("⏸ The music has paused !\n\n» to resume the music click on resume button !", show_alert=True)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
||||
else:
|
||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
||||
@ -275,6 +282,7 @@ async def cbresume(_, query: CallbackQuery):
|
||||
await music_on(chat_id)
|
||||
await query.answer("▶️ The music has resumed !\n\n» to pause the music click on pause button !", show_alert=True)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
||||
else:
|
||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
||||
@ -297,6 +305,7 @@ async def cbstop(_, query: CallbackQuery):
|
||||
clear_queue(chat_id)
|
||||
await query.edit_message_text("✅ **this streaming has ended**", reply_markup=close_mark)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
||||
else:
|
||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
||||
@ -321,6 +330,7 @@ async def cbmute(_, query: CallbackQuery):
|
||||
await music_off(chat_id)
|
||||
await query.answer("🔇 The stream userbot has muted !\n\n» to unmute the userbot click on unmute button !", show_alert=True)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
||||
else:
|
||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
||||
@ -345,6 +355,7 @@ async def cbunmute(_, query: CallbackQuery):
|
||||
await music_on(chat_id)
|
||||
await query.answer("🔊 The stream userbot has unmuted !\n\n» to mute the userbot click on mute button !", show_alert=True)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
|
||||
else:
|
||||
await query.answer("❌ nothing is currently streaming", show_alert=True)
|
||||
@ -371,6 +382,7 @@ async def change_volume(client, m: Message):
|
||||
f"✅ **volume set to** `{range}`%"
|
||||
)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await m.reply(f"🚫 **error:**\n\n`{e}`")
|
||||
else:
|
||||
await m.reply("❌ **nothing in streaming**")
|
||||
|
@ -1,4 +1,3 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import shutil
|
||||
@ -16,6 +15,7 @@ from driver.filters import command
|
||||
from pyrogram import Client, filters
|
||||
from driver.database.dbchat import remove_served_chat
|
||||
from driver.decorators import bot_creator, sudo_users_only, errors
|
||||
from driver.utils import remove_if_exists
|
||||
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ async def executor(client, message):
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
await message.delete()
|
||||
os.remove(filename)
|
||||
remove_if_exists(filename)
|
||||
else:
|
||||
t2 = time()
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
@ -165,7 +165,7 @@ async def shellrunner(client, message):
|
||||
reply_to_message_id=message.message_id,
|
||||
caption="`OUTPUT`",
|
||||
)
|
||||
return os.remove("output.txt")
|
||||
return remove_if_exists("output.txt")
|
||||
await edit_or_reply(message, text=f"`OUTPUT:`\n\n```{output}```")
|
||||
else:
|
||||
await edit_or_reply(message, text="`OUTPUT:`\n\n`no output`")
|
||||
|
@ -4,6 +4,8 @@ import os
|
||||
import re
|
||||
import time
|
||||
import asyncio
|
||||
import traceback
|
||||
|
||||
import lyricsgenius
|
||||
|
||||
import aiofiles
|
||||
@ -21,6 +23,7 @@ from yt_dlp import YoutubeDL
|
||||
from config import BOT_USERNAME as bn
|
||||
from driver.filters import command, other_filters
|
||||
from driver.database.dbpunish import is_gbanned_user
|
||||
from driver.utils import remove_if_exists
|
||||
|
||||
|
||||
@Client.on_message(command(["song", f"song@{bn}"]) & ~filters.edited)
|
||||
@ -82,8 +85,8 @@ async def song_downloader(_, message):
|
||||
await m.edit("❌ error, wait for bot owner to fix")
|
||||
print(e)
|
||||
try:
|
||||
os.remove(audio_file)
|
||||
os.remove(thumb_name)
|
||||
remove_if_exists(audio_file)
|
||||
remove_if_exists(thumb_name)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
@ -126,6 +129,7 @@ async def video_downloader(_, message):
|
||||
ytdl_data = ytdl.extract_info(link, download=True)
|
||||
file_name = ytdl.prepare_filename(ytdl_data)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return await msg.edit(f"🚫 error: `{e}`")
|
||||
preview = wget.download(thumbnail)
|
||||
await msg.edit("📤 uploading video...")
|
||||
@ -136,7 +140,7 @@ async def video_downloader(_, message):
|
||||
caption=ytdl_data["title"],
|
||||
)
|
||||
try:
|
||||
os.remove(file_name)
|
||||
remove_if_exists(file_name)
|
||||
await msg.delete()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@ -173,6 +177,6 @@ async def get_lyric_genius(_, message: Message):
|
||||
caption=f"**OUTPUT:**\n\n`attached lyrics text`",
|
||||
quote=False,
|
||||
)
|
||||
os.remove(filename)
|
||||
remove_if_exists(filename)
|
||||
else:
|
||||
await m.edit(xxx)
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
import asyncio
|
||||
import traceback
|
||||
|
||||
from pyrogram.types import Message
|
||||
from pyrogram import Client, filters, __version__ as pyrover
|
||||
@ -159,6 +160,7 @@ async def active_calls(c: Client, message: Message):
|
||||
for chat in chats:
|
||||
served_chats.append(int(chat["chat_id"]))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
await message.reply_text(f"🚫 error: `{e}`")
|
||||
text = ""
|
||||
j = 0
|
||||
|
@ -2,8 +2,9 @@
|
||||
# Commit Start Date 20/10/2021
|
||||
# Finished On 28/10/2021
|
||||
|
||||
import os
|
||||
# pyrogram stuff
|
||||
import traceback
|
||||
|
||||
from pyrogram import Client
|
||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
||||
from pyrogram.types import InlineKeyboardMarkup, Message
|
||||
@ -19,7 +20,7 @@ from driver.design.chatname import CHAT_TITLE
|
||||
from driver.filters import command, other_filters
|
||||
from driver.queues import QUEUE, add_to_queue
|
||||
from driver.core import calls, user, bot
|
||||
from driver.utils import bash
|
||||
from driver.utils import bash, remove_if_exists
|
||||
from driver.database.dbpunish import is_gbanned_user
|
||||
from driver.database.dblockchat import blacklisted_chats
|
||||
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
||||
@ -81,6 +82,7 @@ async def play(c: Client, m: Message):
|
||||
try:
|
||||
aing = await c.get_me()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return await m.reply_text(f"error:\n\n{e}")
|
||||
a = await c.get_chat_member(chat_id, aing.id)
|
||||
if a.status != "administrator":
|
||||
@ -136,6 +138,7 @@ async def play(c: Client, m: Message):
|
||||
except UserAlreadyParticipant:
|
||||
pass
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return await m.reply_text(
|
||||
f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
|
||||
)
|
||||
@ -172,7 +175,7 @@ async def play(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
else:
|
||||
try:
|
||||
gcname = m.chat.title
|
||||
@ -204,10 +207,11 @@ async def play(c: Client, m: Message):
|
||||
caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
except Exception as e:
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
traceback.print_exc()
|
||||
await m.reply_text(f"🚫 error:\n\n» {e}")
|
||||
else:
|
||||
if len(m.command) < 2:
|
||||
@ -247,7 +251,7 @@ async def play(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
else:
|
||||
try:
|
||||
await suhu.edit("🔄 Joining Group Call...")
|
||||
@ -273,7 +277,7 @@ async def play(c: Client, m: Message):
|
||||
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
except Exception as ep:
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
@ -315,7 +319,7 @@ async def play(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
else:
|
||||
try:
|
||||
await suhu.edit("🔄 Joining Group Call...")
|
||||
@ -339,7 +343,7 @@ async def play(c: Client, m: Message):
|
||||
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
except Exception as ep:
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
|
@ -1,6 +1,5 @@
|
||||
# credit to TeamYukki for this speedtest module
|
||||
|
||||
import os
|
||||
import wget
|
||||
import speedtest
|
||||
|
||||
@ -9,6 +8,7 @@ from driver.filters import command, other_filters
|
||||
from driver.decorators import sudo_users_only
|
||||
from config import BOT_USERNAME as bname
|
||||
from driver.core import bot as app
|
||||
from driver.utils import remove_if_exists
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
@ -48,5 +48,5 @@ async def run_speedtest(_, message: Message):
|
||||
msg = await app.send_photo(
|
||||
chat_id=message.chat.id, photo=path, caption=output
|
||||
)
|
||||
os.remove(path)
|
||||
remove_if_exists(path)
|
||||
await m.delete()
|
||||
|
@ -3,9 +3,9 @@
|
||||
# Finished On 28/10/2021
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
import asyncio
|
||||
import traceback
|
||||
# repository stuff
|
||||
from config import BOT_USERNAME, IMG_1, IMG_2, IMG_5
|
||||
from program.utils.inline import stream_markup
|
||||
@ -17,6 +17,7 @@ from driver.core import calls, user, bot
|
||||
from driver.database.dbpunish import is_gbanned_user
|
||||
from driver.database.dblockchat import blacklisted_chats
|
||||
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
||||
from driver.utils import remove_if_exists
|
||||
# pyrogram stuff
|
||||
from pyrogram import Client
|
||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
||||
@ -96,6 +97,7 @@ async def vplay(c: Client, m: Message):
|
||||
try:
|
||||
aing = await c.get_me()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return await m.reply_text(f"error:\n\n{e}")
|
||||
a = await c.get_chat_member(chat_id, aing.id)
|
||||
if a.status != "administrator":
|
||||
@ -151,6 +153,7 @@ async def vplay(c: Client, m: Message):
|
||||
except UserAlreadyParticipant:
|
||||
pass
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return await m.reply_text(
|
||||
f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
|
||||
)
|
||||
@ -197,7 +200,7 @@ async def vplay(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
else:
|
||||
await loser.edit("🔄 Joining Group Call...")
|
||||
gcname = m.chat.title
|
||||
@ -233,7 +236,7 @@ async def vplay(c: Client, m: Message):
|
||||
caption=f"🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
else:
|
||||
if len(m.command) < 2:
|
||||
await m.reply(
|
||||
@ -274,7 +277,7 @@ async def vplay(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
else:
|
||||
try:
|
||||
await loser.edit("🔄 Joining Group Call...")
|
||||
@ -299,7 +302,7 @@ async def vplay(c: Client, m: Message):
|
||||
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
except Exception as ep:
|
||||
await loser.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
@ -345,7 +348,7 @@ async def vplay(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
else:
|
||||
try:
|
||||
await loser.edit("🔄 Joining Group Call...")
|
||||
@ -370,7 +373,7 @@ async def vplay(c: Client, m: Message):
|
||||
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
os.remove(image)
|
||||
remove_if_exists(image)
|
||||
except Exception as ep:
|
||||
await loser.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
@ -398,6 +401,7 @@ async def vstream(c: Client, m: Message):
|
||||
try:
|
||||
aing = await c.get_me()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return await m.reply_text(f"error:\n\n{e}")
|
||||
a = await c.get_chat_member(chat_id, aing.id)
|
||||
if a.status != "administrator":
|
||||
@ -453,6 +457,7 @@ async def vstream(c: Client, m: Message):
|
||||
except UserAlreadyParticipant:
|
||||
pass
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return await m.reply_text(
|
||||
f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user