diff --git a/bot/functions/gen_qr.py b/bot/functions/gen_qr.py index cd49e83..2f8541f 100644 --- a/bot/functions/gen_qr.py +++ b/bot/functions/gen_qr.py @@ -11,7 +11,7 @@ async def func_gen_qr(update: Update, context: ContextTypes.DEFAULT_TYPE): data = " ".join(context.args) or (re_msg.text or re_msg.caption if re_msg else None) if not data: - await Message.reply_msg(update, "Use /qr 'url/data/text' to generate a QR code image.\nor reply the 'url/data/text' with /qr command.\nE.g. /qr https://google.com") + await Message.reply_msg(update, "Use /qr url/data/text to generate a QR code image.\nor reply the 'url/data/text' with /qr command.\nE.g. /qr https://google.com") return sent_msg = await Message.reply_msg(update, f"Generating...") diff --git a/bot/functions/broadcast.py b/bot/functions/owner_func/broadcast.py similarity index 100% rename from bot/functions/broadcast.py rename to bot/functions/owner_func/broadcast.py diff --git a/bot/functions/bsettings.py b/bot/functions/owner_func/bsettings.py similarity index 100% rename from bot/functions/bsettings.py rename to bot/functions/owner_func/bsettings.py diff --git a/bot/functions/database.py b/bot/functions/owner_func/database.py similarity index 100% rename from bot/functions/database.py rename to bot/functions/owner_func/database.py diff --git a/bot/functions/log.py b/bot/functions/owner_func/log.py similarity index 100% rename from bot/functions/log.py rename to bot/functions/owner_func/log.py diff --git a/bot/functions/restart.py b/bot/functions/owner_func/restart.py similarity index 100% rename from bot/functions/restart.py rename to bot/functions/owner_func/restart.py diff --git a/bot/functions/owner_func/send.py b/bot/functions/owner_func/send.py new file mode 100644 index 0000000..7340050 --- /dev/null +++ b/bot/functions/owner_func/send.py @@ -0,0 +1,77 @@ +import asyncio +from telegram import Update +from telegram.ext import ContextTypes +from telegram.error import Forbidden +from bot.helper.telegram_helper import Message +from bot.functions.power_users import _power_users + + +async def func_send(update: Update, context: ContextTypes.DEFAULT_TYPE): + user = update.effective_user + chat = update.effective_chat + e_msg = update.effective_message + re_msg = update.message.reply_to_message + text = " ".join(context.args) # contains something if forward is true and contains victim_id >> /send f chat_id + + power_users = await _power_users() + if user.id not in power_users: + await Message.reply_msg(update, "Access denied!") + return + + if chat.type != "private": + await Message.reply_msg(update, f"Boss you are in public chat!") + await asyncio.sleep(3) + await Message.del_msgs(chat.id, [e_msg.id, e_msg.id + 1]) + return + + if not text or not re_msg: + msg = ( + "Use /send chat_id by replying a message!\n" + "/send f chat_id to forward the replied message to chat_id!\n" + "Returns reaction on message\n" + "Sent - '👍'\n" + "Forbidden - '👎'\n" + "Something went wrong - '⚠️'" + ) + await Message.reply_msg(update, msg) + return + + forward_confirm, victim_id = None, text + + splited_text = text.split() + if len(splited_text) == 2: + forward_confirm, victim_id = splited_text + + if forward_confirm: + sent_msg = await Message.forward_msg(victim_id, chat.id, re_msg.id) + else: + text = re_msg.text_html + photo = re_msg.photo + audio = re_msg.audio + video = re_msg.video + document = re_msg.document + caption = re_msg.caption_html + + # in future update + # voice = e_msg.voice + # video_note = e_msg.video_note + + if text: + sent_msg = await Message.send_msg(victim_id, text) + elif photo: + sent_msg = await Message.send_img(victim_id, photo[-1].file_id, caption) + elif audio: + sent_msg = await Message.send_audio(victim_id, audio.file_id, audio.file_name, caption) + elif video: + sent_msg = await Message.send_vid(victim_id, video.file_id, caption=caption) + elif document: + sent_msg = await Message.send_doc(victim_id, document.file_id, document.file_name, caption) + + if not sent_msg: + reaction = "⚠️" + elif sent_msg == Forbidden: + reaction = "👎" + else: + reaction = "👍" + + await Message.react_msg(chat.id, e_msg.id, reaction) diff --git a/bot/functions/shell.py b/bot/functions/owner_func/shell.py similarity index 94% rename from bot/functions/shell.py rename to bot/functions/owner_func/shell.py index 417ee71..325ffd8 100644 --- a/bot/functions/shell.py +++ b/bot/functions/owner_func/shell.py @@ -27,7 +27,7 @@ async def func_shell(update: Update, context: ContextTypes.DEFAULT_TYPE): return if not command: - await Message.reply_msg(update, "Use /shell 'dir/ls' [linux/Windows Depend on your hosting server]") + await Message.reply_msg(update, "Use /shell dir/ls [linux/Windows Depend on your hosting server]") return sent_msg = await Message.reply_msg(update, "⌊ please wait... ⌉") @@ -59,5 +59,5 @@ async def func_shell(update: Update, context: ContextTypes.DEFAULT_TYPE): await Message.edit_msg(update, e, sent_msg) return - await Message.send_doc(chat.id, shell, "shell.txt", f"Command: {command}\nExecute time: {(time_executed - time_executing):.2f}s", e_msg.id) await Message.del_msg(chat.id, sent_msg) + await Message.send_doc(chat.id, shell, "shell.txt", f"Command: {command}\nExecute time: {(time_executed - time_executing):.2f}s", e_msg.id) diff --git a/bot/functions/sys.py b/bot/functions/owner_func/sys.py similarity index 100% rename from bot/functions/sys.py rename to bot/functions/owner_func/sys.py diff --git a/bot/functions/paste.py b/bot/functions/paste.py index f1867c6..f3a6200 100644 --- a/bot/functions/paste.py +++ b/bot/functions/paste.py @@ -9,7 +9,7 @@ async def func_paste(update: Update, context: ContextTypes.DEFAULT_TYPE): text = (re_msg.text_html or re_msg.caption_html) if re_msg else " ".join(context.args) if not text: - await Message.reply_msg(update, "Use /paste 'text' or reply the message/text with /paste command.") + await Message.reply_msg(update, "Use /paste text or reply the message/text with /paste command.") return sent_msg = await Message.reply_msg(update, f"Creating...") diff --git a/bot/functions/ping.py b/bot/functions/ping.py index bdafae1..ec076ff 100644 --- a/bot/functions/ping.py +++ b/bot/functions/ping.py @@ -8,7 +8,7 @@ async def func_ping(update: Update, context: ContextTypes.DEFAULT_TYPE): url = " ".join(context.args) if not url: - await Message.reply_msg(update, "Use /ping 'url'\nE.g. /ping https://google.com") + await Message.reply_msg(update, "Use /ping url\nE.g. /ping https://google.com") return if url[0:4] != "http": diff --git a/bot/functions/psndl.py b/bot/functions/psndl.py index 9ed823f..0d26338 100644 --- a/bot/functions/psndl.py +++ b/bot/functions/psndl.py @@ -12,7 +12,7 @@ async def func_psndl(update: Update, context: ContextTypes.DEFAULT_TYPE): keyword = " ".join(context.args) if not keyword: - await Message.reply_msg(update, "Use /psndl 'game name'\nE.g. /psndl grand theft auto") + await Message.reply_msg(update, "Use /psndl game name\nE.g. /psndl grand theft auto") return if len(keyword) < 5: @@ -70,7 +70,7 @@ async def func_rap(update: Update, context: ContextTypes.DEFAULT_TYPE): rap_data = " ".join(context.args) if not rap_data: - await Message.reply_msg(update, "Use /rap 'rap_data'\nE.g. /rap D78710F4C0979FAD9CDB40C612C94F60\nNote: You will get the rap data after searching content/game using /psndl command.") + await Message.reply_msg(update, "Use /rap rap_data\nE.g. /rap D78710F4C0979FAD9CDB40C612C94F60\nNote: You will get the rap data after searching content/game using /psndl command.") return sent_msg = await Message.reply_msg(update, "Creating...") diff --git a/bot/functions/send.py b/bot/functions/send.py deleted file mode 100644 index 5f30460..0000000 --- a/bot/functions/send.py +++ /dev/null @@ -1,55 +0,0 @@ -import asyncio -from telegram import Update -from telegram.ext import ContextTypes -from telegram.error import Forbidden -from bot.helper.telegram_helper import Message -from bot.functions.power_users import _power_users - - -async def func_send(update: Update, context: ContextTypes.DEFAULT_TYPE): - user = update.effective_user - chat = update.effective_chat - e_msg = update.effective_message - re_msg = update.message.reply_to_message - text = " ".join(context.args) - - power_users = await _power_users() - if user.id not in power_users: - await Message.reply_msg(update, "Access denied!") - return - - if chat.type != "private": - await Message.reply_msg(update, f"Boss you are in public chat!") - await asyncio.sleep(3) - await Message.del_msgs(chat.id, [e_msg.id, e_msg.id + 1]) - return - - if not text or not re_msg: - await Message.reply_msg(update, "Use /send 'chat_id' by replying a message!\n/send f 'chat_id' to forward the replied message to chat_id!") - return - - forward_confirm, chat_id = None, text - - splited_text = text.split() - if len(splited_text) == 2: - forward_confirm, chat_id = splited_text - - msg = re_msg.text_html or re_msg.caption_html if re_msg else None - - if forward_confirm: - sent_msg = await Message.forward_msg(chat_id, chat.id, re_msg.id) - else: - if re_msg.text_html: - sent_msg = await Message.send_msg(chat_id, msg) - elif re_msg.caption_html: - sent_msg = await Message.send_img(chat_id, re_msg.photo[-1].file_id, msg) - - if not sent_msg: - msg, reaction = "An error occurred!", "🤔" - elif sent_msg == Forbidden: - msg, reaction = "Forbidden!", "👎" - else: - msg, reaction = "Message Sent!", "👍" - - await Message.react_msg(chat.id, re_msg.id, reaction) - await Message.reply_msg(update, msg) diff --git a/bot/functions/shortener.py b/bot/functions/shortener.py index aad471f..9052352 100644 --- a/bot/functions/shortener.py +++ b/bot/functions/shortener.py @@ -9,7 +9,7 @@ async def func_shortener(update: Update, context: ContextTypes.DEFAULT_TYPE): msg = (re_msg.text or re_msg.caption) if re_msg else " ".join(context.args) if not msg: - await Message.reply_msg(update, "Use /short 'url'\nor reply the url with /short command.\nE.g. /short https://google.com") + await Message.reply_msg(update, "Use /short url\nor reply the url with /short command.\nE.g. /short https://google.com") return shorted_url = await shortener_url(msg) diff --git a/bot/functions/translator.py b/bot/functions/translator.py index 951ddea..edd6fb8 100644 --- a/bot/functions/translator.py +++ b/bot/functions/translator.py @@ -18,7 +18,7 @@ async def func_translator(update: Update, context: ContextTypes.DEFAULT_TYPE): "Language code's": "https://telegra.ph/Language-Code-12-24" } btn = await Button.ubutton(btn_data) - await Message.reply_msg(update, "Use /tr 'text' or /tr lang_code 'text' or reply the text with /tr or /tr lang_code\n\nEnable auto translator mode for this chat from /settings", btn=btn) + await Message.reply_msg(update, "Use /tr text or /tr lang_code text or reply the text with /tr or /tr lang_code\n\nEnable auto translator mode for this chat from /settings", btn=btn) return to_translate = None diff --git a/bot/functions/weather.py b/bot/functions/weather.py index 2895665..6df1551 100644 --- a/bot/functions/weather.py +++ b/bot/functions/weather.py @@ -8,7 +8,7 @@ async def func_weather(update: Update, context: ContextTypes.DEFAULT_TYPE): location = " ".join(context.args) if not location: - await Message.reply_msg(update, "Use /weather 'location name'\nE.g. /weather london") + await Message.reply_msg(update, "Use /weather location_name\nE.g. /weather london") return info = await weather_info(location) diff --git a/bot/functions/whisper.py b/bot/functions/whisper.py index bc2009f..4d824cf 100644 --- a/bot/functions/whisper.py +++ b/bot/functions/whisper.py @@ -17,7 +17,7 @@ async def func_whisper(update: Update, context: ContextTypes.DEFAULT_TYPE): return if not msg: - await Message.reply_msg(update, "Use /whisper @mention_user 'message'\nor reply user by /whisper 'message'\nE.g. /whisper @bishalqx980 This is a secret message 😜") + await Message.reply_msg(update, "Use /whisper @mention_user message\nor reply user by /whisper message\nE.g. /whisper @bishalqx980 This is a secret message 😜") return await Message.del_msg(chat.id, e_msg) diff --git a/main.py b/main.py index a4bb39d..e9b667a 100644 --- a/main.py +++ b/main.py @@ -40,14 +40,14 @@ from bot.functions.settings import func_settings from bot.functions.id import func_id from bot.functions.help import func_help -from bot.functions.broadcast import func_broadcast -from bot.functions.send import func_send -from bot.functions.database import func_database -from bot.functions.bsettings import func_bsettings -from bot.functions.shell import func_shell -from bot.functions.log import func_log -from bot.functions.restart import func_restart -from bot.functions.sys import func_sys +from bot.functions.owner_func.broadcast import func_broadcast +from bot.functions.owner_func.send import func_send +from bot.functions.owner_func.database import func_database +from bot.functions.owner_func.bsettings import func_bsettings +from bot.functions.owner_func.shell import func_shell +from bot.functions.owner_func.log import func_log +from bot.functions.owner_func.restart import func_restart +from bot.functions.owner_func.sys import func_sys from bot.functions.filter_service_msg import func_filter_services from bot.functions.filter_all import func_filter_all from bot.functions.del_command import func_del_command