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

@@ -4,7 +4,6 @@
# 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 -
@@ -22,11 +21,14 @@
"""
import os
from pyUltroid.functions.snips_db import *
from pyUltroid.dB.snips_db import add_snip, get_snips, list_snip, rem_snip
from pyUltroid.functions.tools import create_tl_btn, format_btn, get_msg_button
from pyUltroid.misc import sudoers
from telegraph import upload_file as uf
from telethon.utils import pack_bot_file_id
from . import *
from . import eor, events, get_string, mediainfo, ultroid_bot, ultroid_cmd
from ._inline import something
@ultroid_cmd(pattern="addsnip ?(.*)")
@@ -34,9 +36,10 @@ async def an(e):
wrd = (e.pattern_match.group(1)).lower()
wt = await e.get_reply_message()
if not (wt and wrd):
return await eor(e, "Give word to set as snip and reply to a message.")
return await eor(e, get_string("snip_1"))
if "$" in wrd:
wrd = wrd.replace("$", "")
btn = format_btn(wt.buttons) if wt.buttons else None
if wt and wt.media:
wut = mediainfo(wt.media)
if wut.startswith(("pic", "gif")):
@@ -46,7 +49,7 @@ async def an(e):
m = "https://telegra.ph" + variable[0]
elif wut == "video":
if wt.media.document.size > 8 * 1000 * 1000:
return await eor(x, "`Unsupported Media`", time=5)
return await eor(e, get_string("com_4"), time=5)
dl = await wt.download_media()
variable = uf(dl)
os.remove(dl)
@@ -54,11 +57,17 @@ async def an(e):
else:
m = pack_bot_file_id(wt.media)
if wt.text:
add_snip(wrd, wt.text, m)
txt = wt.text
if not btn:
txt, btn = get_msg_button(wt.text)
add_snip(wrd, txt, m, btn)
else:
add_snip(wrd, None, m)
add_snip(wrd, None, m, btn)
else:
add_snip(wrd, wt.text, None)
txt = wt.text
if not btn:
txt, btn = get_msg_button(wt.text)
add_snip(wrd, txt, None, btn)
await eor(e, f"Done : snip `${wrd}` Saved.")
@@ -66,7 +75,7 @@ async def an(e):
async def rs(e):
wrd = (e.pattern_match.group(1)).lower()
if not wrd:
return await eor(e, "Give the word to remove...")
return await eor(e, get_string("snip_2"))
if wrd.startswith("$"):
wrd = wrd.replace("$", "")
rem_snip(wrd)
@@ -87,10 +96,7 @@ async def lsnote(e):
async def notes(e):
if not e.out and str(e.sender_id) not in sudoers():
return
xx = (e.text).lower()
if not xx.startswith("$"):
return
xx = xx.replace("$", "").split()
xx = [z.replace("$", "") for z in e.text.lower().split() if z.startswith("$")]
for z in xx:
k = get_snips(z)
if k:
@@ -98,7 +104,13 @@ async def notes(e):
media = k["media"]
rep = await e.get_reply_message()
if rep:
if k.get("button"):
btn = create_tl_btn(k["button"])
return await something(rep, msg, media, btn)
await rep.reply(msg, file=media)
else:
await ultroid_bot.send_message(e.chat_id, msg, file=media)
await e.delete()
if k.get("button"):
btn = create_tl_btn(k["button"])
return await something(e, msg, media, btn, reply=None)
await ultroid_bot.send_message(e.chat_id, msg, file=media)