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:
@@ -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 -
|
||||
|
||||
@@ -23,11 +22,13 @@
|
||||
"""
|
||||
import os
|
||||
|
||||
from pyUltroid.functions.notes_db import *
|
||||
from pyUltroid.dB.notes_db import add_note, get_notes, list_note, rem_note
|
||||
from pyUltroid.functions.tools import create_tl_btn, format_btn, get_msg_button
|
||||
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="addnote ?(.*)", admins_only=True)
|
||||
@@ -36,11 +37,10 @@ async def an(e):
|
||||
wt = await e.get_reply_message()
|
||||
chat = e.chat_id
|
||||
if not (wt and wrd):
|
||||
return await eor(
|
||||
e, "`Use this Command with Reply and word to use a note.`", time=5
|
||||
)
|
||||
return await eor(e, get_string("notes_1"), time=5)
|
||||
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")):
|
||||
@@ -50,7 +50,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)
|
||||
@@ -58,12 +58,18 @@ async def an(e):
|
||||
else:
|
||||
m = pack_bot_file_id(wt.media)
|
||||
if wt.text:
|
||||
add_note(int(chat), wrd, wt.text, m)
|
||||
txt = wt.text
|
||||
if not btn:
|
||||
txt, btn = get_msg_button(wt.text)
|
||||
add_note(int(chat), wrd, txt, m, btn)
|
||||
else:
|
||||
add_note(int(chat), wrd, None, m)
|
||||
add_note(int(chat), wrd, None, m, btn)
|
||||
else:
|
||||
add_note(int(chat), wrd, wt.text, None)
|
||||
await eor(e, f"Done Note : `#{wrd}` saved.")
|
||||
txt = wt.text
|
||||
if not btn:
|
||||
txt, btn = get_msg_button(wt.text)
|
||||
add_note(int(chat), wrd, txt, None, btn)
|
||||
await eor(e, get_string("notes_2").format(wrd))
|
||||
|
||||
|
||||
@ultroid_cmd(pattern="remnote ?(.*)", admins_only=True)
|
||||
@@ -71,9 +77,7 @@ async def rn(e):
|
||||
wrd = (e.pattern_match.group(1)).lower()
|
||||
chat = e.chat_id
|
||||
if not wrd:
|
||||
return await eor(
|
||||
e, "`Give me the note handler which you want to remove.`", time=5
|
||||
)
|
||||
return await eor(e, get_string("notes_3"), time=5)
|
||||
if wrd.startswith("#"):
|
||||
wrd = wrd.replace("#", "")
|
||||
rem_note(int(chat), wrd)
|
||||
@@ -85,21 +89,19 @@ async def lsnote(e):
|
||||
x = list_note(e.chat_id)
|
||||
if x:
|
||||
sd = "Notes Found In This Chats Are\n\n"
|
||||
await eor(e, sd + x)
|
||||
else:
|
||||
await eor(e, "No Notes Found Here")
|
||||
return await eor(e, sd + x)
|
||||
await eor(e, get_string("notes_5"))
|
||||
|
||||
|
||||
@ultroid_bot.on(events.NewMessage())
|
||||
async def notes(e):
|
||||
xx = e.text
|
||||
if not xx.startswith("#"):
|
||||
return
|
||||
xx = (xx.replace("#", "")).lower().split()
|
||||
chat = e.chat_id
|
||||
xx = [z.replace("#", "") for z in e.text.lower().split() if z.startswith("#")]
|
||||
for word in xx:
|
||||
k = get_notes(chat, word)
|
||||
k = get_notes(e.chat_id, word)
|
||||
if k:
|
||||
msg = k["msg"]
|
||||
media = k["media"]
|
||||
if k.get("button"):
|
||||
btn = create_tl_btn(k["button"])
|
||||
return await something(e, msg, media, btn)
|
||||
await e.reply(msg, file=media)
|
||||
|
||||
Reference in New Issue
Block a user