diff --git a/.env.sample b/.env.sample
deleted file mode 100644
index 79d989c855..0000000000
--- a/.env.sample
+++ /dev/null
@@ -1,12 +0,0 @@
-# Don't use quotes( " and ' )
-
-API_ID=
-API_HASH=
-SESSION=
-REDIS_URI=
-REDIS_PASSWORD=
-
-# [OPTIONAL]
-
-LOG_CHANNEL=
-BOT_TOKEN=
diff --git a/.gitignore b/.gitignore
index 794eba8b5a..b2f5a9dc07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,44 +1,47 @@
.env
*.session-journal
*.session
-build
test*
*.mp3
*.webm
-*.webp
*.mp4
*.tgs
*.txt
+script*
+!runtime.txt
+!requirements.txt
/*.jpg
/*.png
/*.mp4
*.log
-target/npmlist.json
-package-lock.json
-ultroid.json
-resources/extras/thumbnail.jpg
+temp*
+resources/downloads/
+push.bat
+modules/channels/
+modules/manager/
+localization/strings/
+ultroid*.json
# Directories
addons/
vcbot/
__pycache__/
venv/
-node_modules/
glitch_me/
src/glitch-me
.idea/
.vscode/
temp/
-bin-debug/
-bin-release/
-[Oo]bj/
[Bb]in/
.settings/
*.swf
*.air
-*.ipa
*.apk
+*.webp
+*.cpp
+.vs
+env
# temporary files
*.raw
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index a69d36986a..0000000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Welcome To Contributing Guide
-Any contribution done to this repository will be appreciated! 🎉
-
-### About Ultroid
-- **Ultroid** is Telegram Userbot, which allow you to perform many task easily.
-- It's base core is a pip package named [`pyUltroid`](https://GitHub.com/TeamUltroid/pyUltroid).
-- This repository, contains Ultroid's official plugin files.
-- moreover, Ultroid User also have an option to get more plugins available at [`UltroidAddons`](https://github.com/TeamUltroid/UltroidAddons)
-
-### Issues
-- Search for existing Similar issues.
-- You can open a issue first before contributing, If it contain some major changes like `bug fixes` or `feature addition`.
-- If you are busy or getting trouble while making changes, you can just open the issue (explaining it).
-
-### Contributing
-- You can [fork](https://github.com/TeamUltroid/Ultroid/fork) this repository.
-- You can commits your changes now.
-- You can [Git-Squash](https://docs.github.com/en/get-started/using-git/about-git-rebase) your commits, if they are more. [Optional]
-- At last, You are ready to [`make a Pull Request`](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).
-- Make sure that, your `Pull Request` contain an explaining title and issue number if it closes any open issue.
-
-### Thanks
-- Congrats! 💫 you have successfully made your Contribution to Ultroid.
diff --git a/Dockerfile b/Dockerfile
index f78f36cf70..c49b4505d0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,20 +1,19 @@
# Ultroid - UserBot
-# Copyright (C) 2021-2022 TeamUltroid
+# Copyright (C) 2020-2023 TeamUltroid
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
- +
{escape(pattern or '')}
{escape(err)}+""" + try: + with rm.get("graph", helper=True, dispose=True) as mod: + graphLink = await mod.make_html_telegraph( + "Inline Error", MakeHtml + ) + except Exception as er: + LOGS.exception(f"Error while pasting inline error: {er}") + LOGS.exception(err) + return try: await event.answer( [ await event.builder.article( title="Unhandled Exception has Occured!", - text=error_text(), + text=graphLink, buttons=Button.url( "Report", "https://t.me/UltroidSupportChat" ), @@ -140,11 +154,17 @@ def error_text(): ] ) except QueryIdInvalidError: - LOGS.exception(err) + msg = f"[An error occurred]" + await asst.send_message(udB.get_config("LOG_CHANNEL"), msg) except Exception as er: + LOGS.exception(err) LOGS.exception(er) - await asst.send_message(udB.get_key("LOG_CHANNEL"), error_text()) asst.add_event_handler(wrapper, InlineQuery(pattern=pattern, **kwargs)) + if button: + InlinePlugin.update(button) + if kwargs.get("add_help") is not False: + _path = extract_stack(limit=2)[0].filename[:-3][len(str(CWD)) + 1 :] + InlinePaths.append(_path.replace("/", ".")) return don diff --git a/pyUltroid/_misc/_decorators.py b/core/decorators/_decorators.py similarity index 60% rename from pyUltroid/_misc/_decorators.py rename to core/decorators/_decorators.py index bc93c9247e..4ea398edb3 100644 --- a/pyUltroid/_misc/_decorators.py +++ b/core/decorators/_decorators.py @@ -1,16 +1,16 @@ # Ultroid - UserBot -# Copyright (C) 2021-2022 TeamUltroid +# Copyright (C) 2020-2023 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in #
{ult.chat_id}
'} [{escape(naam)}]{ult.sender_id}
False
'}{escape(ult.text)}+
{escape(format_exc())}+
Your BOT is
up-to-date with
[{branch}]',
+ parse_mode="html",
+ link_preview=False,
+ )
+ org, up = get_origin_upstream()
+ msg = await xx.eor(
+ f'[ChangeLogs]\nUpdating...
',
+ parse_mode="html",
+ link_preview=False,
+ )
+ await update(msg)
+
+
+async def update(eve):
+ if HOSTED_ON == "heroku":
+ from core.heroku import update
+
+ return await update(eve)
+ else:
+ # call_back()
+ await bash(f"git pull && {sys.executable} -m pip install -r requirements.txt")
+ os.execl(sys.executable, sys.executable, "-m", "core")
diff --git a/plugins/chats.py b/modules/basic/chats.py
similarity index 78%
rename from plugins/chats.py
rename to modules/basic/chats.py
index f484cfa16e..7a50073214 100644
--- a/plugins/chats.py
+++ b/modules/basic/chats.py
@@ -1,14 +1,15 @@
# Ultroid - UserBot
-# Copyright (C) 2021-2022 TeamUltroid
+# Copyright (C) 2021-2023 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# {get_display_name(event.chat)}
[{event.chat_id}
]"
- msg += f"\n\n∆ CODE:\n{cmd}
\n\n∆ ERROR:\n{exc}
"
- log_chat = udB.get_key("LOG_CHANNEL")
+ msg += f"\n\n∆ CODE:\n{cmd}
\n\n∆ ERROR:\n{err}
"
+ log_chat = udB.get_config("LOG_CHANNEL")
if len(msg) > 4000:
with BytesIO(msg.encode()) as out_file:
out_file.name = "Eval-Error.txt"
@@ -292,21 +301,27 @@ async def get_():
return
tmt = tima * 1000
timef = time_formatter(tmt)
- timeform = timef if not timef == "0s" else f"{tmt:.3f}ms"
- final_output = "__►__ **EVAL** (__in {}__)\n```{}``` \n\n __►__ **OUTPUT**: \n```{}``` \n".format(
+ timeform = timef if timef != "0s" else f"{tmt:.3f}ms"
+ if isinstance(evaluation, str) and not (await is_url_ok(evaluation, True)):
+ evaluation = f"```{evaluation}```"
+ final_output = "__►__ **EVAL** (__in {}__)\n```{}``` ".format(
timeform,
cmd,
- evaluation,
)
+ if err:
+ final_output += f"\n\n __►__ **ERROR**: \n`{err}`"
+ elif not evaluation:
+ evaluation = get_string("instu_4")
+ if evaluation:
+ final_output += f"\n\n __►__ **OUTPUT**: \n{evaluation}"
if len(final_output) > 4096:
- final_output = evaluation
- with BytesIO(str.encode(final_output)) as out_file:
+ final_output = str(evaluation)
+ with BytesIO(final_output.encode()) as out_file:
out_file.name = "eval.txt"
await event.client.send_file(
event.chat_id,
out_file,
force_document=True,
- thumb=ULTConfig.thumb,
allow_cache=False,
caption=f"```{cmd}```" if len(cmd) < 998 else None,
reply_to=reply_to_id,
@@ -336,51 +351,3 @@ async def aexec(code, event):
)
return await locals()["__aexec"](event, event.client)
-
-
-DUMMY_CPP = """#include {murl}") + extra = f"**[{xx}]({url})**\n\n" + e = await event.eor(f"{extra}`Loading More...`", link_preview=False) + + if hasattr(r.media, "document"): + dl = await event.client.fast_downloader( + r.document, + filename=r.file.name, + show_progress=True, + event=event, + message=f"{extra}`Loading More...`", + ) + + naam = dl[0].name + else: + naam = await r.download_media() + elif match and ( + os.path.isfile(match) + or (match.startswith("https://") and (await is_url_ok(match))) + ): + naam, xx = match, "file" + else: + return await event.eor(get_string("cvt_3"), time=5) + out, er = await bash(f"mediainfo '{naam}'") + makehtml = "" + thumb = None + if naam.endswith((".mkv", ".mp4", ".avi")): + thumb = await generate_screenshot(naam) + is_img = naam.endswith((".jpg", ".png")) + if is_img: + thumb = naam + if thumb and os.path.exists(thumb): + with rm.get("graph", helper=True, dispose=True) as mod: + med = mod.upload_file(thumb) + + makehtml += f"
{line}
" + try: + with rm.get("graph", helper=True, dispose=True) as mod: + urll = await mod.make_html_telegraph("Mediainfo", makehtml) + except Exception: + LOGS.exception(er) + return + await event.eor(f"{extra}[{get_string('mdi_1')}]({urll})", link_preview=False) + if not match: + os.remove(naam) + if thumb and thumb != naam: + with contextlib.suppress(FileNotFoundError): + os.remove(thumb) diff --git a/plugins/pmpermit.py b/modules/basic/pmpermit.py similarity index 94% rename from plugins/pmpermit.py rename to modules/basic/pmpermit.py index 8749f6ee02..b0e772f725 100644 --- a/plugins/pmpermit.py +++ b/modules/basic/pmpermit.py @@ -1,5 +1,5 @@ # Ultroid - UserBot -# Copyright (C) 2021-2022 TeamUltroid +# Copyright (C) 2021-2023 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in @@ -42,27 +42,30 @@ import re from os import remove -from pyUltroid.dB import DEVLIST +from database.helpers import DEVLIST try: from tabulate import tabulate except ImportError: tabulate = None +from core import HNDLR from telethon import events from telethon.errors import MessageNotModifiedError -from telethon.tl.functions.contacts import ( - BlockRequest, - GetBlockedRequest, - UnblockRequest, -) +from telethon.tl import types +from telethon.tl.custom import Button +from telethon.tl.functions.contacts import (BlockRequest, GetBlockedRequest, + UnblockRequest) from telethon.tl.functions.messages import ReportSpamRequest from telethon.utils import get_display_name, resolve_bot_file_id -from pyUltroid.dB.base import KeyManager +from database.helpers.base import KeyManager -from . import * +from .. import (LOGS, asst, callback, get_string, in_pattern, inline_mention, + udB, ultroid_bot, ultroid_cmd) # ========================= CONSTANTS ============================= +OWNER_NAME = ultroid_bot.full_name +OWNER_ID = ultroid_bot.me.id COUNT_PM = {} LASTMSG = {} @@ -156,7 +159,7 @@ async def _(e): func=lambda e: e.is_private, ), ) - async def permitpm(event): + async def permitpmhandler(event): user = await event.get_sender() if user.bot or user.is_self or user.verified or Logm.contains(user.id): return @@ -169,7 +172,8 @@ async def permitpm(event): @ultroid_bot.on( events.NewMessage( outgoing=True, - func=lambda e: e.is_private and e.out and not e.text.startswith(HNDLR), + func=lambda e: e.is_private and e.out and not e.text.startswith( + HNDLR), ), ) async def autoappr(e): @@ -206,16 +210,19 @@ async def autoappr(e): func=lambda e: e.is_private and e.sender_id not in DEVLIST and not e.out - and not e.sender.bot - and not e.sender.is_self - and not e.sender.verified, + # and not e.sender.bot + # and not e.sender.is_self + # and not e.sender.verified, ) ) async def permitpm(event): - inline_pm = Redis("INLINE_PM") or False + sender = await event.get_sender() + if (sender.bot or sender.verified): + return + inline_pm = udB.get_key("INLINE_PM") or False user = event.sender if not keym.contains(user.id) and event.text != UND: - if Redis("MOVE_ARCHIVE"): + if udB.get_key("MOVE_ARCHIVE"): try: await ultroid_bot.edit_folder(user.id, folder=1) except BaseException as er: @@ -408,8 +415,7 @@ async def approvepm(apprvpm): else: return await apprvpm.edit(NO_REPLY) if user.id in DEVLIST: - return await eor( - apprvpm, + return await apprvpm.eor( "Lol, He is my Developer\nHe is auto Approved", ) if not keym.contains(user.id): @@ -419,8 +425,7 @@ async def approvepm(apprvpm): await apprvpm.client.edit_folder(user.id, folder=0) except BaseException: pass - await eod( - apprvpm, + await apprvpm.eor( f"{inline_mention(user, html=True)}approved to PM!
",
parse_mode="html",
)
@@ -430,7 +435,8 @@ async def approvepm(apprvpm):
_not_approved[user.id],
f"#APPROVED\n\n{inline_mention(user, html=True)} [{user.id}
] was approved to PM you!
",
buttons=[
- Button.inline("Disapprove PM", data=f"disapprove_{user.id}"),
+ Button.inline(
+ "Disapprove PM", data=f"disapprove_{user.id}"),
Button.inline("Block", data=f"block_{user.id}"),
],
parse_mode="html",
@@ -440,7 +446,8 @@ async def approvepm(apprvpm):
udB.get_key("LOG_CHANNEL"),
f"#APPROVED\n\n{inline_mention(user, html=True)} [{user.id}
] was approved to PM you!
",
buttons=[
- Button.inline("Disapprove PM", data=f"disapprove_{user.id}"),
+ Button.inline(
+ "Disapprove PM", data=f"disapprove_{user.id}"),
Button.inline("Block", data=f"block_{user.id}"),
],
parse_mode="html",
@@ -459,14 +466,12 @@ async def disapprovepm(e):
else:
return await e.edit(NO_REPLY)
if user.id in DEVLIST:
- return await eor(
- e,
+ return await e.eor(
"`Lol, He is my Developer\nHe Can't Be DisApproved.`",
)
if keym.contains(user.id):
keym.remove(user.id)
- await eod(
- e,
+ await e.eor(
f"{inline_mention(user, html=True)} Disapproved to PM!
",
parse_mode="html",
)
@@ -494,8 +499,7 @@ async def disapprovepm(e):
except MessageNotModifiedError:
pass
else:
- await eod(
- e,
+ await e.eor(
f"{inline_mention(user, html=True)} was never approved!
",
parse_mode="html",
)
@@ -514,7 +518,7 @@ async def blockpm(block):
elif block.is_private:
user = block.chat_id
else:
- return await eor(block, NO_REPLY, time=10)
+ return await block.eor(NO_REPLY, time=10)
await block.client(BlockRequest(user))
aname = await block.client.get_entity(user)
@@ -556,20 +560,20 @@ async def unblockpm(event):
u_s = await event.client(GetBlockedRequest(0, 0))
count = len(u_s.users)
if not count:
- return await eor(msg, "__You have not blocked Anyone...__")
+ return await msg.eor("__You have not blocked Anyone...__")
for user in u_s.users:
await asyncio.sleep(1)
await event.client(UnblockRequest(user.id))
# GetBlockedRequest return 20 users at most.
if count < 20:
- return await eor(msg, f"__Unblocked {count} Users!__")
+ return await msg.eor(f"__Unblocked {count} Users!__")
while u_s.users:
u_s = await event.client(GetBlockedRequest(0, 0))
for user in u_s.users:
await asyncio.sleep(3)
await event.client(UnblockRequest(user.id))
count += len(u_s.users)
- return await eor(msg, f"__Unblocked {count} users.__")
+ return await msg.eor(f"__Unblocked {count} users.__")
try:
user = await event.client.parse_id(match)
@@ -622,7 +626,12 @@ async def list_approved(event):
with open("approved_pms.txt", "w") as list_appr:
if tabulate:
list_appr.write(
- tabulate(users, headers=["UserName", "UserID"], showindex="always")
+ tabulate(
+ users,
+ headers=[
+ "UserName",
+ "UserID"],
+ showindex="always")
)
else:
text = "".join(f"[{user[-1]}] - {user[0]}" for user in users)
diff --git a/modules/basic/stickers.py b/modules/basic/stickers.py
new file mode 100644
index 0000000000..8e44b8d711
--- /dev/null
+++ b/modules/basic/stickers.py
@@ -0,0 +1,186 @@
+# Ultroid - UserBot
+# Copyright (C) 2021-2023 TeamUltroid
+#
+# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
+# PLease read the GNU Affero General Public License in
+# {user_id}
+••Pᴇʀᴍᴀɴᴇɴᴛ Lɪɴᴋ: Click Here
+••Fɪʀsᴛ Nᴀᴍᴇ: {first_name}
"""
+ if not user.bot:
+ caption += f"\n••Sᴇᴄᴏɴᴅ Nᴀᴍᴇ: {last_name}
"
+ caption += f"""\n••Bɪᴏ: {user_bio}
+••Dᴄ ID: {dc_id}
"""
+ if (b_date:= full_user.birthday):
+ date = f"{b_date.day}-{b_date.month}"
+ if b_date.year:
+ date += f"-{b_date.year}"
+ caption += f"\n••Birthday : {date}
"
+ if full_user.stories:
+ caption += f"\n••Stories Count : {len(full_user.stories.stories)}
"
+ if user_photos:
+ caption += f"\n••Nᴏ. Oғ PғPs : {user_photos}
"
+ if not user.bot:
+ caption += f"\n••Is Rᴇsᴛʀɪᴄᴛᴇᴅ: {user.restricted}
"
+ caption += f"\n••Is Pʀᴇᴍɪᴜᴍ: {user.premium}
"
+ caption += f"""\n••Vᴇʀɪғɪᴇᴅ: {user.verified}
+••Is A Bᴏᴛ: {user.bot}
+••Gʀᴏᴜᴘs Iɴ Cᴏᴍᴍᴏɴ: {common_chats}
+"""
+ # if chk := is_gbanned(user_id):
+ # caption += f"""••Gʟᴏʙᴀʟʟʏ Bᴀɴɴᴇᴅ: True
+ # ••Rᴇᴀsᴏɴ: {chk}
"""
+ await event.client.send_message(
+ event.chat_id,
+ caption,
+ reply_to=event.reply_to_msg_id,
+ parse_mode="HTML",
+ file=full_user.profile_photo,
+ force_document=False,
+ silent=True,
+ )
+ await xx.delete()
+
+
+async def get_chat_info(chat, event):
+ if isinstance(chat, types.Channel):
+ chat_info = await event.client(functions.channels.GetFullChannelRequest(chat))
+ elif isinstance(chat, types.Chat):
+ chat_info = await event.client(functions.messages.GetFullChatRequest(chat))
+ else:
+ return await event.eor("`Use this for Group/Channel.`")
+ full = chat_info.full_chat
+ chat_photo = full.chat_photo
+ broadcast = getattr(chat, "broadcast", False)
+ chat_type = "Channel" if broadcast else "Group"
+ chat_title = chat.title
+ try:
+ msg_info = await event.client(
+ functions.messages.GetHistoryRequest(
+ peer=chat.id,
+ offset_id=0,
+ offset_date=None,
+ add_offset=-0,
+ limit=0,
+ max_id=0,
+ min_id=0,
+ hash=0,
+ )
+ )
+ except Exception as er:
+ msg_info = None
+ if not event.client._bot:
+ LOGS.exception(er)
+ first_msg_valid = bool(
+ msg_info and msg_info.messages and msg_info.messages[0].id == 1
+ )
+
+ creator_valid = bool(first_msg_valid and msg_info.users)
+ creator_id = msg_info.users[0].id if creator_valid else None
+ creator_firstname = (
+ msg_info.users[0].first_name
+ if creator_valid and msg_info.users[0].first_name is not None
+ else "Deleted Account"
+ )
+ creator_username = (
+ msg_info.users[0].username
+ if creator_valid and msg_info.users[0].username is not None
+ else None
+ )
+ created = msg_info.messages[0].date if first_msg_valid else None
+ if not isinstance(chat.photo, types.ChatPhotoEmpty):
+ dc_id = chat.photo.dc_id
+ else:
+ dc_id = "Null"
+
+ restricted_users = getattr(full, "banned_count", None)
+ members = getattr(full, "participants_count", chat.participants_count)
+ admins = getattr(full, "admins_count", None)
+ banned_users = getattr(full, "kicked_count", None)
+ members_online = getattr(full, "online_count", 0)
+ group_stickers = (
+ full.stickerset.title if getattr(full, "stickerset", None) else None
+ )
+ messages_viewable = msg_info.count if msg_info else None
+ messages_sent = getattr(full, "read_inbox_max_id", None)
+ messages_sent_alt = getattr(full, "read_outbox_max_id", None)
+ exp_count = getattr(full, "pts", None)
+ supergroup = "Yes" if getattr(chat, "megagroup", None) else "No"
+ creator_username = "@{}".format(
+ creator_username) if creator_username else None
+
+ if admins is None:
+ try:
+ participants_admins = await event.client(
+ functions.channels.GetParticipantsRequest(
+ channel=chat.id,
+ filter=types.ChannelParticipantsAdmins(),
+ offset=0,
+ limit=0,
+ hash=0,
+ )
+ )
+ admins = participants_admins.count if participants_admins else None
+ except Exception as e:
+ LOGS.info(f"Exception: {e}")
+ caption = "ℹ️ [CHAT INFO]\n"
+ caption += f"🆔 ID: {chat.id}
\n"
+ if chat_title is not None:
+ caption += f"📛 {chat_type} name: {chat_title}
\n"
+ if chat.username:
+ caption += f"🔗 Link: @{chat.username}\n"
+ else:
+ caption += f"🗳 {chat_type} type: Private\n"
+ if creator_username:
+ caption += f"🖌 Creator: {creator_username}\n"
+ elif creator_valid:
+ caption += f'🖌 Creator: {creator_firstname}\n'
+ if created:
+ caption += f"🖌 Created: {created.date().strftime('%b %d, %Y')} - {created.time()}
\n"
+ else:
+ caption += f"🖌 Created: {chat.date.date().strftime('%b %d, %Y')} - {chat.date.time()}
⚠\n"
+ caption += f"🗡 Data Centre ID: {dc_id}\n"
+ if exp_count is not None:
+ chat_level = int((1 + math.sqrt(1 + 7 * exp_count / 14)) / 2)
+ caption += f"⭐️ {chat_type} level: {chat_level}
\n"
+ if messages_viewable is not None:
+ caption += f"💬 Viewable messages: {messages_viewable}
\n"
+ if messages_sent:
+ caption += f"💬 Messages sent: {messages_sent}
\n"
+ elif messages_sent_alt:
+ caption += f"💬 Messages sent: {messages_sent_alt}
⚠\n"
+ if members is not None:
+ caption += f"👥 Members: {members}
\n"
+ if admins:
+ caption += f"👮 Administrators: {admins}
\n"
+ if full.bot_info:
+ caption += f"🤖 Bots: {len(full.bot_info)}
\n"
+ if members_online:
+ caption += f"👀 Currently online: {members_online}
\n"
+ if restricted_users is not None:
+ caption += f"🔕 Restricted users: {restricted_users}
\n"
+ if banned_users:
+ caption += f"📨 Banned users: {banned_users}
\n"
+ if group_stickers:
+ caption += f'📹 {chat_type} stickers: {group_stickers}\n'
+ if not broadcast:
+ if getattr(chat, "slowmode_enabled", None):
+ caption += f"👉 Slow mode: True
"
+ caption += f", 🕐 {full.slowmode_seconds}s
\n"
+ else:
+ caption += f"🦸♂ Supergroup: {supergroup}\n"
+ if getattr(chat, "restricted", None):
+ caption += f"🎌 Restricted: {chat.restricted}\n"
+ rist = chat.restriction_reason[0]
+ caption += f"> Platform: {rist.platform}\n"
+ caption += f"> Reason: {rist.reason}\n"
+ caption += f"> Text: {rist.text}\n\n"
+ if getattr(chat, "scam", None):
+ caption += "⚠ Scam: Yes\n"
+ if getattr(chat, "verified", None):
+ caption += f"✅ Verified by Telegram: Yes
\n\n"
+ if full.about:
+ caption += f"🗒 Description: \n{full.about}
\n"
+ return chat_photo, caption
diff --git a/plugins/vctools.py b/modules/basic/vctools.py
similarity index 60%
rename from plugins/vctools.py
rename to modules/basic/vctools.py
index dcc3c33203..1852d0433a 100644
--- a/plugins/vctools.py
+++ b/modules/basic/vctools.py
@@ -1,9 +1,10 @@
# Ultroid - UserBot
-# Copyright (C) 2021-2022 TeamUltroid
+# Copyright (C) 2021-2023 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# {}
\n🌀 PyUltroid -> {}
\n🌀 Python -> {}
\n🌀 Uptime -> {}
\n🌀 Branch ->[ {} ]\n\n• Join @TeamUltroid"
-
-
-@callback("alive")
-async def alive(event):
- text = alive_txt.format(ultroid_version, UltVer, __version__)
- await event.answer(text, alert=True)
-
-
-@ultroid_cmd(
- pattern="alive( (.*)|$)",
-)
-async def lol(ult):
- match = ult.pattern_match.group(1).strip()
- inline = None
- if match in ["inline", "i"]:
- try:
- res = await ult.client.inline_query(asst.me.username, "alive")
- return await res[0].click(ult.chat_id)
- except BotMethodInvalidError:
- pass
- except BaseException as er:
- LOGS.exception(er)
- inline = True
- pic = udB.get_key("ALIVE_PIC")
- if isinstance(pic, list):
- pic = choice(pic)
- uptime = time_formatter((time.time() - start_time) * 1000)
- header = udB.get_key("ALIVE_TEXT") or get_string("bot_1")
- y = Repo().active_branch
- xx = Repo().remotes[0].config_reader.get("url")
- rep = xx.replace(".git", f"/tree/{y}")
- kk = f" `[{y}]({rep})` "
- if inline:
- kk = f"{y}"
- parse = "html"
- als = in_alive.format(
- header,
- f"{ultroid_version} [{HOSTED_ON}]",
- UltVer,
- pyver(),
- uptime,
- kk,
- )
-
- if _e := udB.get_key("ALIVE_EMOJI"):
- als = als.replace("🌀", _e)
- else:
- parse = "md"
- als = (get_string("alive_1")).format(
- header,
- OWNER_NAME,
- f"{ultroid_version} [{HOSTED_ON}]",
- UltVer,
- uptime,
- pyver(),
- __version__,
- kk,
- )
-
- if a := udB.get_key("ALIVE_EMOJI"):
- als = als.replace("✵", a)
- if pic:
- try:
- await ult.reply(
- als,
- file=pic,
- parse_mode=parse,
- link_preview=False,
- buttons=buttons if inline else None,
- )
- return await ult.try_delete()
- except ChatSendMediaForbiddenError:
- pass
- except BaseException as er:
- LOGS.exception(er)
- try:
- await ult.reply(file=pic)
- await ult.reply(
- als,
- parse_mode=parse,
- buttons=buttons if inline else None,
- link_preview=False,
- )
- return await ult.try_delete()
- except BaseException as er:
- LOGS.exception(er)
- await eor(
- ult,
- als,
- parse_mode=parse,
- link_preview=False,
- buttons=buttons if inline else None,
- )
-
-
-@ultroid_cmd(pattern="ping$", chats=[], type=["official", "assistant"])
-async def _(event):
- start = time.time()
- x = await event.eor("Pong !")
- end = round((time.time() - start) * 1000)
- uptime = time_formatter((time.time() - start_time) * 1000)
- await x.edit(get_string("ping").format(end, uptime))
-
-
-@ultroid_cmd(
- pattern="cmds$",
-)
-async def cmds(event):
- await allcmds(event, Telegraph)
-
-
-heroku_api = Var.HEROKU_API
-
-
-@ultroid_cmd(
- pattern="restart$",
- fullsudo=True,
-)
-async def restartbt(ult):
- ok = await ult.eor(get_string("bot_5"))
- call_back()
- who = "bot" if ult.client._bot else "user"
- udB.set_key("_RESTART", f"{who}_{ult.chat_id}_{ok.id}")
- if heroku_api:
- return await restart(ok)
- await bash("git pull && pip3 install -r requirements.txt")
- if len(sys.argv) > 1:
- os.execl(sys.executable, sys.executable, "main.py")
- else:
- os.execl(sys.executable, sys.executable, "-m", "pyUltroid")
-
-
-@ultroid_cmd(
- pattern="shutdown$",
- fullsudo=True,
-)
-async def shutdownbot(ult):
- await shutdown(ult)
-
-
-@ultroid_cmd(
- pattern="logs( (.*)|$)",
- chats=[],
-)
-async def _(event):
- opt = event.pattern_match.group(1).strip()
- file = f"ultroid{sys.argv[-1]}.log" if len(sys.argv) > 1 else "ultroid.log"
- if opt == "heroku":
- await heroku_logs(event)
- elif opt == "carbon" and Carbon:
- event = await event.eor(get_string("com_1"))
- with open(file, "r") as f:
- code = f.read()[-2500:]
- file = await Carbon(
- file_name="ultroid-logs",
- code=code,
- backgroundColor=choice(ATRA_COL),
- )
- if isinstance(file, dict):
- await event.eor(f"`{file}`")
- return
- await event.reply("**Ultroid Logs.**", file=file)
- elif opt == "open":
- with open("ultroid.log", "r") as f:
- file = f.read()[-4000:]
- return await event.eor(f"`{file}`")
- else:
- await def_logs(event, file)
- await event.try_delete()
-
-
-@in_pattern("alive", owner=True)
-async def inline_alive(ult):
- pic = udB.get_key("ALIVE_PIC")
- if isinstance(pic, list):
- pic = choice(pic)
- uptime = time_formatter((time.time() - start_time) * 1000)
- header = udB.get_key("ALIVE_TEXT") or get_string("bot_1")
- y = Repo().active_branch
- xx = Repo().remotes[0].config_reader.get("url")
- rep = xx.replace(".git", f"/tree/{y}")
- kk = f"{y}"
- als = in_alive.format(
- header, f"{ultroid_version} [{HOSTED_ON}]", UltVer, pyver(), uptime, kk
- )
-
- if _e := udB.get_key("ALIVE_EMOJI"):
- als = als.replace("🌀", _e)
- builder = ult.builder
- if pic:
- try:
- if ".jpg" in pic:
- results = [
- await builder.photo(
- pic, text=als, parse_mode="html", buttons=buttons
- )
- ]
- else:
- if _pic := resolve_bot_file_id(pic):
- pic = _pic
- buttons.insert(
- 0, [Button.inline(get_string("bot_2"), data="alive")]
- )
- results = [
- await builder.document(
- pic,
- title="Inline Alive",
- description="@TeamUltroid",
- parse_mode="html",
- buttons=buttons,
- )
- ]
- return await ult.answer(results)
- except BaseException as er:
- LOGS.exception(er)
- result = [
- await builder.article(
- "Alive", text=als, parse_mode="html", link_preview=False, buttons=buttons
- )
- ]
- await ult.answer(result)
-
-
-@ultroid_cmd(pattern="update( (.*)|$)")
-async def _(e):
- xx = await e.eor(get_string("upd_1"))
- if e.pattern_match.group(1).strip() and (
- "fast" in e.pattern_match.group(1).strip()
- or "soft" in e.pattern_match.group(1).strip()
- ):
- await bash("git pull -f && pip3 install -r requirements.txt")
- call_back()
- await xx.edit(get_string("upd_7"))
- os.execl(sys.executable, "python3", "-m", "pyUltroid")
- # return
- m = await updater()
- branch = (Repo.init()).active_branch
- if m:
- x = await asst.send_file(
- udB.get_key("LOG_CHANNEL"),
- ULTPIC(),
- caption="• **Update Available** •",
- force_document=False,
- buttons=Button.inline("Changelogs", data="changes"),
- )
- Link = x.message_link
- await xx.edit(
- f'[ChangeLogs]',
- parse_mode="html",
- link_preview=False,
- )
- else:
- await xx.edit(
- f'Your BOT is
up-to-date with
[{branch}]',
- parse_mode="html",
- link_preview=False,
- )
-
-
-@callback("updtavail", owner=True)
-async def updava(event):
- await event.delete()
- await asst.send_file(
- udB.get_key("LOG_CHANNEL"),
- ULTPIC(),
- caption="• **Update Available** •",
- force_document=False,
- buttons=Button.inline("Changelogs", data="changes"),
- )
diff --git a/plugins/broadcast.py b/plugins/broadcast.py
deleted file mode 100644
index a10c996d55..0000000000
--- a/plugins/broadcast.py
+++ /dev/null
@@ -1,216 +0,0 @@
-# Ultroid - UserBot
-# Copyright (C) 2021-2022 TeamUltroid
-#
-# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
-# PLease read the GNU Affero General Public License in
-# {murl}") - extra = f"**[{xx}]({url})**\n\n" - e = await e.eor(f"{extra}`Loading More...`", link_preview=False) - - if hasattr(r.media, "document"): - file = r.media.document - mime_type = file.mime_type - filename = r.file.name - if not filename: - if "audio" in mime_type: - filename = "audio_" + dt.now().isoformat("_", "seconds") + ".ogg" - elif "video" in mime_type: - filename = "video_" + dt.now().isoformat("_", "seconds") + ".mp4" - dl = await downloader( - f"resources/downloads/{filename}", - file, - e, - taime, - f"{extra}`Loading More...`", - ) - - naam = dl.name - else: - naam = await r.download_media() - elif match and ( - os.path.isfile(match) - or (match.startswith("https://") and (await is_url_ok(match))) - ): - naam, xx = match, "file" - else: - return await e.eor(get_string("cvt_3"), time=5) - out, er = await bash(f"mediainfo '{naam}'") - if er: - LOGS.info(er) - out = extra or str(er) - return await e.edit(out, link_preview=False) - makehtml = "" - if naam.endswith((".jpg", ".png")): - if os.path.exists(naam): - med = "https://graph.org" + Telegraph.upload_file(naam)[0]["src"] - else: - med = match - makehtml += f"
{line}
" - try: - urll = await make_html_telegraph("Mediainfo", makehtml) - except Exception as er: - LOGS.exception(er) - return - await e.eor(f"{extra}[{get_string('mdi_1')}]({urll})", link_preview=False) - if not match: - os.remove(naam) - - -@ultroid_cmd(pattern="rotate( (.*)|$)") -async def rotate_(ult): - match = ult.pattern_match.group(1).strip() - if not ult.is_reply: - return await ult.eor("`Reply to a media...`") - if match: - try: - match = int(match) - except ValueError: - match = None - if not match: - return await ult.eor("`Please provide a valid angle to rotate media..`") - reply = await ult.get_reply_message() - msg = await ult.eor(get_string("com_1")) - photo = reply.game.photo if reply.game else None - if reply.video: - media = await reply.download_media() - file = f"{media}.mp4" - await bash( - f'ffmpeg -i "{media}" -c copy -metadata:s:v:0 rotate={match} "{file}" -y' - ) - elif photo or reply.photo or reply.sticker: - media = await ult.client.download_media(photo or reply) - img = cv2.imread(media) - new_ = rotate_image(img, match) - file = "ult.png" - cv2.imwrite(file, new_) - else: - return await msg.edit("`Unsupported Media..\nReply to Photo/Video`") - if os.path.exists(file): - await ult.client.send_file( - ult.chat_id, file=file, video_note=bool(reply.video_note), reply_to=reply.id - ) - os.remove(media) - await msg.try_delete() diff --git a/plugins/misc.py b/plugins/misc.py deleted file mode 100644 index e82b6702e9..0000000000 --- a/plugins/misc.py +++ /dev/null @@ -1,140 +0,0 @@ -# Ultroid - UserBot -# -# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > -# PLease read the GNU Affero General Public License in -#