Add more error output

This commit is contained in:
xtaodada 2022-02-13 14:27:09 +08:00
parent b656910a10
commit afa436c050
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
6 changed files with 30 additions and 0 deletions

View File

@ -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

View File

@ -1,4 +1,6 @@
import os
import traceback
from cache.admins import admins
from driver.core import calls, bot
from pyrogram import Client, filters
@ -71,6 +73,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 +100,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 +127,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**")
@ -201,6 +206,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 +233,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 +258,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 +283,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 +306,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 +331,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 +356,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 +383,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**")

View File

@ -4,6 +4,8 @@ import os
import re
import time
import asyncio
import traceback
import lyricsgenius
import aiofiles
@ -126,6 +128,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...")

View File

@ -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

View File

@ -4,6 +4,8 @@
import os
# pyrogram stuff
import traceback
from pyrogram import Client
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
from pyrogram.types import InlineKeyboardMarkup, Message
@ -81,6 +83,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 +139,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}`"
)
@ -208,6 +212,7 @@ async def play(c: Client, m: Message):
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:

View File

@ -6,6 +6,7 @@
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
@ -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}`"
)
@ -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}`"
)