{}\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")
+ await bash("pip3 install -r requirements.txt --break-system-packages")
+ 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}`")
+ 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()
+
+
+@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")
+ await bash("pip3 install -r requirements.txt --break-system-packages")
+ 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
new file mode 100644
index 0000000000000000000000000000000000000000..9734c8ef63d0c9b055400f67057509b292051ee1
--- /dev/null
+++ b/plugins/broadcast.py
@@ -0,0 +1,261 @@
+# Ultroid - UserBot
+# Copyright (C) 2021-2026 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")
+ if len(msg) > 4000:
+ with BytesIO(msg.encode()) as out_file:
+ out_file.name = "Eval-Error.txt"
+ return await event.client.send_message(
+ log_chat, f"`{cmd}`", file=out_file
+ )
+ await event.client.send_message(log_chat, msg, parse_mode="html")
+ 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,
+ cmd,
+ evaluation,
+ )
+ if len(final_output) > 4096:
+ final_output = evaluation
+ with BytesIO(str.encode(final_output)) 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,
+ )
+ return await xx.delete()
+ await xx.edit(final_output)
+
+
+def _stringify(text=None, *args, **kwargs):
+ if text:
+ u._ = text
+ text = _parse_eval(text)
+ return print(text, *args, **kwargs)
+
+
+async def aexec(code, event):
+ # Create a dedicated namespace for execution
+ exec_globals = {
+ 'print': _stringify,
+ 'p': _stringify,
+ 'message': event,
+ 'event': event,
+ 'client': event.client,
+ 'reply': await event.get_reply_message(),
+ 'chat': event.chat_id,
+ 'u': u,
+ '__builtins__': __builtins__,
+ '__name__': __name__
+ }
+
+ # Format the async function definition
+ wrapped_code = (
+ 'async def __aexec(e, client):\n' +
+ '\n'.join(f' {line}' for line in code.split('\n'))
+ )
+
+ try:
+ # Execute the wrapped code in our custom namespace
+ exec(wrapped_code, exec_globals)
+ # Get the defined async function
+ func = exec_globals['__aexec']
+ # Execute it with proper parameters
+ return await func(event, event.client)
+ except Exception as e:
+ raise Exception(f"Failed to execute code: {str(e)}")
+
+
+DUMMY_CPP = """#include {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 = upload_file(naam)
+ 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 new file mode 100644 index 0000000000000000000000000000000000000000..e82b6702e97262c19c7e95bfc2055c0dcc1e5d19 --- /dev/null +++ b/plugins/misc.py @@ -0,0 +1,140 @@ +# Ultroid - UserBot +# +# This file is a part of < https://github.com/TeamUltroid/Ultroid/ > +# PLease read the GNU Affero General Public License in +#