dev (#19)
* Config file changes * Commands `/remove`, `/import` and `/export` Co-authored-by: profitroll <vozhd.kk@gmail.com> Co-authored-by: Profitroll <47523801+profitrollgame@users.noreply.github.com> Co-authored-by: Renovate <renovate@git.end-play.xyz> Reviewed-on: #19
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
from modules.app import app
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import CallbackQuery
|
||||
from pyrogram.client import Client
|
||||
from classes.poster_client import PosterClient
|
||||
from modules.utils import locale
|
||||
|
||||
# Callback empty ===============================================================================================================
|
||||
|
||||
@app.on_callback_query(filters.regex("nothing"))
|
||||
async def callback_query_nothing(app: Client, clb: CallbackQuery):
|
||||
await clb.answer(text=locale("nothing", "callback", locale=clb.from_user))
|
||||
# ==============================================================================================================================
|
||||
async def callback_query_nothing(app: PosterClient, clb: CallbackQuery):
|
||||
await clb.answer(
|
||||
text=locale("nothing", "callback", locale=clb.from_user.language_code)
|
||||
)
|
||||
|
29
plugins/callbacks/shutdown.py
Normal file
29
plugins/callbacks/shutdown.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from os import getpid, makedirs, path
|
||||
from time import time
|
||||
from modules.app import app
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import CallbackQuery
|
||||
from classes.poster_client import PosterClient
|
||||
from modules.scheduler import scheduler
|
||||
from modules.logger import logWrite
|
||||
from modules.utils import configGet, jsonSave, locale
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("shutdown"))
|
||||
async def callback_query_nothing(app: PosterClient, clb: CallbackQuery):
|
||||
if clb.from_user.id in app.admins:
|
||||
pid = getpid()
|
||||
logWrite(f"Shutting down bot with pid {pid}")
|
||||
await clb.answer()
|
||||
await clb.message.reply_text(
|
||||
locale("shutdown", "message", locale=clb.from_user.language_code).format(
|
||||
pid
|
||||
),
|
||||
)
|
||||
scheduler.shutdown()
|
||||
makedirs(configGet("cache", "locations"), exist_ok=True)
|
||||
jsonSave(
|
||||
{"timestamp": time()},
|
||||
path.join(configGet("cache", "locations"), "shutdown_time"),
|
||||
)
|
||||
exit()
|
@@ -1,116 +1,274 @@
|
||||
from os import path, sep
|
||||
from pathlib import Path
|
||||
|
||||
from os import path
|
||||
from shutil import rmtree
|
||||
from pyrogram import filters
|
||||
from pyrogram.client import Client
|
||||
from pyrogram.types import CallbackQuery
|
||||
from pyrogram.types import CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from classes.exceptions import SubmissionDuplicatesError, SubmissionUnavailableError
|
||||
from classes.poster_client import PosterClient
|
||||
from classes.user import PosterUser
|
||||
|
||||
from modules.api_client import upload_pic
|
||||
from modules.app import app
|
||||
from modules.submissions import subBlock, subUnblock
|
||||
from modules.utils import configGet, jsonLoad, jsonSave, locale
|
||||
from modules.logger import logWrite
|
||||
from modules.utils import configGet, locale
|
||||
from modules.database import col_submitted
|
||||
from bson import ObjectId
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_yes_[\s\S]*"))
|
||||
async def callback_query_yes(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
async def callback_query_yes(app: PosterClient, clb: CallbackQuery):
|
||||
fullclb = str(clb.data).split("_")
|
||||
user_locale = clb.from_user.language_code
|
||||
|
||||
# Check if submission is in DB and really exists
|
||||
|
||||
# Upload the file to the API server
|
||||
|
||||
# Modify submission in DB to state that it's accepted (or so called "done")
|
||||
|
||||
# Change keyboard to a completed variant
|
||||
|
||||
# Send replies to both user and admin about accepting the application
|
||||
|
||||
db_entry = col_submitted.find_one({"_id": ObjectId(fullclb[2])})
|
||||
|
||||
if db_entry is None:
|
||||
await clb.answer(text=locale("sub_msg_unavail", "message", locale=user_locale), show_alert=True)
|
||||
return
|
||||
else:
|
||||
if db_entry["tmp"]["uuid"] is not None:
|
||||
if not path.exists(path.join(configGet("data", "locations"), "submissions", db_entry["tmp"]["uuid"], db_entry["tmp"]["file"])):
|
||||
await clb.answer(text=locale("sub_msg_unavail", "message", locale=user_locale), show_alert=True)
|
||||
return
|
||||
else:
|
||||
try:
|
||||
submission = await app.get_messages(db_entry["user"], db_entry["telegram"]["msg_id"])
|
||||
except:
|
||||
await clb.answer(text=locale("sub_msg_unavail", "message", locale=user_locale), show_alert=True)
|
||||
return
|
||||
|
||||
try:
|
||||
if configGet("api_based", "mode") is True:
|
||||
media = await app.download_media(submission, file_name=configGet("tmp", "locations")+sep)
|
||||
upload = upload_pic(media)
|
||||
if upload[0] is False:
|
||||
await clb.answer(text=locale("sub_media_failed", "message", locale=user_locale), show_alert=True)
|
||||
elif len(upload[1]) > 0:
|
||||
await clb.answer(text=locale("sub_media_duplicates", "message", locale=user_locale))
|
||||
await clb.message.reply_text(locale("sub_media_duplicates_list", "message", locale=user_locale).format("\n • ".join(upload[1])))
|
||||
else:
|
||||
if clb.data.endswith("_caption"):
|
||||
index = jsonLoad(configGet("index", "locations"))
|
||||
index["captions"][Path(media).name] = submission.caption
|
||||
jsonSave(index, configGet("index", "locations"))
|
||||
else:
|
||||
media = await app.download_media(submission, file_name=configGet("queue", "locations")+sep)
|
||||
if clb.data.endswith("_caption"):
|
||||
index = jsonLoad(configGet("index", "locations"))
|
||||
index["captions"][Path(media).name] = submission.caption
|
||||
jsonSave(index, configGet("index", "locations"))
|
||||
except:
|
||||
await clb.answer(text=locale("sub_media_unavail", "message", locale=user_locale), show_alert=True)
|
||||
submission = await app.submit_photo(fullclb[2])
|
||||
except SubmissionUnavailableError:
|
||||
await clb.answer(
|
||||
text=locale("sub_msg_unavail", "callback", locale=user_locale),
|
||||
show_alert=True,
|
||||
)
|
||||
return
|
||||
except SubmissionDuplicatesError as exp:
|
||||
await clb.answer(
|
||||
text=locale("sub_duplicates_found", "callback", locale=user_locale),
|
||||
show_alert=True,
|
||||
)
|
||||
await clb.message.reply_text(
|
||||
locale("sub_media_duplicates_list", "message", locale=user_locale).format(
|
||||
"\n • ".join(exp.duplicates)
|
||||
),
|
||||
quote=True,
|
||||
)
|
||||
logWrite(
|
||||
locale(
|
||||
"submission_duplicate",
|
||||
"console",
|
||||
locale=configGet("locale_log").format(
|
||||
fullclb[2],
|
||||
str(exp.duplicates),
|
||||
),
|
||||
),
|
||||
debug=True,
|
||||
)
|
||||
return
|
||||
await submission.reply_text(locale("sub_yes", "message", locale=submission.from_user.language_code), quote=True)
|
||||
await clb.answer(text=locale("sub_yes", "callback", locale=user_locale).format(fullclb[2]), show_alert=True)
|
||||
|
||||
# edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||
# await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
if submission[0] is not None:
|
||||
await submission[0].reply_text(
|
||||
locale("sub_yes", "message", locale=submission[0].from_user.language_code),
|
||||
quote=True,
|
||||
)
|
||||
elif db_entry is not None:
|
||||
await app.send_message(db_entry["user"], locale("sub_yes", "message"))
|
||||
|
||||
await clb.answer(
|
||||
text=locale("sub_yes", "callback", locale=user_locale).format(fullclb[2]),
|
||||
show_alert=True,
|
||||
)
|
||||
|
||||
edited_markup = (
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("accepted", "button", locale=user_locale)),
|
||||
callback_data="nothing",
|
||||
)
|
||||
],
|
||||
clb.message.reply_markup.inline_keyboard[1],
|
||||
]
|
||||
if len(clb.message.reply_markup.inline_keyboard) > 1
|
||||
else [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("accepted", "button", locale=user_locale)),
|
||||
callback_data="nothing",
|
||||
)
|
||||
]
|
||||
]
|
||||
)
|
||||
|
||||
if configGet("send_uploaded_id", "submission"):
|
||||
await clb.message.edit_caption(
|
||||
clb.message.caption + f"\n\nID: `{submission[1]}`"
|
||||
)
|
||||
|
||||
await clb.message.edit_reply_markup(
|
||||
reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
|
||||
logWrite(
|
||||
locale(
|
||||
"submission_accepted",
|
||||
"console",
|
||||
locale=configGet("locale_log").format(fullclb[2], submission[1]),
|
||||
),
|
||||
debug=True,
|
||||
)
|
||||
|
||||
# try:
|
||||
# if configGet("api_based", "mode") is True:
|
||||
# media = await app.download_media(submission, file_name=configGet("tmp", "locations")+sep)
|
||||
# upload = upload_pic(media)
|
||||
# if upload[0] is False:
|
||||
# await clb.answer(text=locale("sub_media_failed", "message", locale=user_locale), show_alert=True)
|
||||
# elif len(upload[1]) > 0:
|
||||
# await clb.answer(text=locale("sub_media_duplicates", "message", locale=user_locale))
|
||||
# await clb.message.reply_text(locale("sub_media_duplicates_list", "message", locale=user_locale).format("\n • ".join(upload[1])))
|
||||
# else:
|
||||
# if clb.data.endswith("_caption"):
|
||||
# index = jsonLoad(configGet("index", "locations"))
|
||||
# index["captions"][Path(media).name] = submission.caption
|
||||
# jsonSave(index, configGet("index", "locations"))
|
||||
# else:
|
||||
# media = await app.download_media(submission, file_name=configGet("queue", "locations")+sep)
|
||||
# if clb.data.endswith("_caption"):
|
||||
# index = jsonLoad(configGet("index", "locations"))
|
||||
# index["captions"][Path(media).name] = submission.caption
|
||||
# jsonSave(index, configGet("index", "locations"))
|
||||
# except:
|
||||
# await clb.answer(text=locale("sub_media_unavail", "message", locale=user_locale), show_alert=True)
|
||||
# return
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_no_[\s\S]*"))
|
||||
async def callback_query_no(app: Client, clb: CallbackQuery):
|
||||
fullclb = clb.data.split("_")
|
||||
async def callback_query_no(app: PosterClient, clb: CallbackQuery):
|
||||
fullclb = str(clb.data).split("_")
|
||||
user_locale = clb.from_user.language_code
|
||||
try:
|
||||
submission = await app.get_messages(int(fullclb[2]), int(fullclb[3]))
|
||||
except:
|
||||
await clb.answer(text=locale("sub_msg_unavail", "message", locale=user_locale), show_alert=True)
|
||||
return
|
||||
await submission.reply_text(locale("sub_no", "message", locale=submission.from_user.language_code), quote=True)
|
||||
await clb.answer(text=locale("sub_no", "callback", locale=user_locale).format(fullclb[2]), show_alert=True)
|
||||
|
||||
# edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||
# await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
db_entry = col_submitted.find_one_and_delete({"_id": ObjectId(fullclb[2])})
|
||||
|
||||
if db_entry["temp"]["uuid"] is not None:
|
||||
if path.exists(
|
||||
path.join(
|
||||
configGet("data", "locations"), "submissions", db_entry["temp"]["uuid"]
|
||||
)
|
||||
):
|
||||
rmtree(
|
||||
path.join(
|
||||
configGet("data", "locations"),
|
||||
"submissions",
|
||||
db_entry["temp"]["uuid"],
|
||||
),
|
||||
ignore_errors=True,
|
||||
)
|
||||
|
||||
try:
|
||||
submission = await app.get_messages(
|
||||
db_entry["user"], db_entry["telegram"]["msg_id"]
|
||||
)
|
||||
except:
|
||||
await clb.answer(
|
||||
text=locale("sub_msg_unavail", "message", locale=user_locale),
|
||||
show_alert=True,
|
||||
)
|
||||
return
|
||||
|
||||
await submission.reply_text(
|
||||
locale("sub_no", "message", locale=submission.from_user.language_code),
|
||||
quote=True,
|
||||
)
|
||||
await clb.answer(
|
||||
text=locale("sub_no", "callback", locale=user_locale).format(fullclb[2]),
|
||||
show_alert=True,
|
||||
)
|
||||
|
||||
edited_markup = (
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("declined", "button", locale=user_locale)),
|
||||
callback_data="nothing",
|
||||
)
|
||||
],
|
||||
clb.message.reply_markup.inline_keyboard[1],
|
||||
]
|
||||
if len(clb.message.reply_markup.inline_keyboard) > 1
|
||||
else [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("declined", "button", locale=user_locale)),
|
||||
callback_data="nothing",
|
||||
)
|
||||
]
|
||||
]
|
||||
)
|
||||
await clb.message.edit_reply_markup(
|
||||
reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
logWrite(
|
||||
locale(
|
||||
"submission_rejected",
|
||||
"console",
|
||||
locale=configGet("locale_log").format(fullclb[2]),
|
||||
),
|
||||
debug=True,
|
||||
)
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_block_[\s\S]*"))
|
||||
async def callback_query_block(app: Client, clb: CallbackQuery):
|
||||
fullclb = clb.data.split("_")
|
||||
async def callback_query_block(app: PosterClient, clb: CallbackQuery):
|
||||
fullclb = str(clb.data).split("_")
|
||||
user_locale = clb.from_user.language_code
|
||||
await app.send_message(int(fullclb[2]), locale("sub_msg_unavail", "message", locale=configGet("locale")))
|
||||
subBlock(int(fullclb[2]))
|
||||
await clb.answer(text=locale("sub_block", "callback", locale=user_locale).format(fullclb[2]), show_alert=True)
|
||||
await app.send_message(
|
||||
int(fullclb[2]), locale("sub_blocked", "message", locale=configGet("locale"))
|
||||
)
|
||||
PosterUser(int(fullclb[2])).block()
|
||||
await clb.answer(
|
||||
text=locale("sub_block", "callback", locale=user_locale).format(fullclb[2]),
|
||||
show_alert=True,
|
||||
)
|
||||
|
||||
# edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||
# await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
edited_markup = [
|
||||
clb.message.reply_markup.inline_keyboard[0],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("sub_unblock", "button", locale=user_locale)),
|
||||
callback_data=f"sub_unblock_{fullclb[2]}",
|
||||
)
|
||||
],
|
||||
]
|
||||
await clb.message.edit_reply_markup(
|
||||
reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
logWrite(
|
||||
locale(
|
||||
"user_blocked",
|
||||
"console",
|
||||
locale=configGet("locale_log").format(fullclb[2]),
|
||||
),
|
||||
debug=True,
|
||||
)
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_unblock_[\s\S]*"))
|
||||
async def callback_query_unblock(app: Client, clb: CallbackQuery):
|
||||
fullclb = clb.data.split("_")
|
||||
@app.on_callback_query(filters.regex("sub_unblock_[\s\S]*"))
|
||||
async def callback_query_unblock(app: PosterClient, clb: CallbackQuery):
|
||||
fullclb = str(clb.data).split("_")
|
||||
user_locale = clb.from_user.language_code
|
||||
await app.send_message(int(fullclb[2]), locale("sub_msg_unavail", "message", locale=configGet("locale")))
|
||||
subUnblock(int(fullclb[2]))
|
||||
await clb.answer(text=locale("sub_unblock", "callback", locale=user_locale).format(fullclb[2]), show_alert=True)
|
||||
await app.send_message(
|
||||
int(fullclb[2]), locale("sub_unblocked", "message", locale=configGet("locale"))
|
||||
)
|
||||
PosterUser(int(fullclb[2])).unblock()
|
||||
await clb.answer(
|
||||
text=locale("sub_unblock", "callback", locale=user_locale).format(fullclb[2]),
|
||||
show_alert=True,
|
||||
)
|
||||
|
||||
# edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||
# await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
edited_markup = [
|
||||
clb.message.reply_markup.inline_keyboard[0],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("sub_block", "button", locale=user_locale)),
|
||||
callback_data=f"sub_block_{fullclb[2]}",
|
||||
)
|
||||
],
|
||||
]
|
||||
await clb.message.edit_reply_markup(
|
||||
reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
logWrite(
|
||||
locale(
|
||||
"user_unblocked",
|
||||
"console",
|
||||
locale=configGet("locale_log").format(fullclb[2]),
|
||||
),
|
||||
debug=True,
|
||||
)
|
||||
|
@@ -1,19 +1,45 @@
|
||||
from os import getpid
|
||||
from os import getpid, makedirs, path
|
||||
from time import time
|
||||
|
||||
from pyrogram import filters
|
||||
from pyrogram.client import Client
|
||||
from pyrogram.types import Message
|
||||
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
|
||||
from modules.app import app
|
||||
from classes.poster_client import PosterClient
|
||||
from modules.app import app, users_with_context
|
||||
from modules.logger import logWrite
|
||||
from modules.utils import configGet, killProc, locale
|
||||
from modules.scheduler import scheduler
|
||||
from modules.utils import configGet, jsonSave, locale
|
||||
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.command(["kill", "die", "reboot"], prefixes=["", "/"]))
|
||||
async def cmd_kill(app: Client, msg: Message):
|
||||
|
||||
if msg.from_user.id == configGet("admin"):
|
||||
@app.on_message(~filters.scheduled & filters.command(["shutdown"], prefixes=["", "/"]))
|
||||
async def cmd_kill(app: PosterClient, msg: Message):
|
||||
if msg.from_user.id in app.admins:
|
||||
global users_with_context
|
||||
if len(users_with_context) > 0:
|
||||
await msg.reply_text(
|
||||
f"There're {len(users_with_context)} unfinished users' contexts. If you turn off the bot, those will be lost. Please confirm shutdown using a button below.",
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
"Confirm shutdown", callback_data="shutdown"
|
||||
)
|
||||
]
|
||||
]
|
||||
),
|
||||
)
|
||||
return
|
||||
pid = getpid()
|
||||
logWrite(locale("shutdown", "console", locale=configGet("locale")).format(str(pid)))
|
||||
await msg.reply_text(locale("shutdown", "message", locale=configGet("locale")).format(str(pid)))
|
||||
killProc(pid)
|
||||
logWrite(f"Shutting down bot with pid {pid}")
|
||||
await msg.reply_text(
|
||||
locale("shutdown", "message", locale=msg.from_user.language_code).format(
|
||||
pid
|
||||
),
|
||||
)
|
||||
scheduler.shutdown()
|
||||
makedirs(configGet("cache", "locations"), exist_ok=True)
|
||||
jsonSave(
|
||||
{"timestamp": time()},
|
||||
path.join(configGet("cache", "locations"), "shutdown_time"),
|
||||
)
|
||||
exit()
|
||||
|
@@ -1,18 +1,23 @@
|
||||
from pyrogram import filters
|
||||
from pyrogram.client import Client
|
||||
from pyrogram.types import Message
|
||||
|
||||
from modules.app import app
|
||||
from modules.submissions import subBlocked
|
||||
from modules.utils import configGet, jsonLoad, locale
|
||||
from modules.utils import locale
|
||||
from classes.user import PosterUser
|
||||
from classes.poster_client import PosterClient
|
||||
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.command(["start"], prefixes="/"))
|
||||
async def cmd_start(app: Client, msg: Message):
|
||||
if subBlocked(msg.from_user) is False:
|
||||
await msg.reply_text(locale("start", "message", locale=msg.from_user.language_code))
|
||||
@app.on_message(~filters.scheduled & filters.command(["start"], prefixes="/"))
|
||||
async def cmd_start(app: PosterClient, msg: Message):
|
||||
if PosterUser(msg.from_user.id).is_blocked() is False:
|
||||
await msg.reply_text(
|
||||
locale("start", "message", locale=msg.from_user.language_code)
|
||||
)
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.command(["rules", "help"], prefixes="/"))
|
||||
async def cmd_rules(app: Client, msg: Message):
|
||||
if subBlocked(msg.from_user) is False:
|
||||
await msg.reply_text(locale("rules", "message", locale=msg.from_user.language_code))
|
||||
|
||||
@app.on_message(~filters.scheduled & filters.command(["rules", "help"], prefixes="/"))
|
||||
async def cmd_rules(app: PosterClient, msg: Message):
|
||||
if PosterUser(msg.from_user.id).is_blocked() is False:
|
||||
await msg.reply_text(
|
||||
locale("rules", "message", locale=msg.from_user.language_code)
|
||||
)
|
||||
|
214
plugins/commands/photos.py
Normal file
214
plugins/commands/photos.py
Normal file
@@ -0,0 +1,214 @@
|
||||
import asyncio
|
||||
from glob import iglob
|
||||
from os import getcwd, makedirs, path, remove
|
||||
from shutil import disk_usage, rmtree
|
||||
from traceback import format_exc
|
||||
from uuid import uuid4
|
||||
from zipfile import ZipFile
|
||||
|
||||
from convopyro import listen_message
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
from classes.poster_client import PosterClient
|
||||
from modules.api_client import remove_pic, upload_pic
|
||||
from modules.app import app, users_with_context
|
||||
from modules.logger import logWrite
|
||||
from modules.utils import configGet, extract_and_save, locale
|
||||
|
||||
|
||||
@app.on_message(~filters.scheduled & filters.command(["import"], prefixes=["", "/"]))
|
||||
async def cmd_import(app: PosterClient, msg: Message):
|
||||
if msg.from_user.id in app.admins:
|
||||
global users_with_context
|
||||
if msg.from_user.id not in users_with_context:
|
||||
users_with_context.append(msg.from_user.id)
|
||||
else:
|
||||
return
|
||||
await msg.reply_text(
|
||||
locale("import_request", "message", locale=msg.from_user.language_code)
|
||||
)
|
||||
answer = await listen_message(app, msg.chat.id, timeout=600)
|
||||
users_with_context.remove(msg.from_user.id)
|
||||
if answer is None:
|
||||
await msg.reply_text(
|
||||
locale("import_ignored", "message", locale=msg.from_user.language_code),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
if answer.text == "/cancel":
|
||||
await answer.reply_text(
|
||||
locale("import_abort", "message", locale=msg.from_user.language_code)
|
||||
)
|
||||
return
|
||||
if answer.document is None:
|
||||
await answer.reply_text(
|
||||
locale(
|
||||
"import_invalid_media",
|
||||
"message",
|
||||
locale=msg.from_user.language_code,
|
||||
),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
if answer.document.mime_type != "application/zip":
|
||||
await answer.reply_text(
|
||||
locale(
|
||||
"import_invalid_mime", "message", locale=msg.from_user.language_code
|
||||
),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
if disk_usage(getcwd())[2] < (answer.document.file_size) * 3:
|
||||
await msg.reply_text(
|
||||
locale(
|
||||
"import_too_big", "message", locale=msg.from_user.language_code
|
||||
).format(
|
||||
answer.document.file_size // (2**30),
|
||||
disk_usage(getcwd())[2] // (2**30),
|
||||
)
|
||||
)
|
||||
return
|
||||
tmp_dir = str(uuid4())
|
||||
logWrite(
|
||||
f"Importing '{answer.document.file_name}' file {answer.document.file_size} bytes big (TMP ID {tmp_dir})"
|
||||
)
|
||||
makedirs(path.join(configGet("tmp", "locations"), tmp_dir), exist_ok=True)
|
||||
tmp_path = path.join(configGet("tmp", "locations"), answer.document.file_id)
|
||||
downloading = await answer.reply_text(
|
||||
locale("import_downloading", "message", locale=msg.from_user.language_code),
|
||||
quote=True,
|
||||
)
|
||||
await app.download_media(answer, file_name=tmp_path)
|
||||
await downloading.edit(
|
||||
locale("import_unpacking", "message", locale=msg.from_user.language_code)
|
||||
)
|
||||
try:
|
||||
with ZipFile(tmp_path, "r") as handle:
|
||||
tasks = [
|
||||
extract_and_save(
|
||||
handle, name, path.join(configGet("tmp", "locations"), tmp_dir)
|
||||
)
|
||||
for name in handle.namelist()
|
||||
]
|
||||
_ = await asyncio.gather(*tasks)
|
||||
except Exception as exp:
|
||||
logWrite(
|
||||
f"Could not import '{answer.document.file_name}' due to {exp}: {format_exc}"
|
||||
)
|
||||
await answer.reply_text(
|
||||
locale(
|
||||
"import_unpack_error", "message", locale=msg.from_user.language_code
|
||||
).format(exp, format_exc())
|
||||
)
|
||||
return
|
||||
logWrite(f"Downloaded '{answer.document.file_name}' - awaiting upload")
|
||||
await downloading.edit(
|
||||
locale("import_uploading", "message", locale=msg.from_user.language_code)
|
||||
)
|
||||
remove(tmp_path)
|
||||
|
||||
for filename in iglob(
|
||||
path.join(configGet("tmp", "locations"), tmp_dir) + "**/**", recursive=True
|
||||
):
|
||||
if not path.isfile(filename):
|
||||
continue
|
||||
# upload filename
|
||||
uploaded = await upload_pic(filename)
|
||||
if uploaded[0] is False:
|
||||
logWrite(
|
||||
f"Could not upload '{filename}' from '{path.join(configGet('tmp', 'locations'), tmp_dir)}'. Duplicates: {str(uploaded[1])}",
|
||||
debug=True,
|
||||
)
|
||||
if len(uploaded[1]) > 0:
|
||||
await msg.reply_text(
|
||||
locale(
|
||||
"import_upload_error_duplicate",
|
||||
"message",
|
||||
locale=msg.from_user.language_code,
|
||||
).format(path.basename(filename)),
|
||||
disable_notification=True,
|
||||
)
|
||||
else:
|
||||
await msg.reply_text(
|
||||
locale(
|
||||
"import_upload_error_other",
|
||||
"message",
|
||||
locale=msg.from_user.language_code,
|
||||
).format(path.basename(filename)),
|
||||
disable_notification=True,
|
||||
)
|
||||
else:
|
||||
logWrite(
|
||||
f"Uploaded '{filename}' from '{path.join(configGet('tmp', 'locations'), tmp_dir)}' and got ID {uploaded[2]}",
|
||||
debug=True,
|
||||
)
|
||||
|
||||
await downloading.delete()
|
||||
logWrite(
|
||||
f"Removing '{path.join(configGet('tmp', 'locations'), tmp_dir)}' after uploading",
|
||||
debug=True,
|
||||
)
|
||||
rmtree(path.join(configGet("tmp", "locations"), tmp_dir), ignore_errors=True)
|
||||
await answer.reply_text(
|
||||
locale("import_finished", "message", locale=msg.from_user.language_code),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
@app.on_message(~filters.scheduled & filters.command(["export"], prefixes=["", "/"]))
|
||||
async def cmd_export(app: PosterClient, msg: Message):
|
||||
if msg.from_user.id in app.admins:
|
||||
pass
|
||||
|
||||
|
||||
@app.on_message(~filters.scheduled & filters.command(["remove"], prefixes=["", "/"]))
|
||||
async def cmd_remove(app: PosterClient, msg: Message):
|
||||
if msg.from_user.id in app.admins:
|
||||
global users_with_context
|
||||
if msg.from_user.id not in users_with_context:
|
||||
users_with_context.append(msg.from_user.id)
|
||||
else:
|
||||
return
|
||||
await msg.reply_text(
|
||||
locale("remove_request", "message", locale=msg.from_user.language_code)
|
||||
)
|
||||
answer = await listen_message(app, msg.chat.id, timeout=600)
|
||||
users_with_context.remove(msg.from_user.id)
|
||||
if answer is None:
|
||||
await msg.reply_text(
|
||||
locale("remove_ignored", "message", locale=msg.from_user.language_code),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
if answer.text == "/cancel":
|
||||
await answer.reply_text(
|
||||
locale("remove_abort", "message", locale=msg.from_user.language_code)
|
||||
)
|
||||
return
|
||||
response = await remove_pic(answer.text)
|
||||
if response:
|
||||
logWrite(
|
||||
f"Removed '{answer.text}' by request of user {answer.from_user.id}"
|
||||
)
|
||||
await answer.reply_text(
|
||||
locale(
|
||||
"remove_success", "message", locale=msg.from_user.language_code
|
||||
).format(answer.text)
|
||||
)
|
||||
else:
|
||||
logWrite(
|
||||
f"Could not remove '{answer.text}' by request of user {answer.from_user.id}"
|
||||
)
|
||||
await answer.reply_text(
|
||||
locale(
|
||||
"remove_failure", "message", locale=msg.from_user.language_code
|
||||
).format(answer.text)
|
||||
)
|
||||
|
||||
|
||||
@app.on_message(~filters.scheduled & filters.command(["purge"], prefixes=["", "/"]))
|
||||
async def cmd_purge(app: PosterClient, msg: Message):
|
||||
if msg.from_user.id in app.admins:
|
||||
pass
|
@@ -1,162 +1,287 @@
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime
|
||||
from os import makedirs, path, sep
|
||||
from traceback import format_exc
|
||||
from uuid import uuid4
|
||||
|
||||
from pyrogram import filters
|
||||
from pyrogram.client import Client
|
||||
from pyrogram.enums.chat_action import ChatAction
|
||||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
|
||||
|
||||
from modules.app import app
|
||||
from classes.enums.submission_types import SubmissionType
|
||||
from classes.exceptions import SubmissionDuplicatesError
|
||||
from classes.poster_client import PosterClient
|
||||
from classes.user import PosterUser
|
||||
from modules.app import app, users_with_context
|
||||
from modules.database import col_banned, col_submitted
|
||||
from modules.logger import logWrite
|
||||
from modules.submissions import subLimit, subLimited
|
||||
from modules.utils import configGet, locale
|
||||
from classes.enums.submission_types import SubmissionType
|
||||
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation | filters.document)
|
||||
async def get_submission(_: Client, msg: Message):
|
||||
@app.on_message(
|
||||
~filters.scheduled & filters.private & filters.photo
|
||||
| filters.video
|
||||
| filters.animation
|
||||
| filters.document
|
||||
)
|
||||
async def get_submission(app: PosterClient, msg: Message):
|
||||
global users_with_context
|
||||
if msg.from_user.id in users_with_context:
|
||||
return
|
||||
try:
|
||||
if col_banned.find_one({"user": msg.from_user.id}) is not None:
|
||||
return
|
||||
|
||||
locale("sub_wip", "message", locale=msg.from_user.language_code)
|
||||
await app.send_chat_action(msg.chat.id, ChatAction.TYPING)
|
||||
|
||||
# try:
|
||||
user_locale = msg.from_user.language_code
|
||||
save_tmp = True
|
||||
contents = None
|
||||
|
||||
# if col_banned.find_one( {"user": msg.from_user.id} ) is not None:
|
||||
# return
|
||||
if PosterUser(msg.from_user.id).is_limited():
|
||||
await msg.reply_text(
|
||||
locale("sub_cooldown", "message", locale=user_locale).format(
|
||||
str(configGet("timeout", "submission"))
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
# user_locale = msg.from_user.language_code
|
||||
# save_tmp = True
|
||||
# contents = None
|
||||
if msg.document is not None:
|
||||
logWrite(
|
||||
f"User {msg.from_user.id} is trying to submit a file of type '{msg.document.mime_type}' with name '{msg.document.file_name}' and size of {msg.document.file_size / 1024 / 1024} MB",
|
||||
debug=True,
|
||||
)
|
||||
if msg.document.mime_type not in configGet("mime_types", "submission"):
|
||||
await msg.reply_text(
|
||||
locale("mime_not_allowed", "message", locale=user_locale).format(
|
||||
", ".join(configGet("mime_types", "submission"))
|
||||
),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
if msg.document.file_size > configGet("file_size", "submission"):
|
||||
await msg.reply_text(
|
||||
locale("document_too_large", "message", locale=user_locale).format(
|
||||
str(configGet("file_size", "submission") / 1024 / 1024)
|
||||
),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
if msg.document.file_size > configGet("tmp_size", "submission"):
|
||||
save_tmp = False
|
||||
contents = (
|
||||
msg.document.file_id,
|
||||
SubmissionType.DOCUMENT,
|
||||
) # , msg.document.file_name
|
||||
|
||||
# if subLimited(msg.from_user):
|
||||
# await msg.reply_text(locale("sub_cooldown", "message", locale=user_locale).format(str(configGet("timeout", "submission"))))
|
||||
# return
|
||||
if msg.video is not None:
|
||||
logWrite(
|
||||
f"User {msg.from_user.id} is trying to submit a video with name '{msg.video.file_name}' and size of {msg.video.file_size / 1024 / 1024} MB",
|
||||
debug=True,
|
||||
)
|
||||
if msg.video.file_size > configGet("file_size", "submission"):
|
||||
await msg.reply_text(
|
||||
locale("document_too_large", "message", locale=user_locale).format(
|
||||
str(configGet("file_size", "submission") / 1024 / 1024)
|
||||
),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
if msg.video.file_size > configGet("tmp_size", "submission"):
|
||||
save_tmp = False
|
||||
contents = msg.video.file_id, SubmissionType.VIDEO # , msg.video.file_name
|
||||
|
||||
# if msg.document is not None:
|
||||
# if msg.document.mime_type not in configGet("mime_types", "submission"):
|
||||
# await msg.reply_text(locale("mime_not_allowed", "message", locale=user_locale), quote=True)
|
||||
# return
|
||||
# if msg.document.file_size > configGet("file_size", "submission"):
|
||||
# await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
||||
# return
|
||||
# if msg.document.file_size > configGet("tmp_size", "submission"):
|
||||
# save_tmp = False
|
||||
# contents = msg.document.file_id, SubmissionType.DOCUMENT #, msg.document.file_name
|
||||
if msg.animation is not None:
|
||||
logWrite(
|
||||
f"User {msg.from_user.id} is trying to submit an animation with name '{msg.animation.file_name}' and size of {msg.animation.file_size / 1024 / 1024} MB",
|
||||
debug=True,
|
||||
)
|
||||
if msg.animation.file_size > configGet("file_size", "submission"):
|
||||
await msg.reply_text(
|
||||
locale("document_too_large", "message", locale=user_locale).format(
|
||||
str(configGet("file_size", "submission") / 1024 / 1024)
|
||||
),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
if msg.animation.file_size > configGet("tmp_size", "submission"):
|
||||
save_tmp = False
|
||||
contents = (
|
||||
msg.animation.file_id,
|
||||
SubmissionType.ANIMATION,
|
||||
) # , msg.animation.file_name
|
||||
|
||||
# if msg.video is not None:
|
||||
# if msg.video.file_size > configGet("file_size", "submission"):
|
||||
# await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
||||
# return
|
||||
# if msg.video.file_size > configGet("tmp_size", "submission"):
|
||||
# save_tmp = False
|
||||
# contents = msg.video.file_id, SubmissionType.VIDEO #, msg.video.file_name
|
||||
if msg.photo is not None:
|
||||
logWrite(
|
||||
f"User {msg.from_user.id} is trying to submit a photo with ID '{msg.photo.file_id}' and size of {msg.photo.file_size / 1024 / 1024} MB",
|
||||
debug=True,
|
||||
)
|
||||
contents = msg.photo.file_id, SubmissionType.PHOTO # , "please_generate"
|
||||
|
||||
# if msg.animation is not None:
|
||||
# if msg.animation.file_size > configGet("file_size", "submission"):
|
||||
# await msg.reply_text(locale("document_too_large", "message", locale=user_locale).format(str(configGet("file_size", "submission")/1024/1024)), quote=True)
|
||||
# return
|
||||
# if msg.animation.file_size > configGet("tmp_size", "submission"):
|
||||
# save_tmp = False
|
||||
# contents = msg.animation.file_id, SubmissionType.ANIMATION #, msg.animation.file_name
|
||||
if save_tmp is not None:
|
||||
if contents is None:
|
||||
return
|
||||
|
||||
# if msg.photo is not None:
|
||||
# contents = msg.photo.file_id, SubmissionType.PHOTO #, "please_generate"
|
||||
tmp_id = str(uuid4())
|
||||
# filename = tmp_id if contents[1] == "please_generate" else contents[1]
|
||||
makedirs(
|
||||
path.join(configGet("data", "locations"), "submissions", tmp_id),
|
||||
exist_ok=True,
|
||||
)
|
||||
downloaded = await app.download_media(
|
||||
msg,
|
||||
path.join(configGet("data", "locations"), "submissions", tmp_id) + sep,
|
||||
)
|
||||
inserted = col_submitted.insert_one(
|
||||
{
|
||||
"user": msg.from_user.id,
|
||||
"date": datetime.now(),
|
||||
"done": False,
|
||||
"type": contents[1].value,
|
||||
"temp": {"uuid": tmp_id, "file": path.basename(str(downloaded))},
|
||||
"telegram": {"msg_id": msg.id, "file_id": contents[0]},
|
||||
"caption": str(msg.caption) if msg.caption is not None else None,
|
||||
}
|
||||
)
|
||||
|
||||
# if save_tmp is not None:
|
||||
else:
|
||||
if contents is None:
|
||||
return
|
||||
|
||||
# if contents is None:
|
||||
# return
|
||||
inserted = col_submitted.insert_one(
|
||||
{
|
||||
"user": msg.from_user.id,
|
||||
"date": datetime.now(),
|
||||
"done": False,
|
||||
"type": contents[1].value,
|
||||
"temp": {"uuid": None, "file": None},
|
||||
"telegram": {"msg_id": msg.id, "file_id": contents[0]},
|
||||
"caption": str(msg.caption) if msg.caption is not None else None,
|
||||
}
|
||||
)
|
||||
|
||||
# tmp_id = str(uuid4())
|
||||
# # filename = tmp_id if contents[1] == "please_generate" else contents[1]
|
||||
# makedirs(path.join(configGet("data", "locations"), "submissions", tmp_id), exist_ok=True)
|
||||
# downloaded = await app.download_media(msg, path.join(configGet("data", "locations"), "submissions", tmp_id)+sep)
|
||||
# inserted = col_submitted.insert_one(
|
||||
# {
|
||||
# "user": msg.from_user.id,
|
||||
# "date": datetime.now(tz=timezone.utc),
|
||||
# "done": False,
|
||||
# "type": contents[1].value,
|
||||
# "temp": {
|
||||
# "uuid": tmp_id,
|
||||
# "file": path.basename(str(downloaded))
|
||||
# },
|
||||
# "telegram": {
|
||||
# "msg_id": msg.id,
|
||||
# "file_id": contents[0]
|
||||
# },
|
||||
# "caption": str(msg.caption) if msg.caption is not None else None
|
||||
# }
|
||||
# )
|
||||
|
||||
# else:
|
||||
buttons = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=locale("sub_yes", "button", locale=configGet("locale")),
|
||||
callback_data=f"sub_yes_{str(inserted.inserted_id)}",
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
# if contents is None:
|
||||
# return
|
||||
if msg.caption is not None:
|
||||
caption = str(msg.caption)
|
||||
buttons[0].append(
|
||||
InlineKeyboardButton(
|
||||
text=locale(
|
||||
"sub_yes_caption", "button", locale=configGet("locale")
|
||||
),
|
||||
callback_data=f"sub_yes_{str(inserted.inserted_id)}_caption",
|
||||
)
|
||||
)
|
||||
buttons[0].append(
|
||||
InlineKeyboardButton(
|
||||
text=locale("sub_no", "button", locale=configGet("locale")),
|
||||
callback_data=f"sub_no_{str(inserted.inserted_id)}",
|
||||
)
|
||||
)
|
||||
else:
|
||||
caption = ""
|
||||
buttons[0].append(
|
||||
InlineKeyboardButton(
|
||||
text=locale("sub_no", "button", locale=configGet("locale")),
|
||||
callback_data=f"sub_no_{str(inserted.inserted_id)}",
|
||||
)
|
||||
)
|
||||
|
||||
# inserted = col_submitted.insert_one(
|
||||
# {
|
||||
# "user": msg.from_user.id,
|
||||
# "date": datetime.now(tz=timezone.utc),
|
||||
# "done": False,
|
||||
# "type": contents[1].value,
|
||||
# "temp": {
|
||||
# "uuid": None,
|
||||
# "file": None
|
||||
# },
|
||||
# "telegram": {
|
||||
# "msg_id": msg.id,
|
||||
# "file_id": contents[0]
|
||||
# },
|
||||
# "caption": str(msg.caption) if msg.caption is not None else None
|
||||
# }
|
||||
# )
|
||||
|
||||
# buttons = [
|
||||
# [
|
||||
# InlineKeyboardButton(text=locale("sub_yes", "button", locale=configGet("locale")), callback_data=f"sub_yes_{str(inserted.inserted_id)}")
|
||||
# ]
|
||||
# ]
|
||||
caption += locale("sub_by", "message", locale=locale(configGet("locale")))
|
||||
|
||||
# if msg.caption is not None:
|
||||
# caption = str(msg.caption)
|
||||
# buttons[0].append(
|
||||
# InlineKeyboardButton(text=locale("sub_yes_caption", "button", locale=configGet("locale")), callback_data=f"sub_yes_{str(inserted.inserted_id)}_caption")
|
||||
# )
|
||||
# buttons[0].append(
|
||||
# InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{str(inserted.inserted_id)}")
|
||||
# )
|
||||
# else:
|
||||
# caption = ""
|
||||
# buttons[0].append(
|
||||
# InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{str(inserted.inserted_id)}")
|
||||
# )
|
||||
if msg.from_user.first_name is not None:
|
||||
caption += f" {msg.from_user.first_name}"
|
||||
if msg.from_user.last_name is not None:
|
||||
caption += f" {msg.from_user.last_name}"
|
||||
if msg.from_user.username is not None:
|
||||
caption += f" (@{msg.from_user.username})"
|
||||
if msg.from_user.phone_number is not None:
|
||||
caption += f" ({msg.from_user.phone_number})"
|
||||
|
||||
# caption += locale("sub_by", "message", locale=locale(configGet("locale")))
|
||||
if (
|
||||
msg.from_user.id in app.admins
|
||||
and configGet("admins", "submission", "require_confirmation") is False
|
||||
):
|
||||
try:
|
||||
submitted = await app.submit_photo(str(inserted.inserted_id))
|
||||
await msg.reply_text(
|
||||
locale("sub_yes_auto", "message", locale=user_locale),
|
||||
disable_notification=True,
|
||||
quote=True,
|
||||
)
|
||||
if configGet("send_uploaded_id", "submission"):
|
||||
caption += f"\n\nID: `{submitted[1]}`"
|
||||
await msg.copy(app.owner, caption=caption, disable_notification=True)
|
||||
return
|
||||
except SubmissionDuplicatesError as exp:
|
||||
await msg.reply_text(
|
||||
locale(
|
||||
"sub_media_duplicates_list", "message", locale=user_locale
|
||||
).format("\n • ".join(exp.duplicates)),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
except Exception as exp:
|
||||
await msg.reply_text(format_exc(), quote=True)
|
||||
return
|
||||
elif (
|
||||
msg.from_user.id not in app.admins
|
||||
and configGet("users", "submission", "require_confirmation") is False
|
||||
):
|
||||
try:
|
||||
submitted = await app.submit_photo(str(inserted.inserted_id))
|
||||
await msg.reply_text(
|
||||
locale("sub_yes_auto", "message", locale=user_locale),
|
||||
disable_notification=True,
|
||||
quote=True,
|
||||
)
|
||||
if configGet("send_uploaded_id", "submission"):
|
||||
caption += f"\n\nID: `{submitted[1]}`"
|
||||
await msg.copy(app.owner, caption=caption)
|
||||
return
|
||||
except SubmissionDuplicatesError as exp:
|
||||
await msg.reply_text(
|
||||
locale("sub_dup", "message", locale=user_locale), quote=True
|
||||
)
|
||||
return
|
||||
except Exception as exp:
|
||||
await app.send_message(
|
||||
app.owner,
|
||||
locale("sub_error_admin", "message").format(
|
||||
msg.from_user.id, format_exc()
|
||||
),
|
||||
)
|
||||
await msg.reply_text("sub_error", quote=True)
|
||||
return
|
||||
|
||||
# if msg.from_user.first_name is not None:
|
||||
# caption += f" {msg.from_user.first_name}"
|
||||
# if msg.from_user.last_name is not None:
|
||||
# caption += f" {msg.from_user.last_name}"
|
||||
# if msg.from_user.username is not None:
|
||||
# caption += f" (@{msg.from_user.username})"
|
||||
# if msg.from_user.phone_number is not None:
|
||||
# caption += f" ({msg.from_user.phone_number})"
|
||||
if msg.from_user.id not in app.admins:
|
||||
buttons += [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=locale("sub_block", "button", locale=configGet("locale")),
|
||||
callback_data=f"sub_block_{msg.from_user.id}",
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
# if msg.from_user.id != configGet("admin"):
|
||||
# buttons += [
|
||||
# [
|
||||
# InlineKeyboardButton(text=locale("sub_block", "button", locale=configGet("locale")), callback_data=f"sub_block_{msg.from_user.id}")
|
||||
# ]
|
||||
# # [
|
||||
# # InlineKeyboardButton(text=locale("sub_unblock", "button", locale=configGet("locale")), callback_data=f"sub_unblock_{msg.from_user.id}")
|
||||
# # ]
|
||||
# ]
|
||||
PosterUser(msg.from_user.id).limit()
|
||||
|
||||
# await msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True)
|
||||
# subLimit(msg.from_user)
|
||||
if msg.from_user.id != app.owner:
|
||||
await msg.reply_text(
|
||||
locale("sub_sent", "message", locale=user_locale),
|
||||
disable_notification=True,
|
||||
quote=True,
|
||||
)
|
||||
|
||||
# await msg.copy(configGet("admin"), caption=caption, reply_markup=InlineKeyboardMarkup(buttons))
|
||||
await msg.copy(
|
||||
app.owner, caption=caption, reply_markup=InlineKeyboardMarkup(buttons)
|
||||
)
|
||||
|
||||
# except AttributeError:
|
||||
# logWrite(f"from_user in function get_submission does not seem to contain id")
|
||||
except AttributeError:
|
||||
logWrite(f"from_user in function get_submission does not seem to contain id")
|
||||
|
Reference in New Issue
Block a user