Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few fixes and addition #444

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 7 additions & 6 deletions plugins/admintools.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,13 @@ async def _(e):

msg = await e.get_reply_message()
name = msg.sender
try:
await e.client.delete_messages(e.chat_id, from_user=msg.sender_id)
await e.eor(get_string("purgeall_2").format(name.first_name), time=5)
except Exception as er:
return await e.eor(str(er), time=5)

async for message in e.client.iter_messages(e.chat_id, from_user=msg.sender.id):
try:
await e.client.delete_messages(e.chat_id, [message.id])
except Exception as er:
await e.eor(str(er), time=5)
return
await e.eor(get_string("purgeall_2").format(name.first_name), time=5)

@ultroid_cmd(pattern="pinned", manager=True, groups_only=True)
async def djshsh(event):
Expand Down
19 changes: 8 additions & 11 deletions plugins/beautify.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ async def pass_on(ult):
try:
from playwright.async_api import async_playwright
except ImportError:
await ult.eor("`playwright` is not installed!\nPlease install it to use this command..")
await ult.eor(
"`playwright` is not installed!\nPlease install it to use this command.."
)
return
proc = await ult.eor(get_string("com_1"))
spli = ult.text.split()
Expand Down Expand Up @@ -139,26 +141,21 @@ async def pass_on(ult):
text = msg.message
title = get_display_name(msg.sender)
name = token_hex(8) + ".png"
data = {
"darkMode": dark,
"theme": theme,
"title": title
}
data = {"darkMode": dark, "theme": theme, "title": title}
url = f"https://ray.so/#{urlencode(data)}"
async with async_playwright() as play:
chrome = await play.chromium.launch()
page = await chrome.new_page()
await page.goto(url)
await page.wait_for_load_state("networkidle")
elem = await page.query_selector("textarea[class='Editor_textarea__sAyL_']")
await page.wait_for_selector("div[class='Editor_editor__Jz9sW']")
elem = await page.query_selector("div[class='Editor_editor__Jz9sW']")
await elem.type(text)
button = await page.query_selector("button[class='ExportButton_button__d___t']")
button = await page.query_selector(".ExportButton_button__MA4PI")
await button.click()
async with page.expect_download() as dl:
dled = await dl.value
await dled.save_as(name)
await proc.reply(
file=name
)
await proc.reply(file=name)
await proc.try_delete()
os.remove(name)
8 changes: 8 additions & 0 deletions plugins/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ async def _(event):
with open("ultroid.log", "r") as f:
file = f.read()[-4000:]
return await event.eor(f"`{file}`")
elif (
opt.isdigit() and 5 <= int(opt) <= 100
): # Check if input is a number between 10 and 100
num_lines = int(opt)
with open("ultroid.log", "r") as f:
lines = f.readlines()[-num_lines:]
file = "".join(lines)
return await event.eor(f"`{file}`")
else:
await def_logs(event, file)
await event.try_delete()
Expand Down
26 changes: 18 additions & 8 deletions plugins/stickertools.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Ultroid - UserBot
# Copyright (C) 2021-2023 TeamUltroid
# Ultroid ~ UserBot
# Copyright (C) 2024 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
Commands Available -
Commands Available -

• `{i}destroy <reply to animated sticker>`
To destroy the sticker.
Expand Down Expand Up @@ -61,10 +61,10 @@
get_string,
inline_mention,
mediainfo,
ultroid_cmd,
quotly,
types,
udB,
ultroid_cmd,
)


Expand Down Expand Up @@ -94,7 +94,7 @@ async def pack_kangish(_):
docs = _get_stiks.documents
else:
docs = []
files = glob.glob(cmdtext + "/*")
files = glob.glob(f"{cmdtext}/*")
exte = files[-1]
if exte.endswith(".tgs"):
typee = "anim"
Expand All @@ -115,9 +115,11 @@ async def pack_kangish(_):
stiks.append(
types.InputStickerSetItem(
document=x,
emoji=random.choice(["😐", "👍", "😂"])
if local
else (i.attributes[1]).alt,
emoji=(
random.choice(["😐", "👍", "😂"])
if local
else (i.attributes[1]).alt
),
)
)
try:
Expand Down Expand Up @@ -366,6 +368,14 @@ async def hehe(args):
os.remove(photo)
except BaseException:
pass
try:
os.remove("AnimatedSticker.tgs")
except BaseException:
pass
try:
os.remove("ult.webp")
except BaseException:
pass


