v0.2 11/10/2021

Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com>
Co-authored-by: Amit Sharma <buddhhu@users.noreply.github.com>
Co-authored-by: TechiError <techierror@users.noreply.github.com>
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Sonya Nikiforova <Sonniki@users.noreply.github.com>
Co-authored-by: M̲αραт <Marty2509@users.noreply.github.com>
Co-authored-by: Muhamad Risman Aziz <mrismanaziz@users.noreply.github.com>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
This commit is contained in:
1Danish-00
2021-10-11 00:27:23 +05:30
parent 8f28387fb3
commit 6f44b386aa
165 changed files with 5537 additions and 4155 deletions

View File

@@ -12,18 +12,21 @@ from math import ceil
from os import remove
from git import Repo
from pyUltroid.dB.core import *
from pyUltroid.misc import owner_and_sudos
from support import *
from telethon.tl.types import InputBotInlineResult, InputWebDocument
from pyUltroid.dB._core import HELP, LIST
from pyUltroid.functions.helper import gen_chlog, time_formatter, updater
from pyUltroid.misc import CMD_HELP, owner_and_sudos
from pyUltroid.misc._assistant import callback, in_pattern
from telethon import Button
from telethon.tl.types import InputWebDocument, Message
from telethon.utils import resolve_bot_file_id
from . import *
from . import HNDLR, INLINE_PIC, LOGS, OWNER_NAME, asst, get_string, start_time, udB
from ._help import _main_help_menu
# ================================================#
notmine = f"This bot is for {OWNER_NAME}"
TLINK = "https://telegra.ph/file/d9c9bc13647fa1d96e764.jpg"
TLINK = INLINE_PIC or "https://telegra.ph/file/d9c9bc13647fa1d96e764.jpg"
helps = get_string("inline_1")
add_ons = udB.get("ADDONS")
@@ -32,18 +35,10 @@ if add_ons == "True" or add_ons is None:
else:
zhelps = get_string("inline_3")
C_PIC = udB.get("INLINE_PIC")
if C_PIC:
_file_to_replace = C_PIC
TLINK = C_PIC
else:
_file_to_replace = "resources/extras/inline.jpg"
upage = 0
# ============================================#
# --------------------BUTTONS--------------------#
SUP_BUTTONS = [
@@ -56,24 +51,18 @@ SUP_BUTTONS = [
# --------------------BUTTONS--------------------#
@inline
@in_pattern(owner=True, func=lambda x: not x.text)
async def inline_alive(o):
if o.text or not str(o.sender_id) in owner_and_sudos():
return
b = o.builder
MSG = "• **Ultroid Userbot •**"
WEB0 = InputWebDocument(
"https://telegra.ph/file/55dd0f381c70e72557cb1.jpg", 0, "image/jpg", []
)
RES = [
InputBotInlineResult(
str(o.id),
"photo",
send_message=await b._message(
text=MSG,
media=True,
buttons=SUP_BUTTONS,
),
await o.builder.article(
type="photo",
text=MSG,
include_media=True,
buttons=SUP_BUTTONS,
title="Ultroid Userbot",
description="Userbot | Telethon",
url=TLINK,
@@ -84,29 +73,35 @@ async def inline_alive(o):
await o.answer(RES, switch_pm="👥 ULTROID PORTAL", switch_pm_param="start")
@in_pattern("ultd")
@in_owner
@in_pattern("ultd", owner=True)
async def inline_handler(event):
z = []
PLUGINS = HELP["Official"] if "Official" in HELP.keys() else []
ADDONS = HELP["Addons"] if "Addons" in HELP.keys() else []
for x in LIST.values():
for y in x:
z.append(y)
result = event.builder.photo(
file=_file_to_replace,
link_preview=False,
text=get_string("inline_4").format(
OWNER_NAME,
len(PLUGINS),
len(ADDONS),
len(z),
),
buttons=_main_help_menu,
text = get_string("inline_4").format(
OWNER_NAME,
len(PLUGINS),
len(ADDONS),
len(z),
)
if INLINE_PIC:
result = await event.builder.photo(
file=INLINE_PIC,
link_preview=False,
text=text,
buttons=_main_help_menu,
)
else:
result = await event.builder.article(
title="Ultroid Help Menu", text=text, buttons=_main_help_menu
)
await event.answer([result], gallery=True)
@in_pattern("pasta")
@in_owner
@in_pattern("pasta", owner=True)
async def _(event):
ok = event.text.split("-")[1]
link = "https://spaceb.in/" + ok
@@ -124,22 +119,22 @@ async def _(event):
await event.answer([result])
@callback("ownr")
@owner
@callback("ownr", owner=True)
async def setting(event):
z = []
PLUGINS = HELP["Official"] if "Official" in HELP.keys() else []
ADDONS = HELP["Addons"] if "Addons" in HELP.keys() else []
for x in LIST.values():
for y in x:
z.append(y)
cmd = len(z)
await event.edit(
get_string("inline_4").format(
OWNER_NAME,
len(PLUGINS),
len(ADDONS),
cmd,
len(z),
),
file=_file_to_replace,
file=INLINE_PIC,
link_preview=False,
buttons=[
[
@@ -147,7 +142,7 @@ async def setting(event):
Button.inline("•Uᴘᴛɪᴍᴇ•", data="upp"),
],
[
Button.inline("Rᴇsᴛᴀʀᴛ", data="rstrt"),
Button.inline("Stats", data="alive"),
Button.inline("•Uᴘᴅᴀᴛᴇ•", data="doupdate"),
],
[Button.inline("« Bᴀ", data="open")],
@@ -155,31 +150,26 @@ async def setting(event):
)
@callback("vc_helper")
@owner
@callback(data="vc_helper", owner=True)
async def on_vc_callback_query_handler(event):
xhelps = "**Voice Chat Help Menu for {}**\n**Available Commands:** `{}`\n\n@TeamUltroid".format(
OWNER_NAME, len(VC_HELP)
)
xhelps = get_string("inline_6").format(OWNER_NAME, len(HELP["VCBot"]))
try:
buttons = page_num(0, VC_HELP, "vchelp", "vc")
except ZeroDivisionError:
buttons = page_num(0, HELP["VCBot"].keys(), "vchelp", "vc")
except (ZeroDivisionError, KeyError):
return await event.answer("Vc not Active.")
await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
await event.edit(xhelps, file=INLINE_PIC, buttons=buttons, link_preview=False)
@callback("doupdate")
@owner
@callback(data="doupdate", owner=True)
async def _(event):
check = updater()
if not check:
return await event.answer(
"You Are Already On Latest Version", cache_time=0, alert=True
)
if not updater():
return await event.answer(get_string("inline_9"), cache_time=0, alert=True)
if not INLINE_PIC:
return await event.answer(f"Do {HNDLR}update")
repo = Repo.init()
ac_br = repo.active_branch
changelog, tl_chnglog = gen_chlog(repo, f"HEAD..upstream/{ac_br}")
changelog_str = changelog + "\n\nClick the below button to update!"
changelog_str = changelog + "\n\n" + get_string("inline_8")
if len(changelog_str) > 1024:
await event.edit(get_string("upd_4"))
with open("ultroid_updates.txt", "w+") as file:
@@ -204,7 +194,7 @@ async def _(event):
)
@callback("pkng")
@callback(data="pkng", owner=True)
async def _(event):
start = datetime.now()
end = datetime.now()
@@ -213,15 +203,14 @@ async def _(event):
await event.answer(pin, cache_time=0, alert=True)
@callback("upp")
@callback(data="upp", owner=True)
async def _(event):
uptime = time_formatter((time.time() - start_time) * 1000)
pin = f"🙋Uᴘᴛɪᴍᴇ = {uptime}"
await event.answer(pin, cache_time=0, alert=True)
@callback("inlone")
@owner
@callback(data="inlone", owner=True)
async def _(e):
button = [
[
@@ -243,15 +232,15 @@ async def _(e):
same_peer=True,
),
Button.switch_inline(
"Sᴇᴀʀᴄʜ Oɴ Yᴀʜ",
query="yahoo TeamUltroid",
"Search on XDA",
query="xda telegram",
same_peer=True,
),
],
[
Button.switch_inline(
"ɪSᴘᴇʀ",
query="msg username wspr Hello",
query="wspr @username Hello🎉",
same_peer=True,
),
Button.switch_inline(
@@ -272,7 +261,6 @@ async def _(e):
same_peer=True,
),
],
[Button.switch_inline("xda Search", query="xda telegram", same_peer=True)],
[
Button.inline(
"« Bᴀ",
@@ -283,155 +271,116 @@ async def _(e):
await e.edit(buttons=button, link_preview=False)
@callback("hrrrr")
@owner
@callback(data="hrrrr", owner=True)
async def on_plug_in_callback_query_handler(event):
xhelps = helps.format(OWNER_NAME, len(PLUGINS))
buttons = page_num(0, PLUGINS, "helpme", "def")
xhelps = helps.format(OWNER_NAME, len(HELP["Official"]))
buttons = page_num(0, HELP["Official"].keys(), "helpme", "def")
await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
@callback("frrr")
@owner
@callback(data="frrr", owner=True)
async def addon(event):
halp = zhelps.format(OWNER_NAME, len(ADDONS))
if len(ADDONS) > 0:
buttons = page_num(0, ADDONS, "addon", "add")
await event.edit(f"{halp}", buttons=buttons, link_preview=False)
if HELP.get("Addons"):
halp = zhelps.format(OWNER_NAME, len(HELP["Addons"]))
buttons = page_num(0, HELP["Addons"].keys(), "addon", "add")
await event.edit(halp, buttons=buttons, link_preview=False)
else:
await event.answer(
f"• Tʏᴘᴇ `{HNDLR}setredis ADDONS True`\n T ɢᴇᴛ ᴀᴅᴅɴs ᴘʟɢɪɴs",
f"• Tʏᴘᴇ {HNDLR}setredis ADDONS True\n T ɢᴇᴛ ᴀᴅᴅɴs ᴘʟɢɪɴs",
cache_time=0,
alert=True,
)
@callback("rstrt")
@owner
async def rrst(ult):
await restart(ult)
@callback(
re.compile(
data=re.compile(
rb"helpme_next\((.+?)\)",
),
owner=True,
)
@owner
async def on_plug_in_callback_query_handler(event):
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
buttons = page_num(current_page_number + 1, PLUGINS, "helpme", "def")
buttons = page_num(
current_page_number + 1, HELP["Official"].keys(), "helpme", "def"
)
await event.edit(buttons=buttons, link_preview=False)
@callback(
re.compile(
data=re.compile(
rb"helpme_prev\((.+?)\)",
),
owner=True,
)
@owner
async def on_plug_in_callback_query_handler(event):
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
buttons = page_num(current_page_number - 1, PLUGINS, "helpme", "def")
buttons = page_num(
current_page_number - 1, list(HELP["Official"].keys()), "helpme", "def"
)
await event.edit(buttons=buttons, link_preview=False)
@callback(
re.compile(
rb"vchelp_next\((.+?)\)",
),
)
@owner
async def on_vc_callback_query_handler(event):
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
buttons = page_num(current_page_number + 1, VC_HELP, "vchelp", "vc")
await event.edit(buttons=buttons, link_preview=False)
@callback(
re.compile(
rb"vchelp_prev\((.+?)\)",
),
)
@owner
async def on_vc_callback_query_handler(event):
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
buttons = page_num(current_page_number - 1, VC_HELP, "vchelp", "vc")
await event.edit(buttons=buttons, link_preview=False)
@callback(
re.compile(
data=re.compile(
rb"addon_next\((.+?)\)",
),
owner=True,
)
@owner
async def on_plug_in_callback_query_handler(event):
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
buttons = page_num(current_page_number + 1, ADDONS, "addon", "add")
buttons = page_num(
current_page_number + 1, list(HELP["Addons"].keys()), "addon", "add"
)
await event.edit(buttons=buttons, link_preview=False)
@callback(
re.compile(
data=re.compile(
rb"addon_prev\((.+?)\)",
),
owner=True,
)
@owner
async def on_plug_in_callback_query_handler(event):
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
buttons = page_num(current_page_number - 1, ADDONS, "addon", "add")
buttons = page_num(
current_page_number - 1, list(HELP["Addons"].keys()), "addon", "add"
)
await event.edit(buttons=buttons, link_preview=False)
@callback("back")
@owner
@callback(data="back", owner=True)
async def backr(event):
xhelps = helps.format(OWNER_NAME, len(PLUGINS))
xhelps = helps.format(OWNER_NAME, len(HELP["Official"]))
current_page_number = int(upage)
buttons = page_num(current_page_number, PLUGINS, "helpme", "def")
buttons = page_num(
current_page_number, list(HELP["Official"].keys()), "helpme", "def"
)
await event.edit(
f"{xhelps}",
file=_file_to_replace,
xhelps,
file=INLINE_PIC,
buttons=buttons,
link_preview=False,
)
@callback("buck")
@owner
@callback(data="buck", owner=True)
async def backr(event):
xhelps = zhelps.format(OWNER_NAME, len(ADDONS))
xhelps = zhelps.format(OWNER_NAME, len(HELP["Addons"]))
current_page_number = int(upage)
buttons = page_num(current_page_number, ADDONS, "addon", "add")
buttons = page_num(current_page_number, list(HELP["Addons"].keys()), "addon", "add")
await event.edit(
f"{xhelps}",
file=_file_to_replace,
xhelps,
file=INLINE_PIC,
buttons=buttons,
link_preview=False,
)
@callback("bvck")
@owner
async def bvckr(event):
xhelps = "**Voice Chat Help Menu for {}**\n**Available Commands:** `{}`\n\n@TeamUltroid".format(
OWNER_NAME, len(VC_HELP)
)
current_page_number = int(upage)
buttons = page_num(current_page_number, VC_HELP, "vchelp", "vc")
await event.edit(
f"{xhelps}",
file=_file_to_replace,
buttons=buttons,
link_preview=False,
)
@callback("open")
@owner
@callback(data="open", owner=True)
async def opner(event):
z = []
PLUGINS = HELP["Official"] if "Official" in HELP.keys() else []
ADDONS = HELP["Addons"] if "Addons" in HELP.keys() else []
for x in LIST.values():
for y in x:
z.append(y)
@@ -447,27 +396,25 @@ async def opner(event):
)
@callback("close")
@owner
@callback(data="close", owner=True)
async def on_plug_in_callback_query_handler(event):
await event.edit(
get_string("inline_5"),
file=_file_to_replace,
buttons=Button.inline("Oᴘᴇɴ Aɢᴀɪɴ", data="open"),
)
@callback(
re.compile(
data=re.compile(
b"def_plugin_(.*)",
),
owner=True,
)
@owner
async def on_plug_in_callback_query_handler(event):
plugin_name = event.data_match.group(1).decode("UTF-8")
help_string = f"Plugin Name - `{plugin_name}`\n"
try:
for i in HELP[plugin_name]:
for i in HELP["Official"][plugin_name]:
help_string += i
except BaseException:
pass
@@ -476,18 +423,21 @@ async def on_plug_in_callback_query_handler(event):
else:
reply_pop_up_alert = help_string
reply_pop_up_alert += "\n© @TeamUltroid"
buttons = [
buttons = []
if INLINE_PIC:
buttons.append(
[
Button.inline(
"« Sᴇɴᴅ Pʟɢɪɴ »",
data=f"sndplug_{(event.data).decode('UTF-8')}",
)
]
)
buttons.append(
[
Button.inline(
"« Sᴇɴᴅ Pʟɢɪɴ »",
data=f"sndplug_{(event.data).decode('UTF-8')}",
)
],
[
Button.inline("« Bᴀ", data="back"),
Button.inline("••Cʟᴇ••", data="close"),
],
]
Button.inline("« Bᴀ", data="buck"),
]
)
try:
if str(event.query.user_id) in owner_and_sudos():
await event.edit(
@@ -498,21 +448,20 @@ async def on_plug_in_callback_query_handler(event):
reply_pop_up_alert = notmine
await event.answer(reply_pop_up_alert, cache_time=0)
except BaseException:
halps = f"Do .help {plugin_name} to get the list of commands."
await event.edit(halps, buttons=buttons)
await event.edit(get_string("inline_7").format(plugin_name), buttons=buttons)
@callback(
re.compile(
data=re.compile(
b"vc_plugin_(.*)",
),
owner=True,
)
@owner
async def on_vc_plg_callback_query_handler(event):
plugin_name = event.data_match.group(1).decode("UTF-8")
help_string = f"Plugin Name - `{plugin_name}`\n"
try:
for i in VC_HELP[plugin_name]:
for i in HELP["VCBot"][plugin_name]:
help_string += i
except BaseException:
pass
@@ -521,18 +470,21 @@ async def on_vc_plg_callback_query_handler(event):
else:
reply_pop_up_alert = help_string
reply_pop_up_alert += "\n© @TeamUltroid"
buttons = [
buttons = []
if INLINE_PIC:
buttons.append(
[
Button.inline(
"« Sᴇɴᴅ Pʟɢɪɴ »",
data=f"sndplug_{(event.data).decode('UTF-8')}",
)
]
)
buttons.append(
[
Button.inline(
"« Sᴇɴᴅ Pʟɢɪɴ »",
data=f"sndplug_{(event.data).decode('UTF-8')}",
)
],
[
Button.inline("« Bᴀ", data="bvck"),
Button.inline("••Cʟᴇ••", data="close"),
],
]
Button.inline("« Bᴀ", data="vc_helper"),
]
)
try:
if str(event.query.user_id) in owner_and_sudos():
await event.edit(
@@ -548,28 +500,26 @@ async def on_vc_plg_callback_query_handler(event):
@callback(
re.compile(
data=re.compile(
b"add_plugin_(.*)",
),
owner=True,
)
@owner
async def on_plug_in_callback_query_handler(event):
plugin_name = event.data_match.group(1).decode("UTF-8")
help_string = ""
try:
for i in HELP[plugin_name]:
for i in HELP["Addons"][plugin_name]:
help_string += i
except BaseException:
try:
for u in CMD_HELP[plugin_name]:
help_string = f"Plugin Name-{plugin_name}\n\n✘ Commands Available-\n\n"
help_string = get_string("help_11").format(plugin_name)
help_string += str(CMD_HELP[plugin_name])
except BaseException:
try:
if plugin_name in LIST:
help_string = (
f"Plugin Name-{plugin_name}\n\n✘ Commands Available-\n\n"
)
help_string = get_string("help_11").format(plugin_name)
for d in LIST[plugin_name]:
help_string += HNDLR + d
help_string += "\n"
@@ -580,18 +530,21 @@ async def on_plug_in_callback_query_handler(event):
else:
reply_pop_up_alert = help_string
reply_pop_up_alert += "\n© @TeamUltroid"
buttons = [
[
Button.inline(
"« Sᴇɴᴅ Pʟɢɪɴ »",
data=f"sndplug_{(event.data).decode('UTF-8')}",
)
],
buttons = []
if INLINE_PIC:
buttons.append(
[
Button.inline(
"« Sᴇɴᴅ Pʟɢɪɴ »",
data=f"sndplug_{(event.data).decode('UTF-8')}",
)
]
)
buttons.append(
[
Button.inline("« Bᴀ", data="buck"),
Button.inline("••Cʟᴇ••", data="close"),
],
]
]
)
try:
if str(event.query.user_id) in owner_and_sudos():
await event.edit(
@@ -602,14 +555,14 @@ async def on_plug_in_callback_query_handler(event):
reply_pop_up_alert = notmine
await event.answer(reply_pop_up_alert, cache_time=0)
except BaseException:
halps = f"Do .help {plugin_name} to get the list of commands."
halps = get_string("inline_7").format(plugin_name)
await event.edit(halps, buttons=buttons)
def page_num(page_number, loaded_plugins, prefix, type_):
number_of_rows = 5
number_of_cols = 2
emoji = Redis("EMOJI_IN_HELP")
emoji = udB.get("EMOJI_IN_HELP")
multi = emoji or ""
global upage
upage = page_number
@@ -652,3 +605,100 @@ def page_num(page_number, loaded_plugins, prefix, type_):
modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
] + [(Button.inline("« Bᴀᴋ »", data="open"),)]
return pairs
# --------------------------------------------------------------------------------- #
STUFF = {}
@in_pattern("stf(.*)", owner=True)
async def ibuild(e):
n = e.pattern_match.group(1)
builder = e.builder
if not (n and n.isdigit()):
return
ok = STUFF.get(int(n))
txt = ok.get("msg") or None
pic = ok.get("media") or None
btn = ok.get("button") or None
if not (pic and txt):
txt = "Hey!"
if pic:
try:
include_media = True
mime_type, _pic = None, None
cont, results = None, None
try:
ext = str(pic).split(".")[-1].lower()
except BaseException:
ext = None
if ext in ["img", "jpg", "png"]:
_type = "photo"
mime_type = "image/jpg"
elif ext in ["mp4", "mkv", "gif"]:
mime_type = "video/mp4"
_type = "gif"
else:
try:
if "telethon.tl.types" in str(type(pic)):
_pic = pic
else:
_pic = resolve_bot_file_id(pic)
except BaseException:
pass
if _pic:
results = [
await builder.document(
_pic,
title="Ultroid Op",
text=txt,
description="@TheUltroid",
buttons=btn,
link_preview=False,
)
]
else:
_type = "article"
include_media = False
if not results:
if include_media:
cont = InputWebDocument(pic, 0, mime_type, [])
results = [
await builder.article(
title="Ultroid Op",
type=_type,
text=txt,
description="@TeamUltroid",
include_media=include_media,
buttons=btn,
thumb=cont,
content=cont,
link_preview=False,
)
]
return await e.answer(results)
except Exception as er:
LOGS.exception(er)
result = [
await builder.article("Ultroid Op", text=txt, link_preview=False, buttons=btn)
]
await e.answer(result)
async def something(e, msg, media, button, reply=True, chat=None):
if e.client._bot:
return await e.reply(msg, file=media, buttons=button)
num = len(STUFF) + 1
STUFF.update({num: {"msg": msg, "media": media, "button": button}})
try:
res = await e.client.inline_query(asst.me.username, f"stf{num}")
return await res[0].click(
chat or e.chat_id,
reply_to=bool(isinstance(e, Message) and reply),
hide_via=True,
silent=True,
)
except Exception as er:
LOGS.info(er)