azils3/bash
0
1# Ultroid - UserBot2# Copyright (C) 2021-2025 TeamUltroid3#4# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >5# PLease read the GNU Affero General Public License in6# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.7"""8✘ Commands Available -9 10• `{i}addnote <word><reply to a message>`11 add note in the used chat with replied message and choosen word.12 13• `{i}remnote <word>`14 Remove the note from used chat.15 16• `{i}listnote`17 list all notes.18 19• Use :20 set notes in group so all can use it.21 type `#(Keyword of note)` to get it22"""23import os24 25from . import upload_file as uf26from telethon.utils import pack_bot_file_id27 28from pyUltroid.dB.notes_db import add_note, get_notes, list_note, rem_note29from pyUltroid.fns.tools import create_tl_btn, format_btn, get_msg_button30 31from . import events, get_string, mediainfo, udB, ultroid_bot, ultroid_cmd32from ._inline import something33 34 35@ultroid_cmd(pattern="addnote( (.*)|$)", admins_only=True)36async def an(e):37 wrd = (e.pattern_match.group(1).strip()).lower()38 wt = await e.get_reply_message()39 chat = e.chat_id40 if not (wt and wrd):41 return await e.eor(get_string("notes_1"), time=5)42 if "#" in wrd:43 wrd = wrd.replace("#", "")44 btn = format_btn(wt.buttons) if wt.buttons else None45 if wt and wt.media:46 wut = mediainfo(wt.media)47 if wut.startswith(("pic", "gif")):48 dl = await wt.download_media()49 m = uf(dl)50 os.remove(dl)51 elif wut == "video":52 if wt.media.document.size > 8 * 1000 * 1000:53 return await e.eor(get_string("com_4"), time=5)54 dl = await wt.download_media()55 m = uf(dl)56 os.remove(dl)57 else:58 m = pack_bot_file_id(wt.media)59 if wt.text:60 txt = wt.text61 if not btn:62 txt, btn = get_msg_button(wt.text)63 add_note(chat, wrd, txt, m, btn)64 else:65 add_note(chat, wrd, None, m, btn)66 else:67 txt = wt.text68 if not btn:69 txt, btn = get_msg_button(wt.text)70 add_note(chat, wrd, txt, None, btn)71 await e.eor(get_string("notes_2").format(wrd))72 ultroid_bot.add_handler(notes, events.NewMessage())73 74 75@ultroid_cmd(pattern="remnote( (.*)|$)", admins_only=True)76async def rn(e):77 wrd = (e.pattern_match.group(1).strip()).lower()78 chat = e.chat_id79 if not wrd:80 return await e.eor(get_string("notes_3"), time=5)81 if wrd.startswith("#"):82 wrd = wrd.replace("#", "")83 rem_note(int(chat), wrd)84 await e.eor(f"Done Note: `#{wrd}` Removed.")85 86 87@ultroid_cmd(pattern="listnote$", admins_only=True)88async def lsnote(e):89 if x := list_note(e.chat_id):90 sd = "Notes Found In This Chats Are\n\n"91 return await e.eor(sd + x)92 await e.eor(get_string("notes_5"))93 94 95async def notes(e):96 xx = [z.replace("#", "") for z in e.text.lower().split() if z.startswith("#")]97 for word in xx:98 if k := get_notes(e.chat_id, word):99 msg = k["msg"]100 media = k["media"]101 if k.get("button"):102 btn = create_tl_btn(k["button"])103 return await something(e, msg, media, btn)104 await e.client.send_message(105 e.chat_id, msg, file=media, reply_to=e.reply_to_msg_id or e.id106 )107 108 109if udB.get_key("NOTE"):110 ultroid_bot.add_handler(notes, events.NewMessage())111 