|
@@ -21,6 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
SOFTWARE.
|
|
SOFTWARE.
|
|
|
"""
|
|
"""
|
|
|
|
|
+
|
|
|
from re import findall
|
|
from re import findall
|
|
|
|
|
|
|
|
from pyrogram import filters
|
|
from pyrogram import filters
|
|
@@ -32,7 +33,7 @@ from wbb.core.decorators.permissions import adminsOnly
|
|
|
from wbb.core.keyboard import ikb
|
|
from wbb.core.keyboard import ikb
|
|
|
from wbb.utils.dbfunctions import delete_note, get_note, get_note_names, save_note, deleteall_notes
|
|
from wbb.utils.dbfunctions import delete_note, get_note, get_note_names, save_note, deleteall_notes
|
|
|
from wbb.modules.admin import member_permissions
|
|
from wbb.modules.admin import member_permissions
|
|
|
-from wbb.utils.functions import extract_text_and_keyb
|
|
|
|
|
|
|
+from wbb.utils.functions import extract_text_and_keyb, check_format
|
|
|
|
|
|
|
|
__MODULE__ = "Notes"
|
|
__MODULE__ = "Notes"
|
|
|
__HELP__ = """/notes To Get All The Notes In The Chat.
|
|
__HELP__ = """/notes To Get All The Notes In The Chat.
|
|
@@ -63,40 +64,44 @@ def extract_urls(reply_markup):
|
|
|
urls.append((f"{name}", button.text, button.url))
|
|
urls.append((f"{name}", button.text, button.url))
|
|
|
return urls
|
|
return urls
|
|
|
|
|
|
|
|
-@app2.on_message(
|
|
|
|
|
- filters.command("save", prefixes=USERBOT_PREFIX)
|
|
|
|
|
- & ~filters.forwarded
|
|
|
|
|
- & ~filters.via_bot
|
|
|
|
|
- & SUDOERS
|
|
|
|
|
-)
|
|
|
|
|
|
|
+
|
|
|
@app.on_message(filters.command("save") & ~filters.private)
|
|
@app.on_message(filters.command("save") & ~filters.private)
|
|
|
@adminsOnly("can_change_info")
|
|
@adminsOnly("can_change_info")
|
|
|
async def save_notee(_, message):
|
|
async def save_notee(_, message):
|
|
|
try:
|
|
try:
|
|
|
- if len(message.command) < 2 or not message.reply_to_message:
|
|
|
|
|
|
|
+ if len(message.command) < 2:
|
|
|
await eor(
|
|
await eor(
|
|
|
message,
|
|
message,
|
|
|
text="**Usage:**\nReply to a message with /save [NOTE_NAME] to save a new note.",
|
|
text="**Usage:**\nReply to a message with /save [NOTE_NAME] to save a new note.",
|
|
|
)
|
|
)
|
|
|
else:
|
|
else:
|
|
|
- text = message.text.markdown
|
|
|
|
|
|
|
+ replied_message = message.reply_to_message
|
|
|
|
|
+ if not replied_message:
|
|
|
|
|
+ replied_message = message
|
|
|
|
|
+ text = message.text.markdown if message.text else message.caption.markdown
|
|
|
name = text.split(None, 1)[1].strip()
|
|
name = text.split(None, 1)[1].strip()
|
|
|
if not name:
|
|
if not name:
|
|
|
return await eor(message, text="**Usage**\n__/save [NOTE_NAME]__")
|
|
return await eor(message, text="**Usage**\n__/save [NOTE_NAME]__")
|
|
|
- replied_message = message.reply_to_message
|
|
|
|
|
text = name.split(" ", 1)
|
|
text = name.split(" ", 1)
|
|
|
if len(text) > 1:
|
|
if len(text) > 1:
|
|
|
name = text[0]
|
|
name = text[0]
|
|
|
data = text[1].strip()
|
|
data = text[1].strip()
|
|
|
- if replied_message.sticker or replied_message.video_note:
|
|
|
|
|
|
|
+ if replied_message and (replied_message.sticker or replied_message.video_note):
|
|
|
data = None
|
|
data = None
|
|
|
else:
|
|
else:
|
|
|
- if replied_message.sticker or replied_message.video_note:
|
|
|
|
|
|
|
+ if replied_message and (replied_message.sticker or replied_message.video_note):
|
|
|
data = None
|
|
data = None
|
|
|
- elif not replied_message.text and not replied_message.caption:
|
|
|
|
|
|
|
+ elif replied_message and not replied_message.text and not replied_message.caption:
|
|
|
data = None
|
|
data = None
|
|
|
else:
|
|
else:
|
|
|
data = replied_message.text.markdown if replied_message.text else replied_message.caption.markdown
|
|
data = replied_message.text.markdown if replied_message.text else replied_message.caption.markdown
|
|
|
|
|
+ match = "/save " + name
|
|
|
|
|
+ if not message.reply_to_message and message.text:
|
|
|
|
|
+ if match == data:
|
|
|
|
|
+ return await message.reply_text("**Usage:**\n__/save [NOTE_NAME] [CONTENT]__\n`-----------OR-----------`\nReply to a message with.\n/save [NOTE_NAME]")
|
|
|
|
|
+ elif not message.reply_to_message and not message.text:
|
|
|
|
|
+ if match == data:
|
|
|
|
|
+ data = None
|
|
|
if replied_message.text:
|
|
if replied_message.text:
|
|
|
_type = "text"
|
|
_type = "text"
|
|
|
file_id = None
|
|
file_id = None
|
|
@@ -129,13 +134,16 @@ async def save_notee(_, message):
|
|
|
if urls:
|
|
if urls:
|
|
|
response = "\n".join([f"{name}=[{text}, {url}]" for name, text, url in urls])
|
|
response = "\n".join([f"{name}=[{text}, {url}]" for name, text, url in urls])
|
|
|
data = data + response
|
|
data = data + response
|
|
|
|
|
+ if data:
|
|
|
|
|
+ data = await check_format(ikb, data)
|
|
|
|
|
+ if not data:
|
|
|
|
|
+ return await message.reply_text("**Wrong formatting, check the help section.**")
|
|
|
note = {
|
|
note = {
|
|
|
"type": _type,
|
|
"type": _type,
|
|
|
"data": data,
|
|
"data": data,
|
|
|
"file_id": file_id,
|
|
"file_id": file_id,
|
|
|
}
|
|
}
|
|
|
- prefix = message.text.split()[0][0]
|
|
|
|
|
- chat_id = message.chat.id if prefix != USERBOT_PREFIX else USERBOT_ID
|
|
|
|
|
|
|
+ chat_id = message.chat.id
|
|
|
await save_note(chat_id, name, note)
|
|
await save_note(chat_id, name, note)
|
|
|
await eor(message, text=f"__**Saved note {name}.**__")
|
|
await eor(message, text=f"__**Saved note {name}.**__")
|
|
|
except UnboundLocalError:
|
|
except UnboundLocalError:
|
|
@@ -196,6 +204,8 @@ async def get_one_note_userbot(_, message):
|
|
|
@app.on_message(filters.regex(r"^#.+") & filters.text & ~filters.private)
|
|
@app.on_message(filters.regex(r"^#.+") & filters.text & ~filters.private)
|
|
|
@capture_err
|
|
@capture_err
|
|
|
async def get_one_note(_, message):
|
|
async def get_one_note(_, message):
|
|
|
|
|
+ user_id = message.from_user.id
|
|
|
|
|
+ chat_id = message.chat.id
|
|
|
name = message.text.replace("#", "", 1)
|
|
name = message.text.replace("#", "", 1)
|
|
|
if not name:
|
|
if not name:
|
|
|
return
|
|
return
|
|
@@ -206,7 +216,11 @@ async def get_one_note(_, message):
|
|
|
data = _note["data"]
|
|
data = _note["data"]
|
|
|
file_id = _note["file_id"]
|
|
file_id = _note["file_id"]
|
|
|
keyb = None
|
|
keyb = None
|
|
|
- if data:
|
|
|
|
|
|
|
+ if data:
|
|
|
|
|
+ if "{chat}" in data:
|
|
|
|
|
+ data = data.replace("{chat}", (await app.get_chat(chat_id)).title)
|
|
|
|
|
+ if "{name}" in data:
|
|
|
|
|
+ data = data.replace("{name}", (await app.get_users(user_id)).mention)
|
|
|
if findall(r"\[.+\,.+\]", data):
|
|
if findall(r"\[.+\,.+\]", data):
|
|
|
keyboard = extract_text_and_keyb(ikb, data)
|
|
keyboard = extract_text_and_keyb(ikb, data)
|
|
|
if keyboard:
|
|
if keyboard:
|