Ultroid 0.0.5 - 06/04/21
Co-authored-by: AndrewLaneX <AndrewLaneX@users.noreply.github.com> Co-authored-by: Aditya <me@xditya.me> Co-authored-by: Danish <danish@ultroid.tech> Co-authored-by: buddhhu <buddhuu0@users.noreply.github.com> Co-authored-by: sppidy <sppidy@users.noreply.github.com> Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com> Co-authored-by: divkix <divkix@users.noreply.github.com> Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com> Co-authored-by: Programming Error <error@notavailable.live> Co-authored-by: New-dev0 <New-dev0@notavailable.live>
This commit is contained in:
committed by
ProgrammingError
parent
97146a9402
commit
4e8b0543ce
107
plugins/tools.py
107
plugins/tools.py
@@ -28,7 +28,7 @@
|
||||
Reply a User to Get His Id
|
||||
Without Replying You Will Get the Chat's Id
|
||||
|
||||
• `{i}sg <reply to a user>`
|
||||
• `{i}sg <reply to a user><username/id>`
|
||||
Get His Name History of the replied user.
|
||||
|
||||
• `{i}tr <dest lang code> <(reply to) a message>`
|
||||
@@ -46,7 +46,8 @@ import cv2
|
||||
import emoji
|
||||
from googletrans import Translator
|
||||
from telethon.errors.rpcerrorlist import YouBlockedUserError
|
||||
from telethon.tl.types import ChannelParticipantAdmin, ChannelParticipantsBots
|
||||
from telethon.tl.types import (ChannelParticipantAdmin,
|
||||
ChannelParticipantsBots, User)
|
||||
from telethon.utils import pack_bot_file_id
|
||||
|
||||
from . import *
|
||||
@@ -91,14 +92,17 @@ async def _(event):
|
||||
await eor(
|
||||
event,
|
||||
"**Current Chat ID:** `{}`\n**From User ID:** `{}`\n**Bot API File ID:** `{}`".format(
|
||||
str(event.chat_id), str(r_msg.sender.id), bot_api_file_id
|
||||
str(event.chat_id),
|
||||
str(r_msg.sender.id),
|
||||
bot_api_file_id,
|
||||
),
|
||||
)
|
||||
else:
|
||||
await eor(
|
||||
event,
|
||||
"**Chat ID:** `{}`\n**User ID:** `{}`".format(
|
||||
str(event.chat_id), str(r_msg.sender.id)
|
||||
str(event.chat_id),
|
||||
str(r_msg.sender.id),
|
||||
),
|
||||
)
|
||||
else:
|
||||
@@ -120,7 +124,7 @@ async def _(ult):
|
||||
if not input_str:
|
||||
chat = to_write_chat
|
||||
else:
|
||||
mentions = "**Bots in **{}: \n".format(input_str)
|
||||
mentions = f"**Bots in **{input_str}: \n"
|
||||
try:
|
||||
chat = await ultroid_bot.get_entity(input_str)
|
||||
except Exception as e:
|
||||
@@ -128,15 +132,20 @@ async def _(ult):
|
||||
return None
|
||||
try:
|
||||
async for x in ultroid_bot.iter_participants(
|
||||
chat, filter=ChannelParticipantsBots
|
||||
chat,
|
||||
filter=ChannelParticipantsBots,
|
||||
):
|
||||
if isinstance(x.participant, ChannelParticipantAdmin):
|
||||
mentions += "\n ⚜️ [{}](tg://user?id={}) `{}`".format(
|
||||
x.first_name, x.id, x.id
|
||||
x.first_name,
|
||||
x.id,
|
||||
x.id,
|
||||
)
|
||||
else:
|
||||
mentions += "\n [{}](tg://user?id={}) `{}`".format(
|
||||
x.first_name, x.id, x.id
|
||||
x.first_name,
|
||||
x.id,
|
||||
x.id,
|
||||
)
|
||||
except Exception as e:
|
||||
mentions += " " + str(e) + "\n"
|
||||
@@ -174,7 +183,7 @@ async def _(e):
|
||||
c = await a.download_media(
|
||||
"resources/downloads/",
|
||||
progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
|
||||
progress(d, t, z, toime, "Dᴏᴡɴʟᴏᴀᴅɪɴɢ...")
|
||||
progress(d, t, z, toime, "Dᴏᴡɴʟᴏᴀᴅɪɴɢ..."),
|
||||
),
|
||||
)
|
||||
await z.edit("**Dᴏᴡɴʟᴏᴀᴅᴇᴅ...\nNᴏᴡ Cᴏɴᴠᴇʀᴛɪɴɢ...**")
|
||||
@@ -193,7 +202,9 @@ async def _(e):
|
||||
"comp.mp3",
|
||||
]
|
||||
proess = await asyncio.create_subprocess_exec(
|
||||
*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
|
||||
*cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
stdout, stderr = await proess.communicate()
|
||||
stderr.decode().strip()
|
||||
@@ -210,7 +221,9 @@ async def _(e):
|
||||
"circle.mp4",
|
||||
]
|
||||
process = await asyncio.create_subprocess_exec(
|
||||
*mcd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
|
||||
*mcd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
stdout, stderr = await process.communicate()
|
||||
stderr.decode().strip()
|
||||
@@ -223,7 +236,7 @@ async def _(e):
|
||||
video_note=True,
|
||||
reply_to=a,
|
||||
progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
|
||||
progress(d, t, z, taime, "Uᴘʟᴏᴀᴅɪɴɢ...")
|
||||
progress(d, t, z, taime, "Uᴘʟᴏᴀᴅɪɴɢ..."),
|
||||
),
|
||||
)
|
||||
await z.delete()
|
||||
@@ -260,30 +273,25 @@ async def _(event):
|
||||
reply_to_id = event.reply_to_msg_id
|
||||
time.time() + 100
|
||||
process = await asyncio.create_subprocess_shell(
|
||||
cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
|
||||
cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
stdout, stderr = await process.communicate()
|
||||
OUT = f"<b>☞ BASH\n\n• COMMAND:</b>\n<code>{cmd}</code> \n\n"
|
||||
OUT = f"**☞ BASH\n\n• COMMAND:**\n`{cmd}` \n\n"
|
||||
e = stderr.decode()
|
||||
if e:
|
||||
OUT += f"<b>• ERROR:</b> \n<code>{e}</code>\n"
|
||||
OUT += f"**• ERROR:** \n`{e}`\n"
|
||||
o = stdout.decode()
|
||||
if not o and not e:
|
||||
if not o:
|
||||
o = "Success"
|
||||
OUT += f"<b>• OUTPUT:</b>\n<code>{o}</b>"
|
||||
OUT += f"**• OUTPUT:**\n`{o}`"
|
||||
else:
|
||||
_o = o.split("\n")
|
||||
o = "\n".join(_o)
|
||||
OUT += f"<b>• OUTPUT:</b>\n<code>{o}</code>"
|
||||
OUT += f"**• OUTPUT:**\n`{o}`"
|
||||
if len(OUT) > 4096:
|
||||
ultd = (
|
||||
OUT.replace("<code>", "")
|
||||
.replace("</code>", "")
|
||||
.replace("<b>", "")
|
||||
.replace("</b>", "")
|
||||
.replace("<i>", "")
|
||||
.replace("</i>", "")
|
||||
)
|
||||
ultd = OUT.replace("`", "").replace("*", "").replace("_", "")
|
||||
with io.BytesIO(str.encode(ultd)) as out_file:
|
||||
out_file.name = "bash.txt"
|
||||
await event.client.send_file(
|
||||
@@ -296,7 +304,7 @@ async def _(event):
|
||||
)
|
||||
await xx.delete()
|
||||
else:
|
||||
await eod(xx, OUT, parse_mode="html")
|
||||
await eod(xx, OUT)
|
||||
|
||||
|
||||
@ultroid_cmd(
|
||||
@@ -339,18 +347,14 @@ async def _(event):
|
||||
evaluation = stdout
|
||||
else:
|
||||
evaluation = "Success"
|
||||
final_output = "<i>►</i> <b>EVAL</b>\n<code>{}</code>\n\n<i>►</i><b>OUTPUT</b>: \n<code>{}</code>".format(
|
||||
cmd, evaluation
|
||||
final_output = (
|
||||
"__►__ **EVAL**\n```{}``` \n\n __►__ **OUTPUT**: \n```{}``` \n".format(
|
||||
cmd,
|
||||
evaluation,
|
||||
)
|
||||
)
|
||||
if len(final_output) > 4096:
|
||||
ultd = (
|
||||
final_output.replace("<code>", "")
|
||||
.replace("</code>", "")
|
||||
.replace("<b>", "")
|
||||
.replace("</b>", "")
|
||||
.replace("<i>", "")
|
||||
.replace("</i>", "")
|
||||
)
|
||||
ultd = final_output.replace("`", "").replace("*", "").replace("_", "")
|
||||
with io.BytesIO(str.encode(ultd)) as out_file:
|
||||
out_file.name = "eval.txt"
|
||||
await ultroid_bot.send_file(
|
||||
@@ -363,7 +367,7 @@ async def _(event):
|
||||
)
|
||||
await xx.delete()
|
||||
else:
|
||||
await eod(xx, final_output, parse_mode="html")
|
||||
await eod(xx, final_output)
|
||||
|
||||
|
||||
async def aexec(code, event):
|
||||
@@ -372,29 +376,31 @@ async def aexec(code, event):
|
||||
exec(
|
||||
f"async def __aexec(e, client): "
|
||||
+ "\n message = event = e"
|
||||
+ "".join(f"\n {l}" for l in code.split("\n"))
|
||||
+ "".join(f"\n {l}" for l in code.split("\n")),
|
||||
)
|
||||
|
||||
return await locals()["__aexec"](e, e.client)
|
||||
|
||||
|
||||
@ultroid_cmd(
|
||||
pattern="sg(?: |$)(.*)",
|
||||
pattern="sg ?(.*)",
|
||||
)
|
||||
async def lastname(steal):
|
||||
if steal.fwd_from:
|
||||
return
|
||||
if not steal.reply_to_msg_id:
|
||||
await steal.edit("Reply to any user message.")
|
||||
mat = steal.pattern_match.group(1)
|
||||
if not (steal.is_reply or mat):
|
||||
await eor(steal, "`Use this command with reply or give Username/id...`")
|
||||
return
|
||||
if mat:
|
||||
user_id = await get_user_id(mat)
|
||||
message = await steal.get_reply_message()
|
||||
if message:
|
||||
user_id = message.sender.id
|
||||
chat = "@SangMataInfo_bot"
|
||||
user_id = message.sender.id
|
||||
id = f"/search_id {user_id}"
|
||||
if message.sender.bot:
|
||||
await steal.edit("Reply to actual users message.")
|
||||
return
|
||||
lol = await eor(steal, "Processingg !!!!!")
|
||||
check = await ultroid_bot.get_entity(user_id)
|
||||
if not isinstance(check, User) or check.bot:
|
||||
return await eor(steal, "Reply to Actual User's Message !")
|
||||
lol = await eor(steal, "`Processing !...`")
|
||||
try:
|
||||
async with ultroid_bot.conversation(chat) as conv:
|
||||
try:
|
||||
@@ -420,7 +426,8 @@ async def lastname(steal):
|
||||
await lol.edit(respond.message)
|
||||
await lol.reply(response.message)
|
||||
await steal.client.delete_messages(
|
||||
conv.chat_id, [msg.id, responds.id, respond.id, response.id]
|
||||
conv.chat_id,
|
||||
[msg.id, responds.id, respond.id, response.id],
|
||||
)
|
||||
except TimeoutError:
|
||||
return await lol.edit("Error: @SangMataInfo_bot is not responding!.")
|
||||
|
||||
Reference in New Issue
Block a user