Skip to content
Merged

Beta #85

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
476 changes: 417 additions & 59 deletions tronx/helpers/functions.py

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions tronx/helpers/others.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ def SudoUsers(self):
data_list = [int(x) for x in sudovar.split()] if sudovar else False
return data_list or self.SUDO_USERS or []


def PmpermitPic(self):
return self.getdv("PMPERMIT_PIC") or self.PMPERMIT_PIC or None


def PmpermitText(self):
return self.getdv("PMPERMIT_TEXT") or self.PMPERMIT_TEXT or None

10 changes: 5 additions & 5 deletions tronx/modules/alive.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@app.on_message(gen("alive"))
async def simple_alive(_, m: Message):
try:
await app.send_edit(m, ". . .", mono=True)
m = await app.send_edit(m, ". . .", mono=True)

alive_msg = f"\n"
if app.UserBio():
Expand Down Expand Up @@ -56,8 +56,8 @@ async def simple_alive(_, m: Message):
parse_mode="markdown"
)
elif not pic:
await app.send_message(
m.chat.id,
await app.send_edit(
m,
alive_msg,
disable_web_page_preview=True,
parse_mode="markdown",
Expand All @@ -70,7 +70,7 @@ async def simple_alive(_, m: Message):

@app.on_message(gen("ialive"))
async def inline_alive(_, m: Message):
await app.send_edit(m, ". . .", mono=True)
m = await app.send_edit(m, ". . .", mono=True)
try:
result = await app.get_inline_bot_results(app.bot.username, "#i2l8v3")
except BotInlineDisabled:
Expand All @@ -96,7 +96,7 @@ async def inline_alive(_, m: Message):
@app.on_message(gen(["qt"]))
async def inline_quote(_, m: Message):
try:
await app.send_edit(m,". . .", mono=True)
m = await app.send_edit(m,". . .", mono=True)
try:
result = await app.get_inline_bot_results(app.bot.username, "#q7o5e")
except BotInlineDisabled:
Expand Down
9 changes: 4 additions & 5 deletions tronx/modules/carbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,19 @@ async def carb_api(_, m: Message):
if app.long(m) < 2:
return await app.send_edit(m, f"Usage:\n\n`{app.PREFIX}carbon [colour] [text]`\n`{app.PREFIX}carbon [text]`\n\n**Note:** Default colour is aqua", delme=2)

elif app.long(m) <= 4096:
elif app.textlen(m) <= 4096:
try:
await app.send_edit(m, "creating carbon . . .", mono=True)
m = await app.send_edit(m, "creating carbon . . .", mono=True)
if cmd[1] in colour_code:
text = m.text.split(None, 2)[2]
colour = cmd[1]
await create_carbon(m, text=text, colour=colour)
else:
text = m.text.split(None, 1)[1]
colour= "aqua"
await create_carbon(m, text=text, colour=colour)
await create_carbon(m, text=text, colour=colour)
except Exception as e:
await app.error(m, e)
elif app.long(m) > 4096:
elif app.textlen(m) > 4096:
await app.send_edit(m, "The text is too long !", delme=2)


Expand Down
99 changes: 45 additions & 54 deletions tronx/modules/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from pyrogram import filters
from pyrogram.types import Message

from tronx import *

from tronx.helpers import *
from tronx import app
from tronx.helpers import gen



Expand All @@ -30,28 +29,50 @@



# shortcuts
bot = app.bot
p = print
c = Config




@app.on_message(gen(["eval", "e"], allow_channel=True))
async def evaluate(_, m):
global reply
async def evaluate(client, m: Message):
""" This function is made to execute python codes """

if app.textlen(m) > 4096:
return await send_edit(m, "Your message is too long ! only 4096 characters are allowed", mono=True, delme=4)

global reply, chat_id, chat_type, p, bot

access_list = ("SESSION", "API_ID", "API_HASH", "session_name", "api_id", "api_hash")
sensitive = [ f"app.{x}" for x in dir(app) if x in access_list] + [ f"self.{y}" for y in dir(app) if y in access_list] + [f"Config.{z}" for z in dir(app) if z in access_list]
warning_message = "Sorry but by evaluating this code your sensitive data will be exposed in this chat, aborting command !"
reply = m.reply_to_message
chat_type = m.chat.type
chat_id = m.chat.id
text = m.text

if chat_type in ("supergroup", "group") and chat_id != app.LOG_CHAT:
for x in sensitive:
if x in text:
return await app.send_edit(m, warning_message, mono=True, delme=4)

elif chat_type == "private" and chat_id != app.id:
for y in sensitive:
if y in text:
return await app.send_edit(m, warning_message, mono=True, delme=4)

elif chat_type == "bot" and chat_id != app.bot.id:
for z in sensitive:
if z in text:
return await app.send_edit(m, warning_message, mono=True, delme=4)

try:
cmd = m.text.split(" ", maxsplit=1)[1]
cmd = m.text.split(None, 1)[1]
except IndexError:
return await app.send_edit(m, "Give me some code to execute . . .", mono=True, delme=3)
return await app.send_edit(m, "Give me some text (code) to execute . . .", mono=True, delme=3)

await app.send_edit(m, "Running . . .", mono=True)

reply_to_id = m.message_id
if reply:
reply_to_id = reply.message_id

old_stderr = sys.stderr
old_stdout = sys.stdout
redirected_output = sys.stdout = StringIO()
Expand All @@ -62,34 +83,16 @@ async def evaluate(_, m):
await app.aexec(m, cmd)
except Exception:
exc = traceback.format_exc()

stdout = redirected_output.getvalue()
stderr = redirected_error.getvalue()
sys.stdout = old_stdout
sys.stderr = old_stderr
evaluation = ""

if exc:
evaluation = exc
elif stderr:
evaluation = stderr
elif stdout:
evaluation = stdout
else:
evaluation = f"Success"

evaluation = exc or stderr or stdout or "Success"
final_output = f"**• COMMAND:**\n\n`{cmd}`\n\n**• OUTPUT:**\n\n`{evaluation.strip()}`"

if len(final_output) > 4096:
filename = "eval_output.txt"
with open(filename, "w+", encoding="utf8") as out_file:
out_file.write(str(final_output))
await m.reply_document(
document=filename,
caption=f"`{cmd}`",
disable_notification=True,
reply_to_message_id=reply_to_id,
)
if os.path.exists(f"./{filename}"):
os.remove(filename)
await app.create_file(m, "eval_output.txt", str(final_output))
await m.delete()
else:
await app.send_edit(m, final_output)
Expand All @@ -98,10 +101,13 @@ async def evaluate(_, m):


@app.on_message(gen("term", allow_channel=True))
async def terminal(_, m):
async def terminal(_, m: Message):
if app.long(m) == 1:
return await app.send_edit(m, "Use: `.term pip3 install colorama`", delme=5)

elif app.textlen(m) > 4096:
return await send_edit(m, "Your message is too long ! only 4096 characters are allowed", mono=True, delme=4)

await app.send_edit(m, "Running . . .", mono=True)
args = m.text.split(None, 1)
teks = args[1]
Expand All @@ -115,13 +121,7 @@ async def terminal(_, m):
shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
except Exception as e:
print(e)
await app.send_edit(m,
"""
**Error:**
```{}```
""".format(e)
)
await app.error(m, e)
output += "**{}**\n".format(code)
output += process.stdout.read()[:-1].decode("utf-8")
output += "\n"
Expand All @@ -145,16 +145,7 @@ async def terminal(_, m):
output = None
if output:
if len(output) > 4096:
with open("term_output.txt", "w+") as file:
file.write(output)
await app.send_document(
m.chat.id,
"output.txt",
reply_to_message_id=m.message_id,
caption="`Output file`",
)
if os.path.exists("./output.txt"):
os.remove("output.txt")
await app.create_file(m, "term_output.txt", output)
else:
await app.send_edit(m, f"**OUTPUT:**\n\n```{output}```")
else:
Expand Down
7 changes: 4 additions & 3 deletions tronx/modules/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
async def pingme(_, m: Message):
if app.long(m) == 1:
start = datetime.now()
await app.send_edit(m, ". . .", mono=True)
m = await app.send_edit(m, ". . .", mono=True)
end = datetime.now()
m_s = (end - start).microseconds / 1000
await app.send_edit(
Expand All @@ -78,7 +78,7 @@ async def pingme(_, m: Message):
try:
num = int(count) + 1
for x in range(1, num):
await infinite(m)
m = await infinite(m)
await app.send_edit(m, ". . .", mono=True)
time.sleep(0.50)
await app.send_edit(m, "".join(pings))
Expand All @@ -93,10 +93,11 @@ async def pingme(_, m: Message):
# function to create lots of pings
async def infinite(m: Message):
start = datetime.now()
mid = await app.send_edit(m, random.choice(data))
m = await app.send_edit(m, random.choice(data))
end = datetime.now()
ms = (end - start).microseconds / 1000
msg = f"Pöng !\n{ms} ms\n⧑ {app.UserMention()}\n\n"
pings.append(msg)
return m


4 changes: 2 additions & 2 deletions tronx/modules/zombies.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def remove_deleted(_, m: Message):
count = 0

if app.long(m) != 2:
await app.send_edit(m, "Checking deleted accounts . . .", mono=True)
m = await app.send_edit(m, "Checking deleted accounts . . .", mono=True)

async for x in app.iter_chat_members(chat_id=m.chat.id):
if x.user.is_deleted:
Expand All @@ -47,7 +47,7 @@ async def remove_deleted(_, m: Message):
await app.send_edit(m, "No deleted accounts found.\nGroup is clean as Hell ! 😃", delme=3, mono=True)

elif app.long(m) == 2 and m.command[1] == "clean":
await app.send_edit(m, "Cleaning deleted accounts . . .", mono=True)
m = await app.send_edit(m, "Cleaning deleted accounts . . .", mono=True)

async for x in app.iter_chat_members(chat_id=m.chat.id):
if x.user.is_deleted:
Expand Down
4 changes: 2 additions & 2 deletions tronx/plugins/inlinequery.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def inline_result(_, inline_query):
inline_query.answer(
results=[
InlineQueryResultPhoto(
photo_url=app.PMPERMIT_PIC,
photo_url=app.PmpermitPic(),
title="Tron security system",
description="This is tron security system, it helps you to stop spammers from spamming in your dm.",
caption=app.PMPERMIT_TEXT,
caption=app.PmpermitText(),
parse_mode="combined",
reply_markup=InlineKeyboardMarkup([approve])
)
Expand Down
12 changes: 6 additions & 6 deletions tronx/plugins/utils.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
from tronx import app

from pyrogram import filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton

from tronx import app





@app.bot.on_message(filters.command("id"))
async def id_of_user(_, m):
async def chat_user_id(_, m):
reply = m.reply_to_message
if not reply:
await app.bot.send_message(
m.chat.id,
f"**YOUR ID:** `{m.from_user.id}`\n**CHAT ID:** `{m.chat.id}`"
f"**{m.from_user.first_name}:** `{m.from_user.id}`\n**{m.chat.title}:** `{m.chat.id}`"
)
elif reply:
await app.bot.send_message(
m.chat.id,
f"**REPLIED USER ID:** `{m.from_user.id}`\n**CHAT ID:** `{m.chat.id}`\n**REPLIED ID:** `{reply.from_user.id}`"
f"**{m.from_user.first_name}:** `{m.from_user.id}`\n**{m.chat.title}:** `{m.chat.id}`\n**{reply.from_user.first_name}:** `{reply.from_user.id}`"
)




@app.bot.on_message(filters.command("quote"))
async def get_anime_quotes(_, m):
async def bot_anime_quotes(_, m):
await app.bot.send_message(
m.chat.id,
app.quote(),
Expand Down