Improved naming
This commit is contained in:
parent
c4d31c955f
commit
a0616ff285
@ -6,7 +6,7 @@ from classes.pyroclient import PyroClient
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("nothing"))
|
@Client.on_callback_query(filters.regex("nothing"))
|
||||||
async def callback_query_nothing(app: PyroClient, clb: CallbackQuery):
|
async def callback_query_nothing(app: PyroClient, callback: CallbackQuery):
|
||||||
user = await app.find_user(clb.from_user)
|
user = await app.find_user(callback.from_user)
|
||||||
|
|
||||||
await clb.answer(text=app._("nothing", "callback", locale=user.locale))
|
await callback.answer(text=app._("nothing", "callback", locale=user.locale))
|
||||||
|
@ -10,11 +10,11 @@ from classes.pyroclient import PyroClient
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("shutdown"))
|
@Client.on_callback_query(filters.regex("shutdown"))
|
||||||
async def callback_query_nothing(app: PyroClient, clb: CallbackQuery):
|
async def callback_query_nothing(app: PyroClient, callback: CallbackQuery):
|
||||||
if clb.from_user.id not in app.admins:
|
if callback.from_user.id not in app.admins:
|
||||||
return
|
return
|
||||||
|
|
||||||
await clb.answer()
|
await callback.answer()
|
||||||
|
|
||||||
makedirs(await config_get("cache", "locations"), exist_ok=True)
|
makedirs(await config_get("cache", "locations"), exist_ok=True)
|
||||||
await json_write(
|
await json_write(
|
||||||
|
@ -21,22 +21,22 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("sub_yes_[\s\S]*"))
|
@Client.on_callback_query(filters.regex("sub_yes_[\s\S]*"))
|
||||||
async def callback_query_yes(app: PyroClient, clb: CallbackQuery):
|
async def callback_query_yes(app: PyroClient, callback: CallbackQuery):
|
||||||
user = await app.find_user(clb.from_user)
|
user = await app.find_user(callback.from_user)
|
||||||
fullclb = str(clb.data).split("_")
|
fullcallback = str(callback.data).split("_")
|
||||||
|
|
||||||
db_entry = await col_submitted.find_one({"_id": ObjectId(fullclb[2])})
|
db_entry = await col_submitted.find_one({"_id": ObjectId(fullcallback[2])})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
submission = await app.submit_media(fullclb[2])
|
submission = await app.submit_media(fullcallback[2])
|
||||||
except SubmissionUnavailableError:
|
except SubmissionUnavailableError:
|
||||||
await clb.answer(
|
await callback.answer(
|
||||||
text=app._("sub_msg_unavail", "callback", locale=user.locale),
|
text=app._("sub_msg_unavail", "callback", locale=user.locale),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except SubmissionUnsupportedError:
|
except SubmissionUnsupportedError:
|
||||||
await clb.answer(
|
await callback.answer(
|
||||||
text=app._("mime_not_allowed", "message", locale=user.locale).format(
|
text=app._("mime_not_allowed", "message", locale=user.locale).format(
|
||||||
", ".join(app.config["submission"]["mime_types"]), quote=True
|
", ".join(app.config["submission"]["mime_types"]), quote=True
|
||||||
),
|
),
|
||||||
@ -44,11 +44,11 @@ async def callback_query_yes(app: PyroClient, clb: CallbackQuery):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
except SubmissionDuplicatesError as exc:
|
except SubmissionDuplicatesError as exc:
|
||||||
await clb.answer(
|
await callback.answer(
|
||||||
text=app._("sub_duplicates_found", "callback", locale=user.locale),
|
text=app._("sub_duplicates_found", "callback", locale=user.locale),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
await clb.message.reply_text(
|
await callback.message.reply_text(
|
||||||
app._("sub_media_duplicates_list", "message", locale=user.locale).format(
|
app._("sub_media_duplicates_list", "message", locale=user.locale).format(
|
||||||
"\n • ".join(exc.duplicates)
|
"\n • ".join(exc.duplicates)
|
||||||
),
|
),
|
||||||
@ -56,7 +56,7 @@ async def callback_query_yes(app: PyroClient, clb: CallbackQuery):
|
|||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
"Submission with ID '%s' could not be accepted because of the duplicates: %s",
|
"Submission with ID '%s' could not be accepted because of the duplicates: %s",
|
||||||
fullclb[2],
|
fullcallback[2],
|
||||||
str(exc.duplicates),
|
str(exc.duplicates),
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -80,8 +80,8 @@ async def callback_query_yes(app: PyroClient, clb: CallbackQuery):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
await clb.answer(
|
await callback.answer(
|
||||||
text=app._("sub_yes", "callback", locale=user.locale).format(fullclb[2]),
|
text=app._("sub_yes", "callback", locale=user.locale).format(fullcallback[2]),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,9 +93,9 @@ async def callback_query_yes(app: PyroClient, clb: CallbackQuery):
|
|||||||
callback_data="nothing",
|
callback_data="nothing",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
clb.message.reply_markup.inline_keyboard[1],
|
callback.message.reply_markup.inline_keyboard[1],
|
||||||
]
|
]
|
||||||
if len(clb.message.reply_markup.inline_keyboard) > 1
|
if len(callback.message.reply_markup.inline_keyboard) > 1
|
||||||
else [
|
else [
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
@ -107,27 +107,29 @@ async def callback_query_yes(app: PyroClient, clb: CallbackQuery):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if await config_get("send_uploaded_id", "submission"):
|
if await config_get("send_uploaded_id", "submission"):
|
||||||
await clb.message.edit_caption(
|
await callback.message.edit_caption(
|
||||||
f"{clb.message.caption}\n\nID: `{submission[1]}`"
|
f"{callback.message.caption}\n\nID: `{submission[1]}`"
|
||||||
)
|
)
|
||||||
|
|
||||||
await clb.message.edit_reply_markup(
|
await callback.message.edit_reply_markup(
|
||||||
reply_markup=InlineKeyboardMarkup(edited_markup)
|
reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Submission with ID '%s' accepted and uploaded with ID '%s'",
|
"Submission with ID '%s' accepted and uploaded with ID '%s'",
|
||||||
fullclb[2],
|
fullcallback[2],
|
||||||
submission[1],
|
submission[1],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("sub_no_[\s\S]*"))
|
@Client.on_callback_query(filters.regex("sub_no_[\s\S]*"))
|
||||||
async def callback_query_no(app: PyroClient, clb: CallbackQuery):
|
async def callback_query_no(app: PyroClient, callback: CallbackQuery):
|
||||||
user = await app.find_user(clb.from_user)
|
user = await app.find_user(callback.from_user)
|
||||||
fullclb = str(clb.data).split("_")
|
fullcallback = str(callback.data).split("_")
|
||||||
|
|
||||||
db_entry = await col_submitted.find_one_and_delete({"_id": ObjectId(fullclb[2])})
|
db_entry = await col_submitted.find_one_and_delete(
|
||||||
|
{"_id": ObjectId(fullcallback[2])}
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
db_entry["temp"]["uuid"] is not None
|
db_entry["temp"]["uuid"] is not None
|
||||||
@ -147,7 +149,7 @@ async def callback_query_no(app: PyroClient, clb: CallbackQuery):
|
|||||||
db_entry["user"], db_entry["telegram"]["msg_id"]
|
db_entry["user"], db_entry["telegram"]["msg_id"]
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
await clb.answer(
|
await callback.answer(
|
||||||
text=app._("sub_msg_unavail", "message", locale=user.locale),
|
text=app._("sub_msg_unavail", "message", locale=user.locale),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
@ -161,8 +163,8 @@ async def callback_query_no(app: PyroClient, clb: CallbackQuery):
|
|||||||
),
|
),
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
await clb.answer(
|
await callback.answer(
|
||||||
text=app._("sub_no", "callback", locale=user.locale).format(fullclb[2]),
|
text=app._("sub_no", "callback", locale=user.locale).format(fullcallback[2]),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -174,9 +176,9 @@ async def callback_query_no(app: PyroClient, clb: CallbackQuery):
|
|||||||
callback_data="nothing",
|
callback_data="nothing",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
clb.message.reply_markup.inline_keyboard[1],
|
callback.message.reply_markup.inline_keyboard[1],
|
||||||
]
|
]
|
||||||
if len(clb.message.reply_markup.inline_keyboard) > 1
|
if len(callback.message.reply_markup.inline_keyboard) > 1
|
||||||
else [
|
else [
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
@ -186,81 +188,83 @@ async def callback_query_no(app: PyroClient, clb: CallbackQuery):
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
await clb.message.edit_reply_markup(
|
await callback.message.edit_reply_markup(
|
||||||
reply_markup=InlineKeyboardMarkup(edited_markup)
|
reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
"Submission with ID '%s' rejected",
|
"Submission with ID '%s' rejected",
|
||||||
fullclb[2],
|
fullcallback[2],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("sub_block_[\s\S]*"))
|
@Client.on_callback_query(filters.regex("sub_block_[\s\S]*"))
|
||||||
async def callback_query_block(app: PyroClient, clb: CallbackQuery):
|
async def callback_query_block(app: PyroClient, callback: CallbackQuery):
|
||||||
user = await app.find_user(clb.from_user)
|
user = await app.find_user(callback.from_user)
|
||||||
fullclb = str(clb.data).split("_")
|
fullcallback = str(callback.data).split("_")
|
||||||
|
|
||||||
await app.send_message(
|
await app.send_message(
|
||||||
int(fullclb[2]),
|
int(fullcallback[2]),
|
||||||
app._(
|
app._(
|
||||||
"sub_blocked",
|
"sub_blocked",
|
||||||
"message",
|
"message",
|
||||||
locale=(await app.find_user(int(fullclb[2]))).locale,
|
locale=(await app.find_user(int(fullcallback[2]))).locale,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await user.block()
|
await user.block()
|
||||||
|
|
||||||
await clb.answer(
|
await callback.answer(
|
||||||
text=app._("sub_block", "callback", locale=user.locale).format(fullclb[2]),
|
text=app._("sub_block", "callback", locale=user.locale).format(fullcallback[2]),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
edited_markup = [
|
edited_markup = [
|
||||||
clb.message.reply_markup.inline_keyboard[0],
|
callback.message.reply_markup.inline_keyboard[0],
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=str(app._("sub_unblock", "button", locale=user.locale)),
|
text=str(app._("sub_unblock", "button", locale=user.locale)),
|
||||||
callback_data=f"sub_unblock_{fullclb[2]}",
|
callback_data=f"sub_unblock_{fullcallback[2]}",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
await clb.message.edit_reply_markup(
|
await callback.message.edit_reply_markup(
|
||||||
reply_markup=InlineKeyboardMarkup(edited_markup)
|
reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||||
)
|
)
|
||||||
logger.info("User %s has been blocked", fullclb[2])
|
logger.info("User %s has been blocked", fullcallback[2])
|
||||||
|
|
||||||
|
|
||||||
@Client.on_callback_query(filters.regex("sub_unblock_[\s\S]*"))
|
@Client.on_callback_query(filters.regex("sub_unblock_[\s\S]*"))
|
||||||
async def callback_query_unblock(app: PyroClient, clb: CallbackQuery):
|
async def callback_query_unblock(app: PyroClient, callback: CallbackQuery):
|
||||||
user = await app.find_user(clb.from_user)
|
user = await app.find_user(callback.from_user)
|
||||||
fullclb = str(clb.data).split("_")
|
fullcallback = str(callback.data).split("_")
|
||||||
|
|
||||||
await app.send_message(
|
await app.send_message(
|
||||||
int(fullclb[2]),
|
int(fullcallback[2]),
|
||||||
app._(
|
app._(
|
||||||
"sub_unblocked",
|
"sub_unblocked",
|
||||||
"message",
|
"message",
|
||||||
locale=(await app.find_user(int(fullclb[2]))).locale,
|
locale=(await app.find_user(int(fullcallback[2]))).locale,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
await user.unblock()
|
await user.unblock()
|
||||||
|
|
||||||
await clb.answer(
|
await callback.answer(
|
||||||
text=app._("sub_unblock", "callback", locale=user.locale).format(fullclb[2]),
|
text=app._("sub_unblock", "callback", locale=user.locale).format(
|
||||||
|
fullcallback[2]
|
||||||
|
),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
edited_markup = [
|
edited_markup = [
|
||||||
clb.message.reply_markup.inline_keyboard[0],
|
callback.message.reply_markup.inline_keyboard[0],
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=str(app._("sub_block", "button", locale=user.locale)),
|
text=str(app._("sub_block", "button", locale=user.locale)),
|
||||||
callback_data=f"sub_block_{fullclb[2]}",
|
callback_data=f"sub_block_{fullcallback[2]}",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
await clb.message.edit_reply_markup(
|
await callback.message.edit_reply_markup(
|
||||||
reply_markup=InlineKeyboardMarkup(edited_markup)
|
reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||||
)
|
)
|
||||||
logger.info("User %s has been unblocked", fullclb[2])
|
logger.info("User %s has been unblocked", fullcallback[2])
|
||||||
|
@ -15,14 +15,14 @@ from modules.utils import USERS_WITH_CONTEXT
|
|||||||
@Client.on_message(
|
@Client.on_message(
|
||||||
~filters.scheduled & filters.command(["shutdown"], prefixes=["", "/"])
|
~filters.scheduled & filters.command(["shutdown"], prefixes=["", "/"])
|
||||||
)
|
)
|
||||||
async def cmd_kill(app: PyroClient, msg: Message):
|
async def cmd_kill(app: PyroClient, message: Message):
|
||||||
if msg.from_user.id not in app.admins:
|
if message.from_user.id not in app.admins:
|
||||||
return
|
return
|
||||||
|
|
||||||
user = await app.find_user(msg.from_user)
|
user = await app.find_user(message.from_user)
|
||||||
|
|
||||||
if len(USERS_WITH_CONTEXT) > 0:
|
if len(USERS_WITH_CONTEXT) > 0:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("shutdown_confirm", "message", locale=user.locale).format(
|
app._("shutdown_confirm", "message", locale=user.locale).format(
|
||||||
len(USERS_WITH_CONTEXT)
|
len(USERS_WITH_CONTEXT)
|
||||||
),
|
),
|
||||||
|
@ -11,13 +11,13 @@ from modules import custom_filters
|
|||||||
& ~filters.scheduled
|
& ~filters.scheduled
|
||||||
& filters.command(["start"], prefixes="/")
|
& filters.command(["start"], prefixes="/")
|
||||||
)
|
)
|
||||||
async def cmd_start(app: PyroClient, msg: Message):
|
async def cmd_start(app: PyroClient, message: Message):
|
||||||
user = await app.find_user(msg.from_user)
|
user = await app.find_user(message.from_user)
|
||||||
|
|
||||||
if user.banned:
|
if user.banned:
|
||||||
return
|
return
|
||||||
|
|
||||||
await msg.reply_text(app._("start", "message", locale=user.locale))
|
await message.reply_text(app._("start", "message", locale=user.locale))
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
@Client.on_message(
|
||||||
@ -25,10 +25,10 @@ async def cmd_start(app: PyroClient, msg: Message):
|
|||||||
& ~filters.scheduled
|
& ~filters.scheduled
|
||||||
& filters.command(["rules", "help"], prefixes="/")
|
& filters.command(["rules", "help"], prefixes="/")
|
||||||
)
|
)
|
||||||
async def cmd_rules(app: PyroClient, msg: Message):
|
async def cmd_rules(app: PyroClient, message: Message):
|
||||||
user = await app.find_user(msg.from_user)
|
user = await app.find_user(message.from_user)
|
||||||
|
|
||||||
if user.banned:
|
if user.banned:
|
||||||
return
|
return
|
||||||
|
|
||||||
await msg.reply_text(app._("rules", "message", locale=user.locale))
|
await message.reply_text(app._("rules", "message", locale=user.locale))
|
||||||
|
@ -37,27 +37,27 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_message(~filters.scheduled & filters.command(["import"], prefixes=["", "/"]))
|
@Client.on_message(~filters.scheduled & filters.command(["import"], prefixes=["", "/"]))
|
||||||
async def cmd_import(app: PyroClient, msg: Message):
|
async def cmd_import(app: PyroClient, message: Message):
|
||||||
if msg.from_user.id not in app.admins:
|
if message.from_user.id not in app.admins:
|
||||||
return
|
return
|
||||||
|
|
||||||
global USERS_WITH_CONTEXT
|
global USERS_WITH_CONTEXT
|
||||||
|
|
||||||
if msg.from_user.id not in USERS_WITH_CONTEXT:
|
if message.from_user.id not in USERS_WITH_CONTEXT:
|
||||||
USERS_WITH_CONTEXT.append(msg.from_user.id)
|
USERS_WITH_CONTEXT.append(message.from_user.id)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
user = await app.find_user(msg.from_user)
|
user = await app.find_user(message.from_user)
|
||||||
|
|
||||||
await msg.reply_text(app._("import_request", "message", locale=user.locale))
|
await message.reply_text(app._("import_request", "message", locale=user.locale))
|
||||||
|
|
||||||
answer = await listen_message(app, msg.chat.id, timeout=600)
|
answer = await listen_message(app, message.chat.id, timeout=600)
|
||||||
|
|
||||||
USERS_WITH_CONTEXT.remove(msg.from_user.id)
|
USERS_WITH_CONTEXT.remove(message.from_user.id)
|
||||||
|
|
||||||
if answer is None:
|
if answer is None:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("import_ignored", "message", locale=user.locale),
|
app._("import_ignored", "message", locale=user.locale),
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
@ -86,7 +86,7 @@ async def cmd_import(app: PyroClient, msg: Message):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if disk_usage(getcwd())[2] < (answer.document.file_size) * 3:
|
if disk_usage(getcwd())[2] < (answer.document.file_size) * 3:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("import_too_big", "message", locale=user.locale).format(
|
app._("import_too_big", "message", locale=user.locale).format(
|
||||||
answer.document.file_size // (2**30),
|
answer.document.file_size // (2**30),
|
||||||
disk_usage(getcwd())[2] // (2**30),
|
disk_usage(getcwd())[2] // (2**30),
|
||||||
@ -172,7 +172,7 @@ async def cmd_import(app: PyroClient, msg: Message):
|
|||||||
Path(f"{app.config['locations']['tmp']}/{tmp_dir}"),
|
Path(f"{app.config['locations']['tmp']}/{tmp_dir}"),
|
||||||
exc,
|
exc,
|
||||||
)
|
)
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._(
|
app._(
|
||||||
"import_upload_error_other",
|
"import_upload_error_other",
|
||||||
"message",
|
"message",
|
||||||
@ -193,7 +193,7 @@ async def cmd_import(app: PyroClient, msg: Message):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if len(uploaded_dict["duplicates"]) > 0:
|
if len(uploaded_dict["duplicates"]) > 0:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._(
|
app._(
|
||||||
"import_upload_error_duplicate",
|
"import_upload_error_duplicate",
|
||||||
"message",
|
"message",
|
||||||
@ -202,7 +202,7 @@ async def cmd_import(app: PyroClient, msg: Message):
|
|||||||
disable_notification=True,
|
disable_notification=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._(
|
app._(
|
||||||
"import_upload_error_other",
|
"import_upload_error_other",
|
||||||
"message",
|
"message",
|
||||||
@ -235,35 +235,35 @@ async def cmd_import(app: PyroClient, msg: Message):
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_message(~filters.scheduled & filters.command(["export"], prefixes=["", "/"]))
|
@Client.on_message(~filters.scheduled & filters.command(["export"], prefixes=["", "/"]))
|
||||||
async def cmd_export(app: PyroClient, msg: Message):
|
async def cmd_export(app: PyroClient, message: Message):
|
||||||
if msg.from_user.id not in app.admins:
|
if message.from_user.id not in app.admins:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(~filters.scheduled & filters.command(["remove"], prefixes=["", "/"]))
|
@Client.on_message(~filters.scheduled & filters.command(["remove"], prefixes=["", "/"]))
|
||||||
async def cmd_remove(app: PyroClient, msg: Message):
|
async def cmd_remove(app: PyroClient, message: Message):
|
||||||
if msg.from_user.id not in app.admins:
|
if message.from_user.id not in app.admins:
|
||||||
return
|
return
|
||||||
|
|
||||||
global USERS_WITH_CONTEXT
|
global USERS_WITH_CONTEXT
|
||||||
|
|
||||||
if msg.from_user.id not in USERS_WITH_CONTEXT:
|
if message.from_user.id not in USERS_WITH_CONTEXT:
|
||||||
USERS_WITH_CONTEXT.append(msg.from_user.id)
|
USERS_WITH_CONTEXT.append(message.from_user.id)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
user = await app.find_user(msg.from_user)
|
user = await app.find_user(message.from_user)
|
||||||
|
|
||||||
await msg.reply_text(app._("remove_request", "message", locale=user.locale))
|
await message.reply_text(app._("remove_request", "message", locale=user.locale))
|
||||||
|
|
||||||
answer_id = await app.listen.Message(
|
answer_id = await app.listen.Message(
|
||||||
filters.text & ~filters.me, id=filters.user(msg.from_user.id), timeout=600
|
filters.text & ~filters.me, id=filters.user(message.from_user.id), timeout=600
|
||||||
)
|
)
|
||||||
|
|
||||||
USERS_WITH_CONTEXT.remove(msg.from_user.id)
|
USERS_WITH_CONTEXT.remove(message.from_user.id)
|
||||||
|
|
||||||
if answer_id is None:
|
if answer_id is None:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("remove_ignored", "message", locale=user.locale),
|
app._("remove_ignored", "message", locale=user.locale),
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
@ -273,7 +273,7 @@ async def cmd_remove(app: PyroClient, msg: Message):
|
|||||||
await answer_id.reply_text(app._("remove_abort", "message", locale=user.locale))
|
await answer_id.reply_text(app._("remove_abort", "message", locale=user.locale))
|
||||||
return
|
return
|
||||||
|
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("remove_kind", "message", locale=user.locale),
|
app._("remove_kind", "message", locale=user.locale),
|
||||||
reply_markup=ReplyKeyboardMarkup(
|
reply_markup=ReplyKeyboardMarkup(
|
||||||
[
|
[
|
||||||
@ -287,16 +287,16 @@ async def cmd_remove(app: PyroClient, msg: Message):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
USERS_WITH_CONTEXT.append(msg.from_user.id)
|
USERS_WITH_CONTEXT.append(message.from_user.id)
|
||||||
|
|
||||||
answer_kind = await app.listen.Message(
|
answer_kind = await app.listen.Message(
|
||||||
filters.text & ~filters.me, id=filters.user(msg.from_user.id), timeout=600
|
filters.text & ~filters.me, id=filters.user(message.from_user.id), timeout=600
|
||||||
)
|
)
|
||||||
|
|
||||||
USERS_WITH_CONTEXT.remove(msg.from_user.id)
|
USERS_WITH_CONTEXT.remove(message.from_user.id)
|
||||||
|
|
||||||
if answer_kind is None:
|
if answer_kind is None:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("remove_ignored", "message", locale=user.locale),
|
app._("remove_ignored", "message", locale=user.locale),
|
||||||
quote=True,
|
quote=True,
|
||||||
reply_markup=ReplyKeyboardRemove(),
|
reply_markup=ReplyKeyboardRemove(),
|
||||||
@ -355,6 +355,6 @@ async def cmd_remove(app: PyroClient, msg: Message):
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_message(~filters.scheduled & filters.command(["purge"], prefixes=["", "/"]))
|
@Client.on_message(~filters.scheduled & filters.command(["purge"], prefixes=["", "/"]))
|
||||||
async def cmd_purge(app: PyroClient, msg: Message):
|
async def cmd_purge(app: PyroClient, message: Message):
|
||||||
if msg.from_user.id not in app.admins:
|
if message.from_user.id not in app.admins:
|
||||||
return
|
return
|
||||||
|
@ -14,24 +14,25 @@ from modules import custom_filters
|
|||||||
& filters.reply
|
& filters.reply
|
||||||
& filters.command(["report"], prefixes=["", "/"])
|
& filters.command(["report"], prefixes=["", "/"])
|
||||||
)
|
)
|
||||||
async def command_report(app: PyroClient, msg: Message):
|
async def command_report(app: PyroClient, message: Message):
|
||||||
if msg.reply_to_message.forward_from_chat.id != app.config["posting"]["channel"]:
|
if (
|
||||||
|
message.reply_to_message.forward_from_chat.id
|
||||||
|
!= app.config["posting"]["channel"]
|
||||||
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
user = await app.find_user(msg.from_user)
|
user = await app.find_user(message.from_user)
|
||||||
|
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._(
|
app._(
|
||||||
"report_sent",
|
"report_sent",
|
||||||
"message",
|
"message",
|
||||||
locale=user.locale if msg.from_user is not None else None,
|
locale=user.locale if message.from_user is not None else None,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
print(msg)
|
report_sent = await message.reply_to_message.forward(app.owner)
|
||||||
|
sender = message.from_user if message.from_user is not None else message.sender_chat
|
||||||
report_sent = await msg.reply_to_message.forward(app.owner)
|
|
||||||
sender = msg.from_user if msg.from_user is not None else msg.sender_chat
|
|
||||||
|
|
||||||
sender_name = sender.first_name if isinstance(sender, User) else sender.title
|
sender_name = sender.first_name if isinstance(sender, User) else sender.title
|
||||||
|
|
||||||
|
@ -26,115 +26,121 @@ logger = logging.getLogger(__name__)
|
|||||||
# | filters.animation
|
# | filters.animation
|
||||||
| filters.document
|
| filters.document
|
||||||
)
|
)
|
||||||
async def get_submission(app: PyroClient, msg: Message):
|
async def get_submission(app: PyroClient, message: Message):
|
||||||
global USERS_WITH_CONTEXT
|
global USERS_WITH_CONTEXT
|
||||||
|
|
||||||
if not hasattr(msg.from_user, "id"):
|
if not hasattr(message.from_user, "id"):
|
||||||
return
|
return
|
||||||
|
|
||||||
if msg.from_user.id in USERS_WITH_CONTEXT:
|
if message.from_user.id in USERS_WITH_CONTEXT:
|
||||||
return
|
return
|
||||||
|
|
||||||
user = await app.find_user(msg.from_user)
|
user = await app.find_user(message.from_user)
|
||||||
user_owner = await app.find_user(app.owner)
|
user_owner = await app.find_user(app.owner)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if user.banned:
|
if user.banned:
|
||||||
return
|
return
|
||||||
|
|
||||||
await app.send_chat_action(msg.chat.id, ChatAction.TYPING)
|
await app.send_chat_action(message.chat.id, ChatAction.TYPING)
|
||||||
|
|
||||||
save_tmp = True
|
save_tmp = True
|
||||||
contents = None
|
contents = None
|
||||||
|
|
||||||
if await user.is_limited():
|
if await user.is_limited():
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("sub_cooldown", "message", locale=user.locale).format(
|
app._("sub_cooldown", "message", locale=user.locale).format(
|
||||||
app.config["submission"]["timeout"]
|
app.config["submission"]["timeout"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if msg.document is not None:
|
if message.document is not None:
|
||||||
logger.info(
|
logger.info(
|
||||||
"User %s is trying to submit a file of type '%s' with name '%s' and size of %s MB",
|
"User %s is trying to submit a file of type '%s' with name '%s' and size of %s MB",
|
||||||
msg.from_user.id,
|
message.from_user.id,
|
||||||
msg.document.mime_type,
|
message.document.mime_type,
|
||||||
msg.document.file_name,
|
message.document.file_name,
|
||||||
msg.document.file_size / 1024 / 1024,
|
message.document.file_size / 1024 / 1024,
|
||||||
)
|
)
|
||||||
if msg.document.mime_type not in app.config["submission"]["mime_types"]:
|
if message.document.mime_type not in app.config["submission"]["mime_types"]:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("mime_not_allowed", "message", locale=user.locale).format(
|
app._("mime_not_allowed", "message", locale=user.locale).format(
|
||||||
", ".join(app.config["submission"]["mime_types"])
|
", ".join(app.config["submission"]["mime_types"])
|
||||||
),
|
),
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if msg.document.file_size > app.config["submission"]["file_size"]:
|
if message.document.file_size > app.config["submission"]["file_size"]:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("document_too_large", "message", locale=user.locale).format(
|
app._("document_too_large", "message", locale=user.locale).format(
|
||||||
app.config["submission"]["file_size"] / 1024 / 1024
|
app.config["submission"]["file_size"] / 1024 / 1024
|
||||||
),
|
),
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if msg.document.file_size > app.config["submission"]["tmp_size"]:
|
if message.document.file_size > app.config["submission"]["tmp_size"]:
|
||||||
save_tmp = False
|
save_tmp = False
|
||||||
contents = (
|
contents = (
|
||||||
msg.document.file_id,
|
message.document.file_id,
|
||||||
SubmissionType.DOCUMENT,
|
SubmissionType.DOCUMENT,
|
||||||
) # , msg.document.file_name
|
) # , message.document.file_name
|
||||||
|
|
||||||
if msg.video is not None:
|
if message.video is not None:
|
||||||
logger.info(
|
logger.info(
|
||||||
"User %s is trying to submit a video with name '%s' and size of %s MB",
|
"User %s is trying to submit a video with name '%s' and size of %s MB",
|
||||||
msg.from_user.id,
|
message.from_user.id,
|
||||||
msg.video.file_name,
|
message.video.file_name,
|
||||||
msg.video.file_size / 1024 / 1024,
|
message.video.file_size / 1024 / 1024,
|
||||||
)
|
)
|
||||||
if msg.video.file_size > app.config["submission"]["file_size"]:
|
if message.video.file_size > app.config["submission"]["file_size"]:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("document_too_large", "message", locale=user.locale).format(
|
app._("document_too_large", "message", locale=user.locale).format(
|
||||||
app.config["submission"]["file_size"] / 1024 / 1024
|
app.config["submission"]["file_size"] / 1024 / 1024
|
||||||
),
|
),
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if msg.video.file_size > app.config["submission"]["tmp_size"]:
|
if message.video.file_size > app.config["submission"]["tmp_size"]:
|
||||||
save_tmp = False
|
save_tmp = False
|
||||||
contents = msg.video.file_id, SubmissionType.VIDEO # , msg.video.file_name
|
contents = (
|
||||||
|
message.video.file_id,
|
||||||
|
SubmissionType.VIDEO,
|
||||||
|
) # , message.video.file_name
|
||||||
|
|
||||||
# if msg.animation is not None:
|
# if message.animation is not None:
|
||||||
# logger.info(
|
# logger.info(
|
||||||
# "User %s is trying to submit an animation with name '%s' and size of %s MB",
|
# "User %s is trying to submit an animation with name '%s' and size of %s MB",
|
||||||
# msg.from_user.id,
|
# message.from_user.id,
|
||||||
# msg.animation.file_name,
|
# message.animation.file_name,
|
||||||
# msg.animation.file_size / 1024 / 1024,
|
# message.animation.file_size / 1024 / 1024,
|
||||||
# )
|
# )
|
||||||
# if msg.animation.file_size > app.config["submission"]["file_size"]:
|
# if message.animation.file_size > app.config["submission"]["file_size"]:
|
||||||
# await msg.reply_text(
|
# await message.reply_text(
|
||||||
# app._("document_too_large", "message", locale=user.locale).format(
|
# app._("document_too_large", "message", locale=user.locale).format(
|
||||||
# str(app.config["submission"]["file_size"] / 1024 / 1024)
|
# str(app.config["submission"]["file_size"] / 1024 / 1024)
|
||||||
# ),
|
# ),
|
||||||
# quote=True,
|
# quote=True,
|
||||||
# )
|
# )
|
||||||
# return
|
# return
|
||||||
# if msg.animation.file_size > app.config["submission"]["tmp_size"]:
|
# if message.animation.file_size > app.config["submission"]["tmp_size"]:
|
||||||
# save_tmp = False
|
# save_tmp = False
|
||||||
# contents = (
|
# contents = (
|
||||||
# msg.animation.file_id,
|
# message.animation.file_id,
|
||||||
# SubmissionType.ANIMATION,
|
# SubmissionType.ANIMATION,
|
||||||
# ) # , msg.animation.file_name
|
# ) # , message.animation.file_name
|
||||||
|
|
||||||
if msg.photo is not None:
|
if message.photo is not None:
|
||||||
logger.info(
|
logger.info(
|
||||||
"User %s is trying to submit a photo with ID '%s' and size of %s MB",
|
"User %s is trying to submit a photo with ID '%s' and size of %s MB",
|
||||||
msg.from_user.id,
|
message.from_user.id,
|
||||||
msg.photo.file_id,
|
message.photo.file_id,
|
||||||
msg.photo.file_size / 1024 / 1024,
|
message.photo.file_size / 1024 / 1024,
|
||||||
)
|
)
|
||||||
contents = msg.photo.file_id, SubmissionType.PHOTO # , "please_generate"
|
contents = (
|
||||||
|
message.photo.file_id,
|
||||||
|
SubmissionType.PHOTO,
|
||||||
|
) # , "please_generate"
|
||||||
|
|
||||||
if contents is None:
|
if contents is None:
|
||||||
return
|
return
|
||||||
@ -148,33 +154,37 @@ async def get_submission(app: PyroClient, msg: Message):
|
|||||||
exist_ok=True,
|
exist_ok=True,
|
||||||
)
|
)
|
||||||
downloaded = await app.download_media(
|
downloaded = await app.download_media(
|
||||||
msg,
|
message,
|
||||||
str(Path(f"{app.config['locations']['data']}/submissions/{tmp_id}"))
|
str(Path(f"{app.config['locations']['data']}/submissions/{tmp_id}"))
|
||||||
+ sep,
|
+ sep,
|
||||||
)
|
)
|
||||||
|
|
||||||
inserted = await col_submitted.insert_one(
|
inserted = await col_submitted.insert_one(
|
||||||
{
|
{
|
||||||
"user": msg.from_user.id,
|
"user": message.from_user.id,
|
||||||
"date": datetime.now(),
|
"date": datetime.now(),
|
||||||
"done": False,
|
"done": False,
|
||||||
"type": contents[1].value,
|
"type": contents[1].value,
|
||||||
"temp": {"uuid": tmp_id, "file": path.basename(str(downloaded))},
|
"temp": {"uuid": tmp_id, "file": path.basename(str(downloaded))},
|
||||||
"telegram": {"msg_id": msg.id, "file_id": contents[0]},
|
"telegram": {"msg_id": message.id, "file_id": contents[0]},
|
||||||
"caption": str(msg.caption) if msg.caption is not None else None,
|
"caption": str(message.caption)
|
||||||
|
if message.caption is not None
|
||||||
|
else None,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
inserted = await col_submitted.insert_one(
|
inserted = await col_submitted.insert_one(
|
||||||
{
|
{
|
||||||
"user": msg.from_user.id,
|
"user": message.from_user.id,
|
||||||
"date": datetime.now(),
|
"date": datetime.now(),
|
||||||
"done": False,
|
"done": False,
|
||||||
"type": contents[1].value,
|
"type": contents[1].value,
|
||||||
"temp": {"uuid": None, "file": None},
|
"temp": {"uuid": None, "file": None},
|
||||||
"telegram": {"msg_id": msg.id, "file_id": contents[0]},
|
"telegram": {"msg_id": message.id, "file_id": contents[0]},
|
||||||
"caption": str(msg.caption) if msg.caption is not None else None,
|
"caption": str(message.caption)
|
||||||
|
if message.caption is not None
|
||||||
|
else None,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -187,8 +197,8 @@ async def get_submission(app: PyroClient, msg: Message):
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
if msg.caption is not None:
|
if message.caption is not None:
|
||||||
caption = str(msg.caption)
|
caption = str(message.caption)
|
||||||
buttons[0].append(
|
buttons[0].append(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=app._("sub_yes_caption", "button", locale=user_owner.locale),
|
text=app._("sub_yes_caption", "button", locale=user_owner.locale),
|
||||||
@ -206,32 +216,34 @@ async def get_submission(app: PyroClient, msg: Message):
|
|||||||
)
|
)
|
||||||
caption += app._("sub_by", "message", locale=user_owner.locale)
|
caption += app._("sub_by", "message", locale=user_owner.locale)
|
||||||
|
|
||||||
if msg.from_user.first_name is not None:
|
if message.from_user.first_name is not None:
|
||||||
caption += f" {msg.from_user.first_name}"
|
caption += f" {message.from_user.first_name}"
|
||||||
if msg.from_user.last_name is not None:
|
if message.from_user.last_name is not None:
|
||||||
caption += f" {msg.from_user.last_name}"
|
caption += f" {message.from_user.last_name}"
|
||||||
if msg.from_user.username is not None:
|
if message.from_user.username is not None:
|
||||||
caption += f" (@{msg.from_user.username})"
|
caption += f" (@{message.from_user.username})"
|
||||||
if msg.from_user.phone_number is not None:
|
if message.from_user.phone_number is not None:
|
||||||
caption += f" ({msg.from_user.phone_number})"
|
caption += f" ({message.from_user.phone_number})"
|
||||||
|
|
||||||
if (
|
if (
|
||||||
msg.from_user.id in app.admins
|
message.from_user.id in app.admins
|
||||||
and app.config["submission"]["require_confirmation"]["admins"] is False
|
and app.config["submission"]["require_confirmation"]["admins"] is False
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
submitted = await app.submit_media(str(inserted.inserted_id))
|
submitted = await app.submit_media(str(inserted.inserted_id))
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("sub_yes_auto", "message", locale=user.locale),
|
app._("sub_yes_auto", "message", locale=user.locale),
|
||||||
disable_notification=True,
|
disable_notification=True,
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
if app.config["submission"]["send_uploaded_id"]:
|
if app.config["submission"]["send_uploaded_id"]:
|
||||||
caption += f"\n\nID: `{submitted[1]}`"
|
caption += f"\n\nID: `{submitted[1]}`"
|
||||||
await msg.copy(app.owner, caption=caption, disable_notification=True)
|
await message.copy(
|
||||||
|
app.owner, caption=caption, disable_notification=True
|
||||||
|
)
|
||||||
return
|
return
|
||||||
except SubmissionUnsupportedError:
|
except SubmissionUnsupportedError:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("mime_not_allowed", "message", locale=user.locale).format(
|
app._("mime_not_allowed", "message", locale=user.locale).format(
|
||||||
", ".join(app.config["submission"]["mime_types"]), quote=True
|
", ".join(app.config["submission"]["mime_types"]), quote=True
|
||||||
),
|
),
|
||||||
@ -239,7 +251,7 @@ async def get_submission(app: PyroClient, msg: Message):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
except SubmissionDuplicatesError as exc:
|
except SubmissionDuplicatesError as exc:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._(
|
app._(
|
||||||
"sub_media_duplicates_list", "message", locale=user.locale
|
"sub_media_duplicates_list", "message", locale=user.locale
|
||||||
).format("\n • ".join(exc.duplicates)),
|
).format("\n • ".join(exc.duplicates)),
|
||||||
@ -247,32 +259,32 @@ async def get_submission(app: PyroClient, msg: Message):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
await msg.reply_text(exc, quote=True)
|
await message.reply_text(exc, quote=True)
|
||||||
return
|
return
|
||||||
elif (
|
elif (
|
||||||
msg.from_user.id not in app.admins
|
message.from_user.id not in app.admins
|
||||||
and app.config["submission"]["require_confirmation"]["users"] is False
|
and app.config["submission"]["require_confirmation"]["users"] is False
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
submitted = await app.submit_photo(str(inserted.inserted_id))
|
submitted = await app.submit_photo(str(inserted.inserted_id))
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("sub_yes_auto", "message", locale=user.locale),
|
app._("sub_yes_auto", "message", locale=user.locale),
|
||||||
disable_notification=True,
|
disable_notification=True,
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
if app.config["submission"]["send_uploaded_id"]:
|
if app.config["submission"]["send_uploaded_id"]:
|
||||||
caption += f"\n\nID: `{submitted[1]}`"
|
caption += f"\n\nID: `{submitted[1]}`"
|
||||||
await msg.copy(app.owner, caption=caption)
|
await message.copy(app.owner, caption=caption)
|
||||||
return
|
return
|
||||||
except SubmissionUnsupportedError:
|
except SubmissionUnsupportedError:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("mime_not_allowed", "message", locale=user.locale).format(
|
app._("mime_not_allowed", "message", locale=user.locale).format(
|
||||||
", ".join(app.config["submission"]["mime_types"]), quote=True
|
", ".join(app.config["submission"]["mime_types"]), quote=True
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except SubmissionDuplicatesError as exc:
|
except SubmissionDuplicatesError as exc:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("sub_dup", "message", locale=user.locale), quote=True
|
app._("sub_dup", "message", locale=user.locale), quote=True
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -281,31 +293,31 @@ async def get_submission(app: PyroClient, msg: Message):
|
|||||||
app.owner,
|
app.owner,
|
||||||
app._(
|
app._(
|
||||||
"sub_error_admin", "message", locale=user_owner.locale
|
"sub_error_admin", "message", locale=user_owner.locale
|
||||||
).format(msg.from_user.id, format_exc()),
|
).format(message.from_user.id, format_exc()),
|
||||||
)
|
)
|
||||||
await msg.reply_text("sub_error", quote=True)
|
await message.reply_text("sub_error", quote=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
if msg.from_user.id not in app.admins:
|
if message.from_user.id not in app.admins:
|
||||||
buttons += [
|
buttons += [
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=app._("sub_block", "button", locale=user_owner.locale),
|
text=app._("sub_block", "button", locale=user_owner.locale),
|
||||||
callback_data=f"sub_block_{msg.from_user.id}",
|
callback_data=f"sub_block_{message.from_user.id}",
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
await user.update_cooldown()
|
await user.update_cooldown()
|
||||||
|
|
||||||
if msg.from_user.id != app.owner:
|
if message.from_user.id != app.owner:
|
||||||
await msg.reply_text(
|
await message.reply_text(
|
||||||
app._("sub_sent", "message", locale=user.locale),
|
app._("sub_sent", "message", locale=user.locale),
|
||||||
disable_notification=True,
|
disable_notification=True,
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
await msg.copy(
|
await message.copy(
|
||||||
app.owner, caption=caption, reply_markup=InlineKeyboardMarkup(buttons)
|
app.owner, caption=caption, reply_markup=InlineKeyboardMarkup(buttons)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,6 +8,6 @@ from classes.pyroclient import PyroClient
|
|||||||
@Client.on_message(
|
@Client.on_message(
|
||||||
~filters.scheduled & filters.private & filters.command(["remove_commands"], prefixes=["/"]) # type: ignore
|
~filters.scheduled & filters.private & filters.command(["remove_commands"], prefixes=["/"]) # type: ignore
|
||||||
)
|
)
|
||||||
async def command_remove_commands(app: PyroClient, msg: Message):
|
async def command_remove_commands(app: PyroClient, message: Message):
|
||||||
await msg.reply_text("Okay.")
|
await message.reply_text("Okay.")
|
||||||
await app.remove_commands(command_sets=await app.collect_commands())
|
await app.remove_commands(command_sets=await app.collect_commands())
|
||||||
|
Reference in New Issue
Block a user