[check] some fixes

This commit is contained in:
levina 2022-03-02 09:41:54 +07:00 committed by GitHub
parent 9220ea503f
commit 4dba95ac75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/licenses.html
import re import re
import asyncio import asyncio
import traceback
from config import BOT_USERNAME, IMG_1, IMG_2, IMG_5 from config import BOT_USERNAME, IMG_1, IMG_2, IMG_5
from driver.decorators import require_admin, check_blacklist from driver.decorators import require_admin, check_blacklist
@ -59,7 +58,7 @@ def ytsearch(query: str):
thumbnail = data["thumbnails"][0]["url"] thumbnail = data["thumbnails"][0]["url"]
return [songname, url, duration, thumbnail] return [songname, url, duration, thumbnail]
except Exception as e: except Exception as e:
print(e) LOGS.info(f"[ERROR]: {e}")
return 0 return 0
@ -96,7 +95,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
try: try:
replied = await from_tg_get_msg(link) replied = await from_tg_get_msg(link)
except Exception as e: except Exception as e:
traceback.print_exc() LOGS.info(f"[ERROR]: {e}")
return await m.reply_text(f"🚫 error:\n\n» {e}") return await m.reply_text(f"🚫 error:\n\n» {e}")
if not replied: if not replied:
return await m.reply( return await m.reply(
@ -192,10 +191,9 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
except (NoActiveGroupCall, GroupCallNotFound): except (NoActiveGroupCall, GroupCallNotFound):
await loser.delete() await loser.delete()
await remove_active_chat(chat_id) await remove_active_chat(chat_id)
traceback.print_exc()
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !") await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
except BaseException as err: except BaseException as e:
print(err) LOGS.info(f"[ERROR]: {e}")
else: else:
await m.reply( await m.reply(
"» reply to an **video file** or **give something to search.**" "» reply to an **video file** or **give something to search.**"
@ -248,7 +246,7 @@ async def vplay(c: Client, m: Message):
except UserAlreadyParticipant: except UserAlreadyParticipant:
pass pass
except Exception as e: except Exception as e:
traceback.print_exc() LOGS.info(f"[ERROR]: {e}")
return await m.reply_text( return await m.reply_text(
f"❌ **userbot failed to join**\n\n**reason**: `{e}`" f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
) )
@ -332,8 +330,8 @@ async def vplay(c: Client, m: Message):
await loser.delete() await loser.delete()
await remove_active_chat(chat_id) await remove_active_chat(chat_id)
await m.reply_text("❌ The content you provide to play has no audio source") await m.reply_text("❌ The content you provide to play has no audio source")
except BaseException as err: except BaseException as e:
print(err) LOGS.info(f"[ERROR]: {e}")
else: else:
if len(m.command) < 2: if len(m.command) < 2:
@ -417,8 +415,8 @@ async def vplay(c: Client, m: Message):
await loser.delete() await loser.delete()
await remove_active_chat(chat_id) await remove_active_chat(chat_id)
await m.reply_text("❌ The content you provide to play has no audio source") await m.reply_text("❌ The content you provide to play has no audio source")
except BaseException as err: except BaseException as e:
print(err) LOGS.info(f"[ERROR]: {e}")
@Client.on_message(command(["vstream", f"vstream@{BOT_USERNAME}"]) & other_filters) @Client.on_message(command(["vstream", f"vstream@{BOT_USERNAME}"]) & other_filters)
@ -436,20 +434,21 @@ async def vstream(c: Client, m: Message):
ubot = me_user.id ubot = me_user.id
b = await c.get_chat_member(chat_id, ubot) b = await c.get_chat_member(chat_id, ubot)
if b.status == "banned": if b.status == "banned":
await m.reply_text("❌ The userbot is banned in this chat, unban the userbot first to be able to play music !") try:
return await m.reply_text("❌ The userbot is banned in this chat, unban the userbot first to be able to play music !")
invitelink = (await c.get_chat(chat_id)).invite_link await remove_active_chat(chat_id)
if not invitelink: except BaseException:
await c.export_chat_invite_link(chat_id) pass
invitelink = (await c.get_chat(chat_id)).invite_link invitelink = (await c.get_chat(chat_id)).invite_link
if invitelink.startswith("https://t.me/+"): if not invitelink:
invitelink = invitelink.replace( await c.export_chat_invite_link(chat_id)
"https://t.me/+", "https://t.me/joinchat/" invitelink = (await c.get_chat(chat_id)).invite_link
) if invitelink.startswith("https://t.me/+"):
invitelink = invitelink.replace(
"https://t.me/+", "https://t.me/joinchat/"
)
await user.join_chat(invitelink) await user.join_chat(invitelink)
await remove_active_chat(chat_id) await remove_active_chat(chat_id)
except UserAlreadyParticipant:
pass
except UserNotParticipant: except UserNotParticipant:
try: try:
invitelink = (await c.get_chat(chat_id)).invite_link invitelink = (await c.get_chat(chat_id)).invite_link
@ -465,7 +464,7 @@ async def vstream(c: Client, m: Message):
except UserAlreadyParticipant: except UserAlreadyParticipant:
pass pass
except Exception as e: except Exception as e:
traceback.print_exc() LOGS.info(f"[ERROR]: {e}")
return await m.reply_text( return await m.reply_text(
f"❌ **userbot failed to join**\n\n**reason**: `{e}`" f"❌ **userbot failed to join**\n\n**reason**: `{e}`"
) )
@ -492,7 +491,7 @@ async def vstream(c: Client, m: Message):
) )
loser = await c.send_message(chat_id, "🔍 **Loading...**") loser = await c.send_message(chat_id, "🔍 **Loading...**")
else: else:
await m.reply(f"`/vstream` {url} (720/480/360)") pass
regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+" regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+"
match = re.match(regex, url) match = re.match(regex, url)
@ -553,5 +552,5 @@ async def vstream(c: Client, m: Message):
await loser.delete() await loser.delete()
await remove_active_chat(chat_id) await remove_active_chat(chat_id)
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !") await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
except BaseException as err: except BaseException as e:
print(err) LOGS.info(f"[ERROR]: {e}")