diff --git a/plugins/callback.py b/plugins/callback.py index 7c4da249..d7857dec 100644 --- a/plugins/callback.py +++ b/plugins/callback.py @@ -13,6 +13,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import os + from utils import LOGGER from pyrogram import Client from contextlib import suppress @@ -107,9 +109,9 @@ async def cb_handler(client: Client, query: CallbackQuery): elif query.data.startswith("help"): if query.message.chat.type != "private" and query.message.reply_to_message.from_user is None: - return await query.answer("I cant help you here, since you are an anonymous admin, message me in private chat.", show_alert=True) + return await query.answer("I can't help you here, since you are an anonymous admin, message me in private chat.", show_alert=True) elif query.message.chat.type != "private" and query.from_user.id != query.message.reply_to_message.from_user.id: - return await query.answer("Okda", show_alert=True) + return await query.answer("You need to be an admin to do this.", show_alert=True) me, nyav = query.data.split("_") back=InlineKeyboardMarkup( [ @@ -160,16 +162,16 @@ async def cb_handler(client: Client, query: CallbackQuery): if not query.from_user.id in admins: await query.answer( - "πŸ˜’ Played Joji.mp3", + "You need to be an admin to do this.", show_alert=True ) return #scheduler stuffs if query.data.startswith("sch"): if query.message.chat.type != "private" and query.message.reply_to_message.from_user is None: - return await query.answer("You cant use scheduling here, since you are an anonymous admin. Schedule from private chat.", show_alert=True) + return await query.answer("You can't use scheduling here, since you are an anonymous admin. Schedule from private chat.", show_alert=True) if query.message.chat.type != "private" and query.from_user.id != query.message.reply_to_message.from_user.id: - return await query.answer("Okda", show_alert=True) + return await query.answer("Ok, I will do this.", show_alert=True) data = query.data today = datetime.datetime.now(IST) smonth=today.strftime("%B") @@ -195,7 +197,7 @@ async def cb_handler(client: Client, query: CallbackQuery): button.append([InlineKeyboardButton(text=f"{str(month)} {str(year_)}",callback_data=f"sch_showdate_{year_}_{k}")]) button = button + button_ button.append([InlineKeyboardButton("Close", callback_data="schclose")]) - await query.message.edit("Now Choose the month to schedule a voicechatγ…€ γ…€γ…€", reply_markup=InlineKeyboardMarkup(button)) + await query.message.edit("Now choose the month to schedule a video chatγ…€ γ…€γ…€", reply_markup=InlineKeyboardMarkup(button)) elif day == "none": return else: @@ -223,7 +225,7 @@ async def cb_handler(client: Client, query: CallbackQuery): else: pyear=year button.append([InlineKeyboardButton("Back", callback_data=f"sch_showdate_{pyear}_{month}"), InlineKeyboardButton("Close", callback_data="schclose")]) - await query.message.edit(f"Choose the hour of {date} {smonth} {year} to schedule a voicechat.", reply_markup=InlineKeyboardMarkup(button)) + await query.message.edit(f"Choose the hour of {date} {smonth} {year} to schedule a video chat.", reply_markup=InlineKeyboardMarkup(button)) elif data.startswith("sch_day"): none, none, year, month, day, hour = data.split("_") @@ -260,7 +262,7 @@ async def cb_handler(client: Client, query: CallbackQuery): datetime_object = datetime.datetime.strptime(str(month), "%m") smonth = datetime_object.strftime("%B") if year == today.year and month == today.month and day == today.day and hour == today.hour and minute <= today.minute: - await query.answer("I dont have a timemachine to go to past!!!.") + await query.answer("I don't have a time machine to go to past!!!") return final=f"{day}th {smonth} {year} at {hour}:{minute}" button=[ @@ -274,7 +276,7 @@ async def cb_handler(client: Client, query: CallbackQuery): ] data=Config.SCHEDULED_STREAM.get(f"{query.message.chat.id}_{query.message.message_id}") if not data: - await query.answer("This schedule is expired", show_alert=True) + await query.answer("This schedule is expired.", show_alert=True) if data['3'] == "telegram": title=data['1'] else: @@ -312,7 +314,7 @@ async def cb_handler(client: Client, query: CallbackQuery): f.append(InlineKeyboardButton(text=f"{k}",callback_data=f"sch_month_{year_}_{month}_{d}")) button.append(f) button.append([InlineKeyboardButton("Close", callback_data="schclose")]) - await query.message.edit(f"Choose the day of the month you want to schedule the voicechat.\nToday is {thisday} {smonth} {tyear}. Chooosing a date preceeding today will be considered as next year {year+1}", reply_markup=InlineKeyboardMarkup(button)) + await query.message.edit(f"Choose the day of the month you want to schedule the video chat.\nToday is {thisday} {smonth} {tyear}. Chooosing a date preceeding today will be considered as next year {year+1}", reply_markup=InlineKeyboardMarkup(button)) elif data.startswith("schconfirm"): none, date = data.split("_") @@ -333,13 +335,15 @@ async def cb_handler(client: Client, query: CallbackQuery): elif query.data == "schcancel": buttons = [ [ - InlineKeyboardButton('Yes, Iam Sure!!', callback_data='schcancelall'), + InlineKeyboardButton('Yes, I'm sure!!', callback_data='schcancelall'), InlineKeyboardButton('No', callback_data='schclose'), ] ] - await query.message.edit("Are you sure that you want to cancel all the scheduled streams?", reply_markup=InlineKeyboardMarkup(buttons)) + await query.message.edit( + "Are you sure that you want to cancel all the scheduled streams?", + reply_markup=InlineKeyboardMarkup(buttons)) elif data == "schclose": - await query.answer("Menu Closed") + await query.answer("Menu closed successfully") await query.message.delete() await query.message.reply_to_message.delete() @@ -452,6 +456,33 @@ async def cb_handler(client: Client, query: CallbackQuery): await restart() await query.message.edit(text=await get_playlist_str(), reply_markup=await get_buttons(), disable_web_page_preview=True) + elif query.data == 'recheck_log': + button=[ + [ + InlineKeyboardButton(text='πŸ” Refresh Logs', callback_data='recheck_log'), + InlineKeyboardButton(text='πŸ—‘οΈ Close', callback_data='close'), + ] + ] + await query.answer("Checking logs...") + if os.path.exists('botlog.txt'): + if query.message.document: + await query.message.edit_document( + 'botlog.txt', + caption="Bot Logs", + reply_markup=button + ) + await delete_messages([message]) + else: + await query.message.delete() + await message.reply_document( + 'botlog.txt', + caption="Bot Logs", + reply_markup=button + ) + await delete_messages([message]) + else: + await query.message.answer("No log files found. Try again using refresh logs button.") + elif query.data.startswith("volume"): me, you = query.data.split("_") if you == "main": @@ -539,7 +570,7 @@ async def cb_handler(client: Client, query: CallbackQuery): elif query.data == "set_new_chat": if query.from_user is None: - return await query.answer("You cant do scheduling here, since you are an anonymous admin. Schedule from private chat.", show_alert=True) + return await query.answer("You can't do scheduling here, since you are an anonymous admin. Schedule from private chat.", show_alert=True) if query.from_user.id in Config.SUDO: await query.answer("Setting up new CHAT") chat=query.message.chat.id @@ -571,7 +602,7 @@ async def cb_handler(client: Client, query: CallbackQuery): elif query.from_user.id in Config.ADMINS: pass else: - return await query.answer("Okda", show_alert=True) - await query.answer("Menu Closed") + return await query.answer("You need to be an admin to do this.", show_alert=True) + await query.answer("Menu closed successfully") await query.message.delete() await query.answer() diff --git a/plugins/commands.py b/plugins/commands.py index 05dd56fa..29defb9b 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -53,7 +53,7 @@ if Config.DATABASE_URI: from utils import db -HOME_TEXT = "Hey [{}](tg://user?id={}) πŸ™‹β€β™‚οΈ\n\nIam A Bot Built To Play or Stream Videos In Telegram VoiceChats.\nI Can Stream Any YouTube Video Or A Telegram File Or Even A YouTube Live." +HOME_TEXT = "Hey [{}](tg://user?id={}) πŸ™‹β€β™‚οΈ\n\nI'm a Bot built to Play or Stream Videos in Telegram Video Chats.\nI can Stream any YouTube Video or a Telegram File or even a YouTube Live." admin_filter=filters.create(is_admin) @Client.on_message(filters.command(['start', f"start@{Config.BOT_USERNAME}"])) @@ -78,7 +78,7 @@ async def start(client, message): ], ] ) - await message.reply("Learn to use the VCPlayer, Showing help menu, Choose from the below options.", + await message.reply("Learn to use the VCPlayer. Showing help menu, Choose from the below options.", reply_markup=reply_markup, disable_web_page_preview=True ) @@ -87,13 +87,13 @@ async def start(client, message): you, me = message.command[1].split("_", 1) who=Config.SCHEDULED_STREAM.get(me) if not who: - return await msg.edit("Something gone somewhere.") + return await msg.edit("Oops! Something went wrong.") del Config.SCHEDULED_STREAM[me] whom=f"{message.chat.id}_{msg.message_id}" Config.SCHEDULED_STREAM[whom] = who await sync_to_db() if message.from_user.id not in Config.ADMINS: - return await msg.edit("OK da") + return await msg.edit("You can't manage schedules, because you are not an admin.") today = datetime.now(IST) smonth=today.strftime("%B") obj = calendar.Calendar() @@ -122,7 +122,7 @@ async def start(client, message): f.append(InlineKeyboardButton(text=f"{k}",callback_data=f"sch_month_{year_}_{month}_{d}")) button.append(f) button.append([InlineKeyboardButton("Close", callback_data="schclose")]) - await msg.edit(f"Choose the day of the month you want to schedule the voicechat.\nToday is {thisday} {smonth} {year}. Chooosing a date preceeding today will be considered as next year {year+1}", reply_markup=InlineKeyboardMarkup(button)) + await msg.edit(f"Choose the day of the month you want to schedule the video chat.\nToday is {thisday} {smonth} {year}. Chooosing a date preceeding today will be considered as next year {year+1}", reply_markup=InlineKeyboardMarkup(button)) @@ -166,7 +166,7 @@ async def show_help(client, message): ) if message.chat.type != "private" and message.from_user is None: k=await message.reply( - text="I cant help you here, since you are an anonymous admin. Get help in PM", + text="I can't help you here, since you are an anonymous admin. Get help in PM.", reply_markup=InlineKeyboardMarkup( [ [ @@ -179,7 +179,7 @@ async def show_help(client, message): if Config.msg.get('help') is not None: await Config.msg['help'].delete() Config.msg['help'] = await message.reply_text( - "Learn to use the VCPlayer, Showing help menu, Choose from the below options.", + "Learn to use the VCPlayer. Showing help menu, Choose from the below options.", reply_markup=reply_markup, disable_web_page_preview=True ) @@ -196,7 +196,10 @@ async def repo_(client, message): InlineKeyboardButton('πŸ—‘ Close', callback_data='close'), ] ] - await message.reply("The source code of this bot is public and can be found at VCPlayerBot.\nYou can deploy your own bot and use in your group.\n\nFeel free to starβ˜€οΈ the repo if you liked it πŸ™ƒ.", reply_markup=InlineKeyboardMarkup(buttons), disable_web_page_preview=True) + await message.reply( + "The source code of this bot is public and can be found at VCPlayerBot.\nYou can deploy your own bot and use in your group.\n\nFeel free to star 🌟 the repo if you liked it πŸ™ƒ.", + reply_markup=InlineKeyboardMarkup(buttons), + disable_web_page_preview=True) await delete_messages([message]) @Client.on_message(filters.command(['restart', 'update', f"restart@{Config.BOT_USERNAME}", f"update@{Config.BOT_USERNAME}"]) & admin_filter & chat_filter) @@ -227,18 +230,29 @@ async def update_handler(client, message): @Client.on_message(filters.command(['logs', f"logs@{Config.BOT_USERNAME}"]) & admin_filter & chat_filter) async def get_logs(client, message): m=await message.reply("Checking logs..") + button=[ + [ + InlineKeyboardButton(text='πŸ” Refresh Logs', callback_data='recheck_log'), + InlineKeyboardButton(text='πŸ—‘οΈ Close', callback_data='close'), + ] + ] if os.path.exists("botlog.txt"): - await message.reply_document('botlog.txt', caption="Bot Logs") + await message.reply_document( + 'botlog.txt', + caption="Bot Logs", + ) await m.delete() await delete_messages([message]) else: - k = await m.edit("No log files found.") + k = await m.edit( + "No log files found.", + reply_markup=button) await delete_messages([message, k]) @Client.on_message(filters.command(['env', f"env@{Config.BOT_USERNAME}", "config", f"config@{Config.BOT_USERNAME}"]) & sudo_filter & chat_filter) async def set_heroku_var(client, message): with suppress(MessageIdInvalid, MessageNotModified): - m = await message.reply("Checking config vars..") + m = await message.reply("Checking Config Vars..") if " " in message.text: cmd, env = message.text.split(" ", 1) if "=" in env: @@ -268,7 +282,7 @@ async def set_heroku_var(client, message): return if Config.DATABASE_URI and var in ["STARTUP_STREAM", "CHAT", "LOG_GROUP", "REPLY_MESSAGE", "DELAY", "RECORDING_DUMP", "QUALITY"]: - await m.edit("Mongo DB Found, Setting up config vars...") + await m.edit("MongoDB Found, Setting up config vars...") await asyncio.sleep(2) if not value: await m.edit(f"No value for env specified. Trying to delete env {var}.") @@ -300,7 +314,7 @@ async def set_heroku_var(client, message): elif value == "low": value = 50 else: - await m.edit("You should give me a chat id . It should be an interger.") + await m.edit("You should give me a chat id. It should be an interger.") await delete_messages([message, m]) return if var == "CHAT": @@ -337,7 +351,7 @@ async def set_heroku_var(client, message): if not Config.HEROKU_APP: buttons = [[InlineKeyboardButton('Heroku API_KEY', url='https://dashboard.heroku.com/account/applications/authorizations/new'), InlineKeyboardButton('πŸ—‘ Close', callback_data='close'),]] await m.edit( - text="No heroku app found, this command needs the following heroku vars to be set.\n\n1. HEROKU_API_KEY: Your heroku account api key.\n2. HEROKU_APP_NAME: Your heroku app name.", + text="No Heroku app found, this command needs the following heroku vars to be set.\n\n1. HEROKU_API_KEY: Your heroku account api key.\n2. HEROKU_APP_NAME: Your heroku app name.", reply_markup=InlineKeyboardMarkup(buttons)) await delete_messages([message]) return