Skip to content

Commit

Permalink
owner func dir separated & read description
Browse files Browse the repository at this point in the history
- Added Audio/Video/Doc support on /send cmd
- Minor updates and fixes
  • Loading branch information
bishalqx980 committed Jan 2, 2025
1 parent 19680e2 commit fea4554
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 74 deletions.
2 changes: 1 addition & 1 deletion bot/functions/gen_qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>/qr 'url/data/text'</code> to generate a QR code image.\nor reply the 'url/data/text' with <code>/qr</code> command.\nE.g. <code>/qr https://google.com</code>")
await Message.reply_msg(update, "Use <code>/qr url/data/text</code> to generate a QR code image.\nor reply the 'url/data/text' with <code>/qr</code> command.\nE.g. <code>/qr https://google.com</code>")
return

sent_msg = await Message.reply_msg(update, f"Generating...")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
77 changes: 77 additions & 0 deletions bot/functions/owner_func/send.py
Original file line number Diff line number Diff line change
@@ -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 <code>/send chat_id</code> by replying a message!\n"
"<code>/send f chat_id</code> 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)
4 changes: 2 additions & 2 deletions bot/functions/shell.py → bot/functions/owner_func/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def func_shell(update: Update, context: ContextTypes.DEFAULT_TYPE):
return

if not command:
await Message.reply_msg(update, "Use <code>/shell 'dir/ls'</code> [linux/Windows Depend on your hosting server]")
await Message.reply_msg(update, "Use <code>/shell dir/ls</code> [linux/Windows Depend on your hosting server]")
return

sent_msg = await Message.reply_msg(update, "<b>⌊ please wait... ⌉</b>")
Expand Down Expand Up @@ -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"<b>Command</b>: {command}\n<b>Execute time</b>: {(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"<b>Command</b>: {command}\n<b>Execute time</b>: {(time_executed - time_executing):.2f}s", e_msg.id)
File renamed without changes.
2 changes: 1 addition & 1 deletion bot/functions/paste.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>/paste 'text'</code> or reply the message/text with <code>/paste</code> command.")
await Message.reply_msg(update, "Use <code>/paste text</code> or reply the message/text with <code>/paste</code> command.")
return

sent_msg = await Message.reply_msg(update, f"Creating...")
Expand Down
2 changes: 1 addition & 1 deletion bot/functions/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>/ping 'url'</code>\nE.g. <code>/ping https://google.com</code>")
await Message.reply_msg(update, "Use <code>/ping url</code>\nE.g. <code>/ping https://google.com</code>")
return

if url[0:4] != "http":
Expand Down
4 changes: 2 additions & 2 deletions bot/functions/psndl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>/psndl 'game name'</code>\nE.g. <code>/psndl grand theft auto</code>")
await Message.reply_msg(update, "Use <code>/psndl game name</code>\nE.g. <code>/psndl grand theft auto</code>")
return

if len(keyword) < 5:
Expand Down Expand Up @@ -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 <code>/rap 'rap_data'</code>\nE.g. <code>/rap D78710F4C0979FAD9CDB40C612C94F60</code>\n<i><b>Note:</b> You will get the rap data after searching content/game using /psndl command.</i>")
await Message.reply_msg(update, "Use <code>/rap rap_data</code>\nE.g. <code>/rap D78710F4C0979FAD9CDB40C612C94F60</code>\n<i><b>Note:</b> You will get the rap data after searching content/game using /psndl command.</i>")
return

sent_msg = await Message.reply_msg(update, "Creating...")
Expand Down
55 changes: 0 additions & 55 deletions bot/functions/send.py

This file was deleted.

2 changes: 1 addition & 1 deletion bot/functions/shortener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>/short 'url'</code>\nor reply the url with <code>/short</code> command.\nE.g. <code>/short https://google.com</code>")
await Message.reply_msg(update, "Use <code>/short url</code>\nor reply the url with <code>/short</code> command.\nE.g. <code>/short https://google.com</code>")
return

shorted_url = await shortener_url(msg)
Expand Down
2 changes: 1 addition & 1 deletion bot/functions/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>/tr 'text'</code> or <code>/tr lang_code 'text'</code> or reply the text with <code>/tr</code> or <code>/tr lang_code</code>\n\nEnable auto translator mode for this chat from /settings", btn=btn)
await Message.reply_msg(update, "Use <code>/tr text</code> or <code>/tr lang_code text</code> or reply the text with <code>/tr</code> or <code>/tr lang_code</code>\n\nEnable auto translator mode for this chat from /settings", btn=btn)
return

to_translate = None
Expand Down
2 changes: 1 addition & 1 deletion bot/functions/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>/weather 'location name'</code>\nE.g. <code>/weather london</code>")
await Message.reply_msg(update, "Use <code>/weather location_name</code>\nE.g. <code>/weather london</code>")
return

info = await weather_info(location)
Expand Down
2 changes: 1 addition & 1 deletion bot/functions/whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async def func_whisper(update: Update, context: ContextTypes.DEFAULT_TYPE):
return

if not msg:
await Message.reply_msg(update, "Use <code>/whisper @mention_user 'message'</code>\nor reply user by <code>/whisper 'message'</code>\nE.g. <code>/whisper @bishalqx980 This is a secret message 😜</code>")
await Message.reply_msg(update, "Use <code>/whisper @mention_user message</code>\nor reply user by <code>/whisper message</code>\nE.g. <code>/whisper @bishalqx980 This is a secret message 😜</code>")
return

await Message.del_msg(chat.id, e_msg)
Expand Down
16 changes: 8 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fea4554

Please sign in to comment.