A lot of stuff done
This commit is contained in:
parent
8b34e7024d
commit
0af55128ad
116
main.py
116
main.py
@ -5,6 +5,7 @@ from modules.utils import *
|
|||||||
|
|
||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
|
from pyrogram.enums.parse_mode import ParseMode
|
||||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, BotCommand, BotCommandScopeChat, ReplyKeyboardMarkup, ForceReply, ReplyKeyboardRemove
|
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, BotCommand, BotCommandScopeChat, ReplyKeyboardMarkup, ForceReply, ReplyKeyboardRemove
|
||||||
from pyrogram import idle # type: ignore
|
from pyrogram import idle # type: ignore
|
||||||
from pyrogram.errors.exceptions import bad_request_400
|
from pyrogram.errors.exceptions import bad_request_400
|
||||||
@ -94,7 +95,7 @@ async def confirm_yes(app, msg):
|
|||||||
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(msg.from_user.id))[question]}")
|
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(msg.from_user.id))[question]}")
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
await app.send_message(chat_id=configGet("admin_group"), text=(locale("application_got", "message")).format(str(msg.from_user.id), msg.from_user.first_name, msg.from_user.last_name, msg.from_user.username, "\n".join(application_content)), reply_markup=InlineKeyboardMarkup( # type: ignore
|
await app.send_message(chat_id=configGet("admin_group"), text=(locale("application_got", "message")).format(str(msg.from_user.id), msg.from_user.first_name, msg.from_user.last_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup( # type: ignore
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(text=str(locale("sub_yes", "button")), callback_data=f"sub_yes_{msg.from_user.id}")
|
InlineKeyboardButton(text=str(locale("sub_yes", "button")), callback_data=f"sub_yes_{msg.from_user.id}")
|
||||||
@ -113,7 +114,7 @@ async def confirm_yes(app, msg):
|
|||||||
)
|
)
|
||||||
|
|
||||||
configSet("sent", True, file=str(msg.from_user.id))
|
configSet("sent", True, file=str(msg.from_user.id))
|
||||||
configSet("application_date", int(time()), file=str(msg.from_user.id))
|
configSet("confirmed", True, file=str(msg.from_user.id))
|
||||||
|
|
||||||
@app.on_message(~ filters.scheduled & filters.private & (filters.regex(locale("confirm", "keyboard")[1][0])))
|
@app.on_message(~ filters.scheduled & filters.private & (filters.regex(locale("confirm", "keyboard")[1][0])))
|
||||||
async def confirm_no(app, msg):
|
async def confirm_no(app, msg):
|
||||||
@ -135,9 +136,8 @@ async def confirm_no(app, msg):
|
|||||||
async def callback_query_accept(app, clb):
|
async def callback_query_accept(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
user_locale = clb.from_user.language_code
|
|
||||||
|
|
||||||
await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.id, fullclb[2])) # type: ignore
|
await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore
|
||||||
|
|
||||||
link = await app.create_chat_invite_link(configGet("destination_group"), name=f"Invite for {fullclb[2]}", member_limit=1, expire_date=datetime.now()+timedelta(days=1))
|
link = await app.create_chat_invite_link(configGet("destination_group"), name=f"Invite for {fullclb[2]}", member_limit=1, expire_date=datetime.now()+timedelta(days=1))
|
||||||
|
|
||||||
@ -147,54 +147,113 @@ async def callback_query_accept(app, clb):
|
|||||||
]]
|
]]
|
||||||
))
|
))
|
||||||
|
|
||||||
|
configSet("approved", True, file=fullclb[2])
|
||||||
|
|
||||||
|
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")
|
||||||
|
application[fullclb[2]]["approved"] = True
|
||||||
|
application[fullclb[2]]["approved_by"] = clb.from_user.id
|
||||||
|
application[fullclb[2]]["approval_date"] = int(time())
|
||||||
|
jsonSave(application, f"{configGet('data', 'locations')}{sep}applications.json")
|
||||||
|
|
||||||
edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||||
|
|
||||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||||
await clb.answer(text=locale("sub_accepted", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
await clb.answer(text=locale("sub_accepted", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("sub_no_[\s\S]*")) # type: ignore
|
|
||||||
async def callback_query_refuse(app, clb):
|
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
|
||||||
user_locale = clb.from_user.language_code
|
|
||||||
|
|
||||||
await app.send_message(configGet("admin_group"), locale("refused_by", "message").format(clb.from_user.id, fullclb[2])) # type: ignore
|
|
||||||
await app.send_message(int(fullclb[2]), locale("refused", "message"))
|
|
||||||
|
|
||||||
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]]
|
|
||||||
|
|
||||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
|
||||||
await clb.answer(text=locale("sub_refused", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("sub_no_aggressive_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("sub_no_aggressive_[\s\S]*")) # type: ignore
|
||||||
async def callback_query_refuse_aggressive(app, clb):
|
async def callback_query_refuse_aggressive(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
user_locale = clb.from_user.language_code
|
|
||||||
|
|
||||||
await app.send_message(configGet("admin_group"), locale("refused_by_agr", "message").format(clb.from_user.id, fullclb[2])) # type: ignore
|
await app.send_message(configGet("admin_group"), locale("refused_by_agr", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True) # type: ignore
|
||||||
await app.send_message(int(fullclb[2]), locale("refused", "message"))
|
await app.send_message(int(fullclb[3]), locale("refused", "message"))
|
||||||
|
|
||||||
|
configSet("refused", True, file=fullclb[3])
|
||||||
|
|
||||||
|
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")
|
||||||
|
application[fullclb[3]]["refused"] = True
|
||||||
|
application[fullclb[3]]["refused_by"] = clb.from_user.id
|
||||||
|
application[fullclb[3]]["refusal_date"] = int(time())
|
||||||
|
jsonSave(application, f"{configGet('data', 'locations')}{sep}applications.json")
|
||||||
|
|
||||||
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]]
|
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]]
|
||||||
|
|
||||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||||
await clb.answer(text=locale("sub_no_aggressive", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
await clb.answer(text=locale("sub_no_aggressive", "callback").format(fullclb[3]), show_alert=True) # type: ignore
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("sub_no_russian_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("sub_no_russian_[\s\S]*")) # type: ignore
|
||||||
async def callback_query_refuse_russian(app, clb):
|
async def callback_query_refuse_russian(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
user_locale = clb.from_user.language_code
|
|
||||||
|
|
||||||
await app.send_message(configGet("admin_group"), locale("refused_by_rus", "message").format(clb.from_user.id, fullclb[2])) # type: ignore
|
await app.send_message(configGet("admin_group"), locale("refused_by_rus", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True) # type: ignore
|
||||||
await app.send_message(int(fullclb[2]), locale("refused", "message"))
|
await app.send_message(int(fullclb[3]), locale("refused", "message"))
|
||||||
|
await app.send_message(int(fullclb[3]), locale("refused_russian", "message"))
|
||||||
|
|
||||||
|
configSet("refused", True, file=fullclb[3])
|
||||||
|
|
||||||
|
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")
|
||||||
|
application[fullclb[3]]["refused"] = True
|
||||||
|
application[fullclb[3]]["refused_by"] = clb.from_user.id
|
||||||
|
application[fullclb[3]]["refusal_date"] = int(time())
|
||||||
|
jsonSave(application, f"{configGet('data', 'locations')}{sep}applications.json")
|
||||||
|
|
||||||
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]]
|
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]]
|
||||||
|
|
||||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||||
await clb.answer(text=locale("sub_no_russian", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
await clb.answer(text=locale("sub_no_russian", "callback").format(fullclb[3]), show_alert=True) # type: ignore
|
||||||
|
|
||||||
|
@app.on_callback_query(filters.regex("sub_no_[\s\S]*")) # type: ignore
|
||||||
|
async def callback_query_refuse(app, clb):
|
||||||
|
|
||||||
|
fullclb = clb.data.split("_")
|
||||||
|
|
||||||
|
await app.send_message(configGet("admin_group"), locale("refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore
|
||||||
|
await app.send_message(int(fullclb[2]), locale("refused", "message"))
|
||||||
|
|
||||||
|
configSet("refused", True, file=fullclb[2])
|
||||||
|
|
||||||
|
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")
|
||||||
|
application[fullclb[2]]["refused"] = True
|
||||||
|
application[fullclb[2]]["refused_by"] = clb.from_user.id
|
||||||
|
application[fullclb[2]]["refusal_date"] = int(time())
|
||||||
|
jsonSave(application, f"{configGet('data', 'locations')}{sep}applications.json")
|
||||||
|
|
||||||
|
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]]
|
||||||
|
|
||||||
|
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||||
|
await clb.answer(text=locale("sub_refused", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
@app.on_message(~ filters.scheduled & filters.contact)
|
||||||
|
async def get_contact(app, msg):
|
||||||
|
if (msg.from_user.id in configGet("admins")) or (msg.from_user.id == configGet("owner")):
|
||||||
|
if msg.contact.user_id != None:
|
||||||
|
try:
|
||||||
|
user_data = jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{msg.contact.user_id}.json")
|
||||||
|
application_content = []
|
||||||
|
i = 1
|
||||||
|
for question in configGet("application", file=str(msg.contact.user_id)):
|
||||||
|
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(msg.contact.user_id))[question]}")
|
||||||
|
i += 1
|
||||||
|
if user_data["sent"]:
|
||||||
|
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")[str(msg.contact.user_id)]
|
||||||
|
if user_data["approved"]:
|
||||||
|
application_status = locale("application_status_accepted", "message").format(await app.get_users(application["approved_by"]).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore
|
||||||
|
elif application["refused"]:
|
||||||
|
application_status = locale("application_status_refused", "message").format(await app.get_users(application["refused_by"]).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore
|
||||||
|
else:
|
||||||
|
application_status = locale("application_status_on_hold", "message")
|
||||||
|
else:
|
||||||
|
application_status = locale("application_status_not_send", "message")
|
||||||
|
await msg.reply_text(locale("contact", "message").format(str(msg.contact.user_id), "\n".join(application_content), application_status)) # type: ignore
|
||||||
|
except FileNotFoundError:
|
||||||
|
await msg.reply_text(locale("contact_invalid", "message"))
|
||||||
|
else:
|
||||||
|
await msg.reply_text(locale("contact_not_member", "message"))
|
||||||
|
|
||||||
|
|
||||||
# Any other input ==============================================================================================================
|
# Any other input ==============================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.private)
|
@app.on_message(~ filters.scheduled & filters.private)
|
||||||
async def any_stage(app, msg):
|
async def any_stage(app, msg):
|
||||||
@ -211,7 +270,7 @@ async def any_stage(app, msg):
|
|||||||
if (int(msg.text) in [-1, 0, 128, 256, 512, 1024, 2048]) or (int(msg.text) >= 100):
|
if (int(msg.text) in [-1, 0, 128, 256, 512, 1024, 2048]) or (int(msg.text) >= 100):
|
||||||
await msg.reply_text(locale("question2_joke", "message"), reply_markup=ForceReply(placeholder=str(locale("question2", "force_reply"))))
|
await msg.reply_text(locale("question2_joke", "message"), reply_markup=ForceReply(placeholder=str(locale("question2", "force_reply"))))
|
||||||
elif int(msg.text) < configGet("age_allowed"):
|
elif int(msg.text) < configGet("age_allowed"):
|
||||||
await msg.reply_text(locale("question2_underage", "message"), reply_markup=ForceReply(placeholder=str(locale("question2", "force_reply"))))
|
await msg.reply_text(locale("question2_underage", "message").format(str(configGet("age_allowed"))), reply_markup=ForceReply(placeholder=str(locale("question2", "force_reply")))) # type: ignore
|
||||||
else:
|
else:
|
||||||
await msg.reply_text(locale(f"question{user_stage+1}", "message"), reply_markup=ForceReply(placeholder=str(locale(f"question{user_stage+1}", "force_reply"))))
|
await msg.reply_text(locale(f"question{user_stage+1}", "message"), reply_markup=ForceReply(placeholder=str(locale(f"question{user_stage+1}", "force_reply"))))
|
||||||
configSet("stage", user_stage+1, file=str(msg.from_user.id))
|
configSet("stage", user_stage+1, file=str(msg.from_user.id))
|
||||||
@ -237,7 +296,8 @@ async def any_stage(app, msg):
|
|||||||
else:
|
else:
|
||||||
await msg.reply_text("You are already done, wait!")
|
await msg.reply_text("You are already done, wait!")
|
||||||
else:
|
else:
|
||||||
await msg.reply_text("You are already done, wait!")
|
if not configGet("approved", file=str(msg.from_user.id)) and not configGet("refused", file=str(msg.from_user.id)):
|
||||||
|
await msg.reply_text("You are already done, wait!")
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user