|
@@ -31,7 +31,13 @@ from wbb import SUDOERS, USERBOT_ID, USERBOT_PREFIX, app, app2, eor
|
|
|
from wbb.core.decorators.errors import capture_err
|
|
from wbb.core.decorators.errors import capture_err
|
|
|
from wbb.core.decorators.permissions import adminsOnly
|
|
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, check_format
|
|
from wbb.utils.functions import extract_text_and_keyb, check_format
|
|
|
|
|
|
|
@@ -60,7 +66,11 @@ def extract_urls(reply_markup):
|
|
|
for i, row in enumerate(buttons):
|
|
for i, row in enumerate(buttons):
|
|
|
for j, button in enumerate(row):
|
|
for j, button in enumerate(row):
|
|
|
if button.url:
|
|
if button.url:
|
|
|
- name = "\n~\nbutton" if i * len(row) + j + 1 == 1 else f"button{i * len(row) + j + 1}"
|
|
|
|
|
|
|
+ name = (
|
|
|
|
|
+ "\n~\nbutton"
|
|
|
|
|
+ if i * len(row) + j + 1 == 1
|
|
|
|
|
+ else f"button{i * len(row) + j + 1}"
|
|
|
|
|
+ )
|
|
|
urls.append((f"{name}", button.text, button.url))
|
|
urls.append((f"{name}", button.text, button.url))
|
|
|
return urls
|
|
return urls
|
|
|
|
|
|
|
@@ -86,19 +96,33 @@ async def save_notee(_, message):
|
|
|
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 and (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 and (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 replied_message and 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
|
|
match = "/save " + name
|
|
|
if not message.reply_to_message and message.text:
|
|
if not message.reply_to_message and message.text:
|
|
|
if match == data:
|
|
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]")
|
|
|
|
|
|
|
+ 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:
|
|
elif not message.reply_to_message and not message.text:
|
|
|
if match == data:
|
|
if match == data:
|
|
|
data = None
|
|
data = None
|
|
@@ -132,22 +156,28 @@ async def save_notee(_, message):
|
|
|
if replied_message.reply_markup and not "~" in data:
|
|
if replied_message.reply_markup and not "~" in data:
|
|
|
urls = extract_urls(replied_message.reply_markup)
|
|
urls = extract_urls(replied_message.reply_markup)
|
|
|
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:
|
|
if data:
|
|
|
data = await check_format(ikb, data)
|
|
data = await check_format(ikb, data)
|
|
|
if not data:
|
|
if not data:
|
|
|
- return await message.reply_text("**Wrong formatting, check the help section.**")
|
|
|
|
|
|
|
+ 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,
|
|
|
}
|
|
}
|
|
|
- chat_id = message.chat.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:
|
|
|
- return await message.reply_text("**Replied message is inaccessible.\n`Forward the message and try again`**")
|
|
|
|
|
|
|
+ return await message.reply_text(
|
|
|
|
|
+ "**Replied message is inaccessible.\n`Forward the message and try again`**"
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
|
|
|
@app2.on_message(
|
|
@app2.on_message(
|
|
@@ -204,8 +234,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
|
|
|
|
|
|
|
+ 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
|
|
@@ -214,7 +244,7 @@ async def get_one_note(_, message):
|
|
|
return
|
|
return
|
|
|
type = _note["type"]
|
|
type = _note["type"]
|
|
|
data = _note["data"]
|
|
data = _note["data"]
|
|
|
- file_id = _note["file_id"]
|
|
|
|
|
|
|
+ file_id = _note.get("file_id")
|
|
|
keyb = None
|
|
keyb = None
|
|
|
if data:
|
|
if data:
|
|
|
if "{chat}" in data:
|
|
if "{chat}" in data:
|
|
@@ -280,6 +310,7 @@ async def get_one_note(_, message):
|
|
|
reply_markup=keyb,
|
|
reply_markup=keyb,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@app2.on_message(
|
|
@app2.on_message(
|
|
|
filters.command("delete", prefixes=USERBOT_PREFIX)
|
|
filters.command("delete", prefixes=USERBOT_PREFIX)
|
|
|
& ~filters.forwarded
|
|
& ~filters.forwarded
|
|
@@ -315,12 +346,16 @@ async def delete_all(_, message):
|
|
|
else:
|
|
else:
|
|
|
keyboard = InlineKeyboardMarkup(
|
|
keyboard = InlineKeyboardMarkup(
|
|
|
[
|
|
[
|
|
|
- [InlineKeyboardButton("YES, DO IT", callback_data="delete_yes"),
|
|
|
|
|
- InlineKeyboardButton("Cancel", callback_data="delete_no")
|
|
|
|
|
|
|
+ [
|
|
|
|
|
+ InlineKeyboardButton("YES, DO IT", callback_data="delete_yes"),
|
|
|
|
|
+ InlineKeyboardButton("Cancel", callback_data="delete_no"),
|
|
|
]
|
|
]
|
|
|
]
|
|
]
|
|
|
)
|
|
)
|
|
|
- await message.reply_text("**Are you sure you want to delete all the notes in this chat forever ?.**", reply_markup=keyboard)
|
|
|
|
|
|
|
+ await message.reply_text(
|
|
|
|
|
+ "**Are you sure you want to delete all the notes in this chat forever ?.**",
|
|
|
|
|
+ reply_markup=keyboard,
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.on_callback_query(filters.regex("delete_(.*)"))
|
|
@app.on_callback_query(filters.regex("delete_(.*)"))
|
|
@@ -330,12 +365,17 @@ async def delete_all_cb(_, cb):
|
|
|
permissions = await member_permissions(chat_id, from_user.id)
|
|
permissions = await member_permissions(chat_id, from_user.id)
|
|
|
permission = "can_change_info"
|
|
permission = "can_change_info"
|
|
|
if permission not in permissions:
|
|
if permission not in permissions:
|
|
|
- return await cb.answer(f"You don't have the required permission.\n Permission: {permission}", show_alert=True)
|
|
|
|
|
|
|
+ return await cb.answer(
|
|
|
|
|
+ f"You don't have the required permission.\n Permission: {permission}",
|
|
|
|
|
+ show_alert=True,
|
|
|
|
|
+ )
|
|
|
input = cb.data.split("_", 1)[1]
|
|
input = cb.data.split("_", 1)[1]
|
|
|
if input == "yes":
|
|
if input == "yes":
|
|
|
stoped_all = await deleteall_notes(chat_id)
|
|
stoped_all = await deleteall_notes(chat_id)
|
|
|
if stoped_all:
|
|
if stoped_all:
|
|
|
- return await cb.message.edit("**Successfully deleted all notes on this chat.**")
|
|
|
|
|
|
|
+ return await cb.message.edit(
|
|
|
|
|
+ "**Successfully deleted all notes on this chat.**"
|
|
|
|
|
+ )
|
|
|
if input == "no":
|
|
if input == "no":
|
|
|
await cb.message.reply_to_message.delete()
|
|
await cb.message.reply_to_message.delete()
|
|
|
- await cb.message.delete()
|
|
|
|
|
|
|
+ await cb.message.delete()
|