@ultroid_cmd(
Expand Down
118 changes: 73 additions & 45 deletions plugins/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,55 +338,83 @@ async def _(e):
await e.delete()



def sanga_seperator(sanga_list):
string = "".join(info[info.find("\n") + 1 :] for info in sanga_list)
string = re.sub(r"^$\n", "", string, flags=re.MULTILINE)
name, username = string.split("Usernames**")
name = name.split("Names")[1]
return name, username


def mentionuser(name, userid):
return f"[{name}](tg://user?id={userid})"


@ultroid_cmd(
pattern="sg( (.*)|$)",
pattern="sg(|u)(?:\\s|$)([\\s\\S]*)",
fullsudo=True,
)
async def lastname(steal):
mat = steal.pattern_match.group(1).strip()
message = await steal.get_reply_message()
if mat:
try:
user_id = await steal.client.parse_id(mat)
except ValueError:
user_id = mat
elif message:
user_id = message.sender_id
else:
return await steal.eor("`Use this command with reply or give Username/id...`")
chat = "@SangMataInfo_bot"
id = f"/search_id {user_id}"
lol = await steal.eor(get_string("com_1"))
async def sangmata(event):
"To get name/username history."
cmd = event.pattern_match.group(1)
user = event.pattern_match.group(2)
reply = await event.get_reply_message()
if not user and reply:
user = str(reply.sender_id)
if not user:
await event.edit(
"`Reply to user's text message to get name/username history or give userid/username`",
)
await asyncio.sleep(10)
return await event.delete()

try:
async with steal.client.conversation(chat) as conv:
if user.isdigit():
userinfo = await ultroid_bot.get_entity(int(user))
else:
userinfo = await ultroid_bot.get_entity(user)
except ValueError:
userinfo = None
if not isinstance(userinfo, types.User):
await event.edit("`Can't fetch the user...`")
await asyncio.sleep(10)
return await event.delete()

await event.edit("`Processing...`")
async with event.client.conversation("@SangMata_beta_bot") as conv:
try:
await conv.send_message(f"{userinfo.id}")
except YouBlockedUserError:
await catub(unblock("SangMata_beta_bot"))
await conv.send_message(f"{userinfo.id}")
responses = []
while True:
try:
msg = await conv.send_message(id)
response = await conv.get_response()
respond = await conv.get_response()
responds = await conv.get_response()
except YouBlockedUserError:
return await lol.edit("Please unblock @sangmatainfo_bot and try again")
if (
(response and response.text == "No records found")
or (respond and respond.text == "No records found")
or (responds and responds.text == "No records found")
):
await lol.edit("No records found for this user")
await steal.client.delete_messages(conv.chat_id, [msg.id, response.id])
elif response.text.startswith("🔗"):
await lol.edit(respond.message)
await lol.reply(responds.message)
elif respond.text.startswith("🔗"):
await lol.edit(response.message)
await lol.reply(responds.message)
else:
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],
)
except AsyncTimeout:
await lol.edit("Error: @SangMataInfo_bot is not responding!.")
response = await conv.get_response(timeout=2)
except asyncio.TimeoutError:
break
responses.append(response.text)
await event.client.send_read_acknowledge(conv.chat_id)

if not responses:
await event.edit("`Bot can't fetch results`")
await asyncio.sleep(10)
await event.delete()
if "No records found" in responses or "No data available" in responses:
await event.edit("`The user doesn't have any record`")
await asyncio.sleep(10)
await event.delete()

names, usernames = sanga_seperator(responses)
check = (usernames, "Username") if cmd == "u" else (names, "Name")
user_name = (
f"{userinfo.first_name} {userinfo.last_name}"
if userinfo.last_name
else userinfo.first_name
)
output = f"**➜ User Info :** {mentionuser(user_name, userinfo.id)}\n**➜ {check[1]} History :**\n{check[0]}"
await event.edit(output)


@ultroid_cmd(pattern="webshot( (.*)|$)")
Expand Down
22 changes: 14 additions & 8 deletions plugins/warn.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,21 @@ async def twarns(e):
async def warnset(e):
ok = e.pattern_match.group(1).strip()
if not ok:
return await e.eor("stuff")
return await e.eor("Invalid format. Correct usage: .setwarns <number>|<action>")
if "|" in ok:
try:
number, action = int(ok.split()[0]), ok.split()[1]
except BaseException:
return await e.eor(get_string("schdl_2"), time=5)
if ("ban" or "kick" or "mute") not in action:
return await e.eor("`Only mute / ban / kick option suported`", time=5)
number, action = ok.split("|")
number = int(number.strip())
action = action.strip()
except ValueError:
return await e.eor(
"Invalid format. Correct usage: .setwarns <number>|<action>", time=5
)
if action not in ["ban", "mute", "kick"]:
return await e.eor("Only mute / ban / kick options are supported", time=5)
udB.set_key("SETWARN", f"{number} {action}")
await e.eor(f"Done Your Warn Count is now {number} and Action is {action}")
await e.eor(f"Done. Your Warn Count is now {number} and Action is {action}")
else:
await e.eor(get_string("schdl_2"), time=5)
await e.eor(
"Invalid format. Correct usage: .setwarns <number>|<action>", time=5
)
Loading
Loading