[fix] FileNotFoundError
This commit is contained in:
parent
afa436c050
commit
416992da7a
@ -1,4 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import os
|
||||||
from driver.core import bot, calls
|
from driver.core import bot, calls
|
||||||
from driver.database.dbqueue import remove_active_chat
|
from driver.database.dbqueue import remove_active_chat
|
||||||
from driver.queues import (
|
from driver.queues import (
|
||||||
@ -152,3 +153,8 @@ async def bash(cmd):
|
|||||||
err = stderr.decode().strip()
|
err = stderr.decode().strip()
|
||||||
out = stdout.decode().strip()
|
out = stdout.decode().strip()
|
||||||
return out, err
|
return out, err
|
||||||
|
|
||||||
|
|
||||||
|
def remove_if_exists(path):
|
||||||
|
if os.path.exists(path):
|
||||||
|
os.remove(path)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import os
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from cache.admins import admins
|
from cache.admins import admins
|
||||||
@ -9,7 +8,7 @@ from driver.design.chatname import CHAT_TITLE
|
|||||||
from driver.queues import QUEUE, clear_queue
|
from driver.queues import QUEUE, clear_queue
|
||||||
from driver.filters import command, other_filters
|
from driver.filters import command, other_filters
|
||||||
from driver.decorators import authorized_users_only
|
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.dbpunish import is_gbanned_user
|
||||||
|
|
||||||
from driver.database.dbqueue import (
|
from driver.database.dbqueue import (
|
||||||
@ -166,7 +165,7 @@ async def skip(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
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}",
|
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:
|
else:
|
||||||
skip = m.text.split(None, 1)[1]
|
skip = m.text.split(None, 1)[1]
|
||||||
track = "🗑 removed song from queue:"
|
track = "🗑 removed song from queue:"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
@ -16,6 +15,7 @@ from driver.filters import command
|
|||||||
from pyrogram import Client, filters
|
from pyrogram import Client, filters
|
||||||
from driver.database.dbchat import remove_served_chat
|
from driver.database.dbchat import remove_served_chat
|
||||||
from driver.decorators import bot_creator, sudo_users_only, errors
|
from driver.decorators import bot_creator, sudo_users_only, errors
|
||||||
|
from driver.utils import remove_if_exists
|
||||||
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
|
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ async def executor(client, message):
|
|||||||
reply_markup=keyboard,
|
reply_markup=keyboard,
|
||||||
)
|
)
|
||||||
await message.delete()
|
await message.delete()
|
||||||
os.remove(filename)
|
remove_if_exists(filename)
|
||||||
else:
|
else:
|
||||||
t2 = time()
|
t2 = time()
|
||||||
keyboard = InlineKeyboardMarkup(
|
keyboard = InlineKeyboardMarkup(
|
||||||
@ -165,7 +165,7 @@ async def shellrunner(client, message):
|
|||||||
reply_to_message_id=message.message_id,
|
reply_to_message_id=message.message_id,
|
||||||
caption="`OUTPUT`",
|
caption="`OUTPUT`",
|
||||||
)
|
)
|
||||||
return os.remove("output.txt")
|
return remove_if_exists("output.txt")
|
||||||
await edit_or_reply(message, text=f"`OUTPUT:`\n\n```{output}```")
|
await edit_or_reply(message, text=f"`OUTPUT:`\n\n```{output}```")
|
||||||
else:
|
else:
|
||||||
await edit_or_reply(message, text="`OUTPUT:`\n\n`no output`")
|
await edit_or_reply(message, text="`OUTPUT:`\n\n`no output`")
|
||||||
|
@ -23,6 +23,7 @@ from yt_dlp import YoutubeDL
|
|||||||
from config import BOT_USERNAME as bn
|
from config import BOT_USERNAME as bn
|
||||||
from driver.filters import command, other_filters
|
from driver.filters import command, other_filters
|
||||||
from driver.database.dbpunish import is_gbanned_user
|
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)
|
@Client.on_message(command(["song", f"song@{bn}"]) & ~filters.edited)
|
||||||
@ -84,8 +85,8 @@ async def song_downloader(_, message):
|
|||||||
await m.edit("❌ error, wait for bot owner to fix")
|
await m.edit("❌ error, wait for bot owner to fix")
|
||||||
print(e)
|
print(e)
|
||||||
try:
|
try:
|
||||||
os.remove(audio_file)
|
remove_if_exists(audio_file)
|
||||||
os.remove(thumb_name)
|
remove_if_exists(thumb_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
@ -139,7 +140,7 @@ async def video_downloader(_, message):
|
|||||||
caption=ytdl_data["title"],
|
caption=ytdl_data["title"],
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
os.remove(file_name)
|
remove_if_exists(file_name)
|
||||||
await msg.delete()
|
await msg.delete()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
@ -176,6 +177,6 @@ async def get_lyric_genius(_, message: Message):
|
|||||||
caption=f"**OUTPUT:**\n\n`attached lyrics text`",
|
caption=f"**OUTPUT:**\n\n`attached lyrics text`",
|
||||||
quote=False,
|
quote=False,
|
||||||
)
|
)
|
||||||
os.remove(filename)
|
remove_if_exists(filename)
|
||||||
else:
|
else:
|
||||||
await m.edit(xxx)
|
await m.edit(xxx)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
# Commit Start Date 20/10/2021
|
# Commit Start Date 20/10/2021
|
||||||
# Finished On 28/10/2021
|
# Finished On 28/10/2021
|
||||||
|
|
||||||
import os
|
|
||||||
# pyrogram stuff
|
# pyrogram stuff
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ from driver.design.chatname import CHAT_TITLE
|
|||||||
from driver.filters import command, other_filters
|
from driver.filters import command, other_filters
|
||||||
from driver.queues import QUEUE, add_to_queue
|
from driver.queues import QUEUE, add_to_queue
|
||||||
from driver.core import calls, user, bot
|
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.dbpunish import is_gbanned_user
|
||||||
from driver.database.dblockchat import blacklisted_chats
|
from driver.database.dblockchat import blacklisted_chats
|
||||||
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
||||||
@ -176,7 +175,7 @@ async def play(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
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:
|
else:
|
||||||
try:
|
try:
|
||||||
gcname = m.chat.title
|
gcname = m.chat.title
|
||||||
@ -208,7 +207,7 @@ async def play(c: Client, m: Message):
|
|||||||
caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
await idle()
|
||||||
os.remove(image)
|
remove_if_exists(image)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await suhu.delete()
|
await suhu.delete()
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
@ -252,7 +251,7 @@ async def play(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
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:
|
else:
|
||||||
try:
|
try:
|
||||||
await suhu.edit("🔄 Joining Group Call...")
|
await suhu.edit("🔄 Joining Group Call...")
|
||||||
@ -278,7 +277,7 @@ async def play(c: Client, m: Message):
|
|||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
await idle()
|
||||||
os.remove(image)
|
remove_if_exists(image)
|
||||||
except Exception as ep:
|
except Exception as ep:
|
||||||
await suhu.delete()
|
await suhu.delete()
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
@ -320,7 +319,7 @@ async def play(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
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:
|
else:
|
||||||
try:
|
try:
|
||||||
await suhu.edit("🔄 Joining Group Call...")
|
await suhu.edit("🔄 Joining Group Call...")
|
||||||
@ -344,7 +343,7 @@ async def play(c: Client, m: Message):
|
|||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
await idle()
|
||||||
os.remove(image)
|
remove_if_exists(image)
|
||||||
except Exception as ep:
|
except Exception as ep:
|
||||||
await suhu.delete()
|
await suhu.delete()
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# credit to TeamYukki for this speedtest module
|
# credit to TeamYukki for this speedtest module
|
||||||
|
|
||||||
import os
|
|
||||||
import wget
|
import wget
|
||||||
import speedtest
|
import speedtest
|
||||||
|
|
||||||
@ -9,6 +8,7 @@ from driver.filters import command, other_filters
|
|||||||
from driver.decorators import sudo_users_only
|
from driver.decorators import sudo_users_only
|
||||||
from config import BOT_USERNAME as bname
|
from config import BOT_USERNAME as bname
|
||||||
from driver.core import bot as app
|
from driver.core import bot as app
|
||||||
|
from driver.utils import remove_if_exists
|
||||||
from pyrogram import Client, filters
|
from pyrogram import Client, filters
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
|
|
||||||
@ -48,5 +48,5 @@ async def run_speedtest(_, message: Message):
|
|||||||
msg = await app.send_photo(
|
msg = await app.send_photo(
|
||||||
chat_id=message.chat.id, photo=path, caption=output
|
chat_id=message.chat.id, photo=path, caption=output
|
||||||
)
|
)
|
||||||
os.remove(path)
|
remove_if_exists(path)
|
||||||
await m.delete()
|
await m.delete()
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
# Finished On 28/10/2021
|
# Finished On 28/10/2021
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import asyncio
|
import asyncio
|
||||||
import traceback
|
import traceback
|
||||||
@ -18,6 +17,7 @@ from driver.core import calls, user, bot
|
|||||||
from driver.database.dbpunish import is_gbanned_user
|
from driver.database.dbpunish import is_gbanned_user
|
||||||
from driver.database.dblockchat import blacklisted_chats
|
from driver.database.dblockchat import blacklisted_chats
|
||||||
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
||||||
|
from driver.utils import remove_if_exists
|
||||||
# pyrogram stuff
|
# pyrogram stuff
|
||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
||||||
@ -200,7 +200,7 @@ async def vplay(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
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:
|
else:
|
||||||
await loser.edit("🔄 Joining Group Call...")
|
await loser.edit("🔄 Joining Group Call...")
|
||||||
gcname = m.chat.title
|
gcname = m.chat.title
|
||||||
@ -236,7 +236,7 @@ async def vplay(c: Client, m: Message):
|
|||||||
caption=f"🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
caption=f"🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
await idle()
|
||||||
os.remove(image)
|
remove_if_exists(image)
|
||||||
else:
|
else:
|
||||||
if len(m.command) < 2:
|
if len(m.command) < 2:
|
||||||
await m.reply(
|
await m.reply(
|
||||||
@ -277,7 +277,7 @@ async def vplay(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
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:
|
else:
|
||||||
try:
|
try:
|
||||||
await loser.edit("🔄 Joining Group Call...")
|
await loser.edit("🔄 Joining Group Call...")
|
||||||
@ -302,7 +302,7 @@ async def vplay(c: Client, m: Message):
|
|||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
await idle()
|
||||||
os.remove(image)
|
remove_if_exists(image)
|
||||||
except Exception as ep:
|
except Exception as ep:
|
||||||
await loser.delete()
|
await loser.delete()
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
@ -348,7 +348,7 @@ async def vplay(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
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:
|
else:
|
||||||
try:
|
try:
|
||||||
await loser.edit("🔄 Joining Group Call...")
|
await loser.edit("🔄 Joining Group Call...")
|
||||||
@ -373,7 +373,7 @@ async def vplay(c: Client, m: Message):
|
|||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
await idle()
|
||||||
os.remove(image)
|
remove_if_exists(image)
|
||||||
except Exception as ep:
|
except Exception as ep:
|
||||||
await loser.delete()
|
await loser.delete()
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user