Removed # type: ignore and fixed missing imports
This commit is contained in:
parent
712b5d22ab
commit
65f6b4e30e
2
app.py
2
app.py
@ -6,7 +6,7 @@ app = Client("holochecker", bot_token=configGet("bot_token", "bot"), api_id=conf
|
|||||||
async def isAnAdmin(admin_id):
|
async def isAnAdmin(admin_id):
|
||||||
if admin_id == configGet("owner") or admin_id in configGet("admins"):
|
if admin_id == configGet("owner") or admin_id in configGet("admins"):
|
||||||
return True
|
return True
|
||||||
async for member in app.get_chat_members(configGet("admin_group")): # type: ignore
|
async for member in app.get_chat_members(configGet("admin_group")):
|
||||||
if member.user.id == admin_id:
|
if member.user.id == admin_id:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
10
main.py
10
main.py
@ -8,7 +8,7 @@ from schedule import run_pending, every
|
|||||||
from app import app
|
from app import app
|
||||||
|
|
||||||
from modules.commands_register import commands_register
|
from modules.commands_register import commands_register
|
||||||
from pyrogram import idle # type: ignore
|
from pyrogram import idle
|
||||||
|
|
||||||
|
|
||||||
pid = getpid()
|
pid = getpid()
|
||||||
@ -51,7 +51,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# Yes, it should be in some kind of async main() function but I don't give a shit.
|
# Yes, it should be in some kind of async main() function but I don't give a shit.
|
||||||
# I did compare performance, almost no difference and it's much more useful this way. Change my mind.
|
# I did compare performance, almost no difference and it's much more useful this way. Change my mind.
|
||||||
app.start() # type: ignore
|
app.start()
|
||||||
|
|
||||||
if configGet("birthdays_notify"):
|
if configGet("birthdays_notify"):
|
||||||
|
|
||||||
@ -73,14 +73,14 @@ if __name__ == "__main__":
|
|||||||
t = Thread(target=background_task)
|
t = Thread(target=background_task)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
app.send_message(configGet("owner"), f"Starting up with pid `{pid}`") # type: ignore
|
app.send_message(configGet("owner"), f"Starting up with pid `{pid}`")
|
||||||
|
|
||||||
commands_register(app)
|
commands_register(app)
|
||||||
|
|
||||||
idle()
|
idle()
|
||||||
|
|
||||||
app.send_message(configGet("owner"), f"Shutting with pid `{pid}`") # type: ignore
|
app.send_message(configGet("owner"), f"Shutting with pid `{pid}`")
|
||||||
|
|
||||||
app.stop() # type: ignore
|
app.stop()
|
||||||
|
|
||||||
killProc(pid)
|
killProc(pid)
|
@ -3,7 +3,7 @@ from pyrogram import filters
|
|||||||
from modules.utils import locale
|
from modules.utils import locale
|
||||||
|
|
||||||
# Callback empty ===============================================================================================================
|
# Callback empty ===============================================================================================================
|
||||||
@app.on_callback_query(filters.regex("nothing")) # type: ignore
|
@app.on_callback_query(filters.regex("nothing"))
|
||||||
async def callback_query_nothing(app, clb):
|
async def callback_query_nothing(app, clb):
|
||||||
await clb.answer(text=locale("nothing", "callback"))
|
await clb.answer(text=locale("nothing", "callback"))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
@ -8,12 +8,12 @@ from modules.handlers.confirmation import confirm_yes
|
|||||||
from modules.handlers.welcome import welcome_pass
|
from modules.handlers.welcome import welcome_pass
|
||||||
|
|
||||||
# Callbacks reapply ============================================================================================================
|
# Callbacks reapply ============================================================================================================
|
||||||
@app.on_callback_query(filters.regex("reapply_yes_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("reapply_yes_[\s\S]*"))
|
||||||
async def callback_reapply_query_accept(app, clb):
|
async def callback_reapply_query_accept(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
|
|
||||||
await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore
|
await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
|
||||||
logWrite(f"User {fullclb[2]} got their reapplication approved by {clb.from_user.id}")
|
logWrite(f"User {fullclb[2]} got their reapplication approved by {clb.from_user.id}")
|
||||||
|
|
||||||
await app.send_message(int(fullclb[2]), locale("approved_joined", "message"))
|
await app.send_message(int(fullclb[2]), locale("approved_joined", "message"))
|
||||||
@ -30,7 +30,7 @@ async def callback_reapply_query_accept(app, clb):
|
|||||||
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)
|
||||||
|
|
||||||
need_link = True
|
need_link = True
|
||||||
|
|
||||||
@ -58,12 +58,12 @@ async def callback_reapply_query_accept(app, clb):
|
|||||||
else:
|
else:
|
||||||
await app.send_message(int(fullclb[2]), locale("approved_joined", "message"))
|
await app.send_message(int(fullclb[2]), locale("approved_joined", "message"))
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("reapply_no_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("reapply_no_[\s\S]*"))
|
||||||
async def callback_query_reapply_refuse(app, clb):
|
async def callback_query_reapply_refuse(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
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(configGet("admin_group"), locale("refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
|
||||||
await app.send_message(int(fullclb[2]), locale("refused", "message"))
|
await app.send_message(int(fullclb[2]), locale("refused", "message"))
|
||||||
logWrite(f"User {fullclb[2]} got their reapplication refused by {clb.from_user.id}")
|
logWrite(f"User {fullclb[2]} got their reapplication refused by {clb.from_user.id}")
|
||||||
|
|
||||||
@ -79,20 +79,20 @@ async def callback_query_reapply_refuse(app, clb):
|
|||||||
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_refused", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
await clb.answer(text=locale("sub_refused", "callback").format(fullclb[2]), show_alert=True)
|
||||||
|
|
||||||
# Use old application when user reapplies after leaving the chat
|
# Use old application when user reapplies after leaving the chat
|
||||||
@app.on_callback_query(filters.regex("reapply_old_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("reapply_old_[\s\S]*"))
|
||||||
async def callback_query_reapply_old(app, clb):
|
async def callback_query_reapply_old(app, clb):
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
||||||
configSet(["approved"], False, file=str(clb.from_user.id))
|
configSet(["approved"], False, file=str(clb.from_user.id))
|
||||||
configSet(["refused"], False, file=str(clb.from_user.id))
|
configSet(["refused"], False, file=str(clb.from_user.id))
|
||||||
await confirm_yes(app, message)
|
await confirm_yes(app, message)
|
||||||
await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button"), "nothing")]])) # type: ignore
|
await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button"), "nothing")]]))
|
||||||
|
|
||||||
# Start a new application when user reapplies after leaving the chat
|
# Start a new application when user reapplies after leaving the chat
|
||||||
@app.on_callback_query(filters.regex("reapply_new_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("reapply_new_[\s\S]*"))
|
||||||
async def callback_query_reapply_new(app, clb):
|
async def callback_query_reapply_new(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
@ -106,10 +106,10 @@ async def callback_query_reapply_new(app, clb):
|
|||||||
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
||||||
await welcome_pass(app, message, once_again=True)
|
await welcome_pass(app, message, once_again=True)
|
||||||
logWrite(f"User {clb.from_user.id} restarted the application after leaving the chat earlier")
|
logWrite(f"User {clb.from_user.id} restarted the application after leaving the chat earlier")
|
||||||
await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button"), "nothing")]])) # type: ignore
|
await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button"), "nothing")]]))
|
||||||
|
|
||||||
# Abort application fill in progress and restart it
|
# Abort application fill in progress and restart it
|
||||||
@app.on_callback_query(filters.regex("reapply_stop_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("reapply_stop_[\s\S]*"))
|
||||||
async def callback_query_reapply_stop(app, clb):
|
async def callback_query_reapply_stop(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
|
@ -6,7 +6,7 @@ from modules.utils import locale, logWrite
|
|||||||
from modules.commands.rules import default_rules_markup
|
from modules.commands.rules import default_rules_markup
|
||||||
|
|
||||||
# Callback rule ================================================================================================================
|
# Callback rule ================================================================================================================
|
||||||
@app.on_callback_query(filters.regex("rule_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("rule_[\s\S]*"))
|
||||||
async def callback_query_rule(app, clb):
|
async def callback_query_rule(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
@ -17,24 +17,24 @@ async def callback_query_rule(app, clb):
|
|||||||
|
|
||||||
if rule_num == len(locale("rules")):
|
if rule_num == len(locale("rules")):
|
||||||
lower_buttons = [
|
lower_buttons = [
|
||||||
InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}") # type: ignore
|
InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}")
|
||||||
]
|
]
|
||||||
elif rule_num == 1:
|
elif rule_num == 1:
|
||||||
lower_buttons = [
|
lower_buttons = [
|
||||||
InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}") # type: ignore
|
InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}")
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
lower_buttons = [
|
lower_buttons = [
|
||||||
InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}"), # type: ignore
|
InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}"),
|
||||||
InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}") # type: ignore
|
InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}")
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await clb.message.edit(text=locale("rules")[rule_num-1], disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(
|
await clb.message.edit(text=locale("rules")[rule_num-1], disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"), # type: ignore
|
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"),
|
||||||
InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional") # type: ignore
|
InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional")
|
||||||
],
|
],
|
||||||
lower_buttons
|
lower_buttons
|
||||||
]
|
]
|
||||||
@ -43,9 +43,9 @@ async def callback_query_rule(app, clb):
|
|||||||
except bad_request_400.MessageNotModified:
|
except bad_request_400.MessageNotModified:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
await clb.answer(text=locale("rules_page", "callback").format(fullclb[1])) # type: ignore
|
await clb.answer(text=locale("rules_page", "callback").format(fullclb[1]))
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("rules_home")) # type: ignore
|
@app.on_callback_query(filters.regex("rules_home"))
|
||||||
async def callback_query_rules_home(app, clb):
|
async def callback_query_rules_home(app, clb):
|
||||||
|
|
||||||
logWrite(f"User {clb.from_user.id} requested to check out homepage rules")
|
logWrite(f"User {clb.from_user.id} requested to check out homepage rules")
|
||||||
@ -55,9 +55,9 @@ async def callback_query_rules_home(app, clb):
|
|||||||
except bad_request_400.MessageNotModified:
|
except bad_request_400.MessageNotModified:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
await clb.answer(text=locale("rules_home", "callback")) # type: ignore
|
await clb.answer(text=locale("rules_home", "callback"))
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("rules_additional")) # type: ignore
|
@app.on_callback_query(filters.regex("rules_additional"))
|
||||||
async def callback_query_rules_additional(app, clb):
|
async def callback_query_rules_additional(app, clb):
|
||||||
|
|
||||||
logWrite(f"User {clb.from_user.id} requested to check out additional rules")
|
logWrite(f"User {clb.from_user.id} requested to check out additional rules")
|
||||||
@ -67,5 +67,5 @@ async def callback_query_rules_additional(app, clb):
|
|||||||
except bad_request_400.MessageNotModified:
|
except bad_request_400.MessageNotModified:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
await clb.answer(text=locale("rules_additional", "callback")) # type: ignore
|
await clb.answer(text=locale("rules_additional", "callback"))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
@ -6,12 +6,12 @@ from pyrogram import filters
|
|||||||
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite
|
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite
|
||||||
|
|
||||||
# Callbacks application ========================================================================================================
|
# Callbacks application ========================================================================================================
|
||||||
@app.on_callback_query(filters.regex("sub_yes_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("sub_yes_[\s\S]*"))
|
||||||
async def callback_query_accept(app, clb):
|
async def callback_query_accept(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
|
|
||||||
await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore
|
await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
|
||||||
logWrite(f"User {fullclb[2]} got approved by {clb.from_user.id}")
|
logWrite(f"User {fullclb[2]} got approved by {clb.from_user.id}")
|
||||||
|
|
||||||
need_link = True
|
need_link = True
|
||||||
@ -52,14 +52,14 @@ async def callback_query_accept(app, clb):
|
|||||||
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)
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("sub_no_aggressive_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("sub_no_aggressive_[\s\S]*"))
|
||||||
async def callback_query_refuse_aggressive(app, clb):
|
async def callback_query_refuse_aggressive(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
|
|
||||||
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(configGet("admin_group"), locale("refused_by_agr", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True)
|
||||||
await app.send_message(int(fullclb[3]), locale("refused", "message"))
|
await app.send_message(int(fullclb[3]), locale("refused", "message"))
|
||||||
logWrite(f"User {fullclb[3]} got refused by {clb.from_user.id} due to being aggressive")
|
logWrite(f"User {fullclb[3]} got refused by {clb.from_user.id} due to being aggressive")
|
||||||
|
|
||||||
@ -75,14 +75,14 @@ async def callback_query_refuse_aggressive(app, clb):
|
|||||||
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[3]), show_alert=True) # type: ignore
|
await clb.answer(text=locale("sub_no_aggressive", "callback").format(fullclb[3]), show_alert=True)
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("sub_no_russian_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("sub_no_russian_[\s\S]*"))
|
||||||
async def callback_query_refuse_russian(app, clb):
|
async def callback_query_refuse_russian(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
|
|
||||||
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(configGet("admin_group"), locale("refused_by_rus", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True)
|
||||||
await app.send_message(int(fullclb[3]), locale("refused", "message"))
|
await app.send_message(int(fullclb[3]), locale("refused", "message"))
|
||||||
await app.send_message(int(fullclb[3]), locale("refused_russian", "message"))
|
await app.send_message(int(fullclb[3]), locale("refused_russian", "message"))
|
||||||
logWrite(f"User {fullclb[3]} got refused by {clb.from_user.id} due to being russian")
|
logWrite(f"User {fullclb[3]} got refused by {clb.from_user.id} due to being russian")
|
||||||
@ -99,14 +99,14 @@ async def callback_query_refuse_russian(app, clb):
|
|||||||
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[3]), show_alert=True) # type: ignore
|
await clb.answer(text=locale("sub_no_russian", "callback").format(fullclb[3]), show_alert=True)
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("sub_no_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("sub_no_[\s\S]*"))
|
||||||
async def callback_query_refuse(app, clb):
|
async def callback_query_refuse(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
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(configGet("admin_group"), locale("refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
|
||||||
await app.send_message(int(fullclb[2]), locale("refused", "message"))
|
await app.send_message(int(fullclb[2]), locale("refused", "message"))
|
||||||
logWrite(f"User {fullclb[2]} got refused by {clb.from_user.id}")
|
logWrite(f"User {fullclb[2]} got refused by {clb.from_user.id}")
|
||||||
|
|
||||||
@ -122,5 +122,5 @@ async def callback_query_refuse(app, clb):
|
|||||||
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_refused", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
await clb.answer(text=locale("sub_refused", "callback").format(fullclb[2]), show_alert=True)
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
@ -5,18 +5,18 @@ from pyrogram import filters
|
|||||||
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite
|
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite
|
||||||
|
|
||||||
# Callbacks sus users ==========================================================================================================
|
# Callbacks sus users ==========================================================================================================
|
||||||
@app.on_callback_query(filters.regex("sus_allow_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("sus_allow_[\s\S]*"))
|
||||||
async def callback_query_sus_allow(app, clb):
|
async def callback_query_sus_allow(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
|
|
||||||
await app.send_message(configGet("admin_group"), locale("sus_allowed_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore
|
await app.send_message(configGet("admin_group"), locale("sus_allowed_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
|
||||||
logWrite(f"User {fullclb[2]} was allowed to join with another link by {clb.from_user.id}")
|
logWrite(f"User {fullclb[2]} was allowed to join with another link by {clb.from_user.id}")
|
||||||
|
|
||||||
edited_markup = [[InlineKeyboardButton(text=str(locale("sus_allowed", "button")), callback_data="nothing")]]
|
edited_markup = [[InlineKeyboardButton(text=str(locale("sus_allowed", "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("sus_allowed", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
await clb.answer(text=locale("sus_allowed", "callback").format(fullclb[2]), show_alert=True)
|
||||||
|
|
||||||
await app.restrict_chat_member(configGet("destination_group"), int(fullclb[2]), permissions=ChatPermissions(
|
await app.restrict_chat_member(configGet("destination_group"), int(fullclb[2]), permissions=ChatPermissions(
|
||||||
can_send_messages=True,
|
can_send_messages=True,
|
||||||
@ -26,18 +26,18 @@ async def callback_query_sus_allow(app, clb):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.on_callback_query(filters.regex("sus_refuse_[\s\S]*")) # type: ignore
|
@app.on_callback_query(filters.regex("sus_refuse_[\s\S]*"))
|
||||||
async def callback_query_sus_refuse(app, clb):
|
async def callback_query_sus_refuse(app, clb):
|
||||||
|
|
||||||
fullclb = clb.data.split("_")
|
fullclb = clb.data.split("_")
|
||||||
|
|
||||||
await app.send_message(configGet("admin_group"), locale("sus_refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore
|
await app.send_message(configGet("admin_group"), locale("sus_refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
|
||||||
logWrite(f"User {fullclb[2]} was refused to join with another link by {clb.from_user.id}")
|
logWrite(f"User {fullclb[2]} was refused to join with another link by {clb.from_user.id}")
|
||||||
|
|
||||||
edited_markup = [[InlineKeyboardButton(text=str(locale("sus_refused", "button")), callback_data="nothing")]]
|
edited_markup = [[InlineKeyboardButton(text=str(locale("sus_refused", "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("sus_refused", "callback").format(fullclb[2]), show_alert=True) # type: ignore
|
await clb.answer(text=locale("sus_refused", "callback").format(fullclb[2]), show_alert=True)
|
||||||
|
|
||||||
await app.ban_chat_member(configGet("destination_group"), int(fullclb[2]))
|
await app.ban_chat_member(configGet("destination_group"), int(fullclb[2]))
|
||||||
|
|
||||||
|
@ -33,20 +33,20 @@ async def cmd_application(app, msg):
|
|||||||
i += 1
|
i += 1
|
||||||
if user_data["sent"]:
|
if user_data["sent"]:
|
||||||
if user_data["approved"]:
|
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
|
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"))
|
||||||
elif application["refused"]:
|
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
|
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"))
|
||||||
else:
|
else:
|
||||||
application_status = locale("application_status_on_hold", "message")
|
application_status = locale("application_status_on_hold", "message")
|
||||||
else:
|
else:
|
||||||
if user_data["approved"]:
|
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
|
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"))
|
||||||
elif application["refused"]:
|
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
|
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"))
|
||||||
else:
|
else:
|
||||||
application_status = locale("application_status_not_send", "message")
|
application_status = locale("application_status_not_send", "message")
|
||||||
logWrite(f"User {msg.from_user.id} requested application of {user_id}")
|
logWrite(f"User {msg.from_user.id} requested application of {user_id}")
|
||||||
await msg.reply_text(locale("contact", "message").format(str(user_id), "\n".join(application_content), application_status), quote=should_quote(msg)) # type: ignore
|
await msg.reply_text(locale("contact", "message").format(str(user_id), "\n".join(application_content), application_status), quote=should_quote(msg))
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logWrite(f"User {msg.from_user.id} requested application of {user_id} but user does not exists")
|
logWrite(f"User {msg.from_user.id} requested application of {user_id} but user does not exists")
|
||||||
await msg.reply_text(locale("contact_invalid", "message"), quote=should_quote(msg))
|
await msg.reply_text(locale("contact_invalid", "message"), quote=should_quote(msg))
|
||||||
|
@ -21,25 +21,25 @@ async def cmd_reapply(app, msg):
|
|||||||
else:
|
else:
|
||||||
await msg.reply_text(locale("reapply_left_chat", "message"), reply_markup=InlineKeyboardMarkup([
|
await msg.reply_text(locale("reapply_left_chat", "message"), reply_markup=InlineKeyboardMarkup([
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(locale("reapply_old_one", "button"), f"reapply_old_{msg.id}") # type: ignore
|
InlineKeyboardButton(locale("reapply_old_one", "button"), f"reapply_old_{msg.id}")
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(locale("reapply_new_one", "button"), f"reapply_new_{msg.id}") # type: ignore
|
InlineKeyboardButton(locale("reapply_new_one", "button"), f"reapply_new_{msg.id}")
|
||||||
]
|
]
|
||||||
]))
|
]))
|
||||||
else:
|
else:
|
||||||
await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([ # type: ignore
|
await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}") # type: ignore
|
InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}")
|
||||||
]
|
]
|
||||||
])) # type: ignore
|
]))
|
||||||
else:
|
else:
|
||||||
if configGet("sent", file=str(msg.from_user.id)):
|
if configGet("sent", file=str(msg.from_user.id)):
|
||||||
await msg.reply_text(locale("reapply_forbidden", "message"))
|
await msg.reply_text(locale("reapply_forbidden", "message"))
|
||||||
else:
|
else:
|
||||||
await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([ # type: ignore
|
await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}") # type: ignore
|
InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}")
|
||||||
]
|
]
|
||||||
])) # type: ignore
|
]))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
@ -7,8 +7,8 @@ from modules.utils import locale
|
|||||||
default_rules_markup = InlineKeyboardMarkup(
|
default_rules_markup = InlineKeyboardMarkup(
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"), # type: ignore
|
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"),
|
||||||
InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional") # type: ignore
|
InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional")
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
InlineKeyboardButton("1", callback_data="rule_1"),
|
InlineKeyboardButton("1", callback_data="rule_1"),
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
from app import app
|
from app import app
|
||||||
from os import sep
|
from os import sep
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from modules.utils import jsonLoad, jsonSave, configGet, configSet, logWrite
|
from pyrogram.types import ReplyKeyboardMarkup
|
||||||
|
from modules.utils import jsonLoad, jsonSave, configGet, configSet, locale, logWrite
|
||||||
|
|
||||||
# Start command ================================================================================================================
|
# Start command ================================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]))
|
||||||
@ -20,5 +21,5 @@ async def cmd_start(app, msg):
|
|||||||
configSet(["telegram_locale"], str(msg.from_user.language_code), file=str(msg.from_user.id))
|
configSet(["telegram_locale"], str(msg.from_user.language_code), file=str(msg.from_user.id))
|
||||||
|
|
||||||
logWrite(f"User {msg.from_user.id} started bot interaction")
|
logWrite(f"User {msg.from_user.id} started bot interaction")
|
||||||
await msg.reply_text(locale("start", "message"), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboard"), resize_keyboard=True)) # type: ignore
|
await msg.reply_text(locale("start", "message"), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboard"), resize_keyboard=True))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
@ -1,7 +1,7 @@
|
|||||||
from os import sep
|
from os import sep
|
||||||
from app import app, isAnAdmin
|
from app import app, isAnAdmin
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from modules.utils import jsonLoad, jsonSave, configGet
|
from modules.utils import jsonLoad, jsonSave, configGet, locale
|
||||||
|
|
||||||
# Warn command =================================================================================================================
|
# Warn command =================================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["warn"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & filters.command(["warn"], prefixes=["/"]))
|
||||||
@ -16,5 +16,5 @@ async def cmd_warn(app, msg):
|
|||||||
else:
|
else:
|
||||||
warnings[str(msg.reply_to_message.from_user.id)] += 1
|
warnings[str(msg.reply_to_message.from_user.id)] += 1
|
||||||
jsonSave(warnings, f"{configGet('data', 'locations')}{sep}warnings.json")
|
jsonSave(warnings, f"{configGet('data', 'locations')}{sep}warnings.json")
|
||||||
await msg.reply_text(locale("warned", "message").format(msg.reply_to_message.from_user.first_name, msg.reply_to_message.from_user.id)) # type: ignore
|
await msg.reply_text(locale("warned", "message").format(msg.reply_to_message.from_user.first_name, msg.reply_to_message.from_user.id))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
@ -28,14 +28,14 @@ async def cmd_warnings(app, msg):
|
|||||||
target_name = target.first_name
|
target_name = target.first_name
|
||||||
target_id = str(target.id)
|
target_id = str(target.id)
|
||||||
else:
|
else:
|
||||||
await msg.reply_text(locale("no_user_warnings", "message").format(msg.command[1])) # type: ignore
|
await msg.reply_text(locale("no_user_warnings", "message").format(msg.command[1]))
|
||||||
return
|
return
|
||||||
|
|
||||||
if target_id not in warnings:
|
if target_id not in warnings:
|
||||||
await msg.reply_text(locale("no_warnings", "message").format(target_name, target_id), quote=should_quote(msg)) # type: ignore
|
await msg.reply_text(locale("no_warnings", "message").format(target_name, target_id), quote=should_quote(msg))
|
||||||
else:
|
else:
|
||||||
if warnings[target_id] <= 5:
|
if warnings[target_id] <= 5:
|
||||||
await msg.reply_text(locale("warnings_1", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg)) # type: ignore
|
await msg.reply_text(locale("warnings_1", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg))
|
||||||
else:
|
else:
|
||||||
await msg.reply_text(locale("warnings_2", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg)) # type: ignore
|
await msg.reply_text(locale("warnings_2", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
@ -8,7 +8,7 @@ def commands_register(app):
|
|||||||
commands_list = []
|
commands_list = []
|
||||||
for command in configGet("commands"):
|
for command in configGet("commands"):
|
||||||
commands_list.append(BotCommand(command, configGet("commands")[command]))
|
commands_list.append(BotCommand(command, configGet("commands")[command]))
|
||||||
app.set_bot_commands(commands_list) # type: ignore
|
app.set_bot_commands(commands_list)
|
||||||
|
|
||||||
# Registering admin commands
|
# Registering admin commands
|
||||||
commands_admin_list = []
|
commands_admin_list = []
|
||||||
@ -20,20 +20,20 @@ def commands_register(app):
|
|||||||
|
|
||||||
for admin in configGet("admins"):
|
for admin in configGet("admins"):
|
||||||
try:
|
try:
|
||||||
app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=admin)) # type: ignore
|
app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=admin))
|
||||||
except bad_request_400.PeerIdInvalid:
|
except bad_request_400.PeerIdInvalid:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=configGet("owner"))) # type: ignore
|
app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=configGet("owner")))
|
||||||
|
|
||||||
# Registering admin group commands
|
# Registering admin group commands
|
||||||
commands_group_admin_list = []
|
commands_group_admin_list = []
|
||||||
for command in configGet("commands_group_admin"):
|
for command in configGet("commands_group_admin"):
|
||||||
commands_group_admin_list.append(BotCommand(command, configGet("commands_group_admin")[command]))
|
commands_group_admin_list.append(BotCommand(command, configGet("commands_group_admin")[command]))
|
||||||
app.set_bot_commands(commands_group_admin_list, scope=BotCommandScopeChat(chat_id=configGet("admin_group"))) # type: ignore
|
app.set_bot_commands(commands_group_admin_list, scope=BotCommandScopeChat(chat_id=configGet("admin_group")))
|
||||||
|
|
||||||
# Registering destination group commands
|
# Registering destination group commands
|
||||||
commands_group_destination_list = []
|
commands_group_destination_list = []
|
||||||
for command in configGet("commands_group_destination"):
|
for command in configGet("commands_group_destination"):
|
||||||
commands_group_destination_list.append(BotCommand(command, configGet("commands_group_destination")[command]))
|
commands_group_destination_list.append(BotCommand(command, configGet("commands_group_destination")[command]))
|
||||||
app.set_bot_commands(commands_group_destination_list, scope=BotCommandScopeChat(chat_id=configGet("destination_group"))) # type: ignore
|
app.set_bot_commands(commands_group_destination_list, scope=BotCommandScopeChat(chat_id=configGet("destination_group")))
|
@ -5,6 +5,7 @@ from datetime import datetime
|
|||||||
from app import app
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import ReplyKeyboardRemove, InlineKeyboardMarkup, InlineKeyboardButton
|
from pyrogram.types import ReplyKeyboardRemove, InlineKeyboardMarkup, InlineKeyboardButton
|
||||||
|
from pyrogram.enums.parse_mode import ParseMode
|
||||||
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite
|
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite
|
||||||
from modules.handlers.welcome import welcome_pass
|
from modules.handlers.welcome import welcome_pass
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ async def confirm_yes(app, msg):
|
|||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
if configGet("reapply", file=str(msg.from_user.id)):
|
if configGet("reapply", file=str(msg.from_user.id)):
|
||||||
await app.send_message(chat_id=configGet("admin_group"), text=(locale("reapply_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
|
await app.send_message(chat_id=configGet("admin_group"), text=(locale("reapply_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(
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(text=str(locale("reapply_yes", "button")), callback_data=f"reapply_yes_{msg.from_user.id}")
|
InlineKeyboardButton(text=str(locale("reapply_yes", "button")), callback_data=f"reapply_yes_{msg.from_user.id}")
|
||||||
@ -59,7 +60,7 @@ async def confirm_yes(app, msg):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
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
|
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(
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
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}")
|
||||||
|
@ -24,20 +24,20 @@ async def get_contact(app, msg):
|
|||||||
i += 1
|
i += 1
|
||||||
if user_data["sent"]:
|
if user_data["sent"]:
|
||||||
if user_data["approved"]:
|
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
|
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"))
|
||||||
elif application["refused"]:
|
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
|
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"))
|
||||||
else:
|
else:
|
||||||
application_status = locale("application_status_on_hold", "message")
|
application_status = locale("application_status_on_hold", "message")
|
||||||
else:
|
else:
|
||||||
if user_data["approved"]:
|
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
|
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"))
|
||||||
elif application["refused"]:
|
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
|
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"))
|
||||||
else:
|
else:
|
||||||
application_status = locale("application_status_not_send", "message")
|
application_status = locale("application_status_not_send", "message")
|
||||||
logWrite(f"User {msg.from_user.id} requested application of {msg.contact.user_id}")
|
logWrite(f"User {msg.from_user.id} requested application of {msg.contact.user_id}")
|
||||||
await msg.reply_text(locale("contact", "message").format(str(msg.contact.user_id), "\n".join(application_content), application_status)) # type: ignore
|
await msg.reply_text(locale("contact", "message").format(str(msg.contact.user_id), "\n".join(application_content), application_status))
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logWrite(f"User {msg.from_user.id} requested application of {msg.contact.user_id} but user does not exists")
|
logWrite(f"User {msg.from_user.id} requested application of {msg.contact.user_id} but user does not exists")
|
||||||
await msg.reply_text(locale("contact_invalid", "message"))
|
await msg.reply_text(locale("contact_invalid", "message"))
|
||||||
|
@ -2,7 +2,7 @@ from datetime import datetime
|
|||||||
from app import app
|
from app import app
|
||||||
import asyncio
|
import asyncio
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import ForceReply
|
from pyrogram.types import ForceReply, ReplyKeyboardMarkup
|
||||||
from modules.utils import configGet, configSet, locale, logWrite
|
from modules.utils import configGet, configSet, locale, logWrite
|
||||||
|
|
||||||
# Any other input ==============================================================================================================
|
# Any other input ==============================================================================================================
|
||||||
@ -33,7 +33,7 @@ async def any_stage(app, msg):
|
|||||||
|
|
||||||
elif ((datetime.now() - input_dt).days) < ((datetime.now() - datetime.now().replace(year=datetime.now().year - configGet("age_allowed"))).days):
|
elif ((datetime.now() - input_dt).days) < ((datetime.now() - datetime.now().replace(year=datetime.now().year - configGet("age_allowed"))).days):
|
||||||
logWrite(f"User {msg.from_user.id} failed stage {user_stage} due to being underage")
|
logWrite(f"User {msg.from_user.id} failed stage {user_stage} due to being underage")
|
||||||
await msg.reply_text(locale("question2_underage", "message").format(str(configGet("age_allowed"))), reply_markup=ForceReply(placeholder=str(locale("question2", "force_reply")))) # type: ignore
|
await msg.reply_text(locale("question2_underage", "message").format(str(configGet("age_allowed"))), reply_markup=ForceReply(placeholder=str(locale("question2", "force_reply"))))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logWrite(f"User {msg.from_user.id} completed stage {user_stage} of application")
|
logWrite(f"User {msg.from_user.id} completed stage {user_stage} of application")
|
||||||
@ -59,7 +59,7 @@ async def any_stage(app, msg):
|
|||||||
for question in configGet("application", file=str(msg.from_user.id)):
|
for question in configGet("application", file=str(msg.from_user.id)):
|
||||||
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 msg.reply_text(locale("confirm", "message").format("\n".join(application_content)), reply_markup=ReplyKeyboardMarkup(locale("confirm", "keyboard"), resize_keyboard=True)) # type: ignore
|
await msg.reply_text(locale("confirm", "message").format("\n".join(application_content)), reply_markup=ReplyKeyboardMarkup(locale("confirm", "keyboard"), resize_keyboard=True))
|
||||||
#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("application_date", int(time()), file=str(msg.from_user.id))
|
||||||
else:
|
else:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from app import app
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
|
from pyrogram.types import ForceReply, ReplyKeyboardMarkup
|
||||||
from modules.utils import configGet, configSet, locale, logWrite
|
from modules.utils import configGet, configSet, locale, logWrite
|
||||||
|
|
||||||
# Welcome check ================================================================================================================
|
# Welcome check ================================================================================================================
|
||||||
@ -17,7 +18,7 @@ async def welcome_pass(app, msg, once_again: bool = True) -> None:
|
|||||||
await msg.reply_text(locale("privacy_notice", "message"))
|
await msg.reply_text(locale("privacy_notice", "message"))
|
||||||
|
|
||||||
logWrite(f"User {msg.from_user.id} confirmed starting the application")
|
logWrite(f"User {msg.from_user.id} confirmed starting the application")
|
||||||
await msg.reply_text(locale("question1", "message"), reply_markup=ForceReply(placeholder=locale("question1", "force_reply"))) # type: ignore
|
await msg.reply_text(locale("question1", "message"), reply_markup=ForceReply(placeholder=locale("question1", "force_reply")))
|
||||||
configSet(["stage"], 1, file=str(msg.from_user.id))
|
configSet(["stage"], 1, file=str(msg.from_user.id))
|
||||||
configSet(["sent"], False, file=str(msg.from_user.id))
|
configSet(["sent"], False, file=str(msg.from_user.id))
|
||||||
|
|
||||||
@ -25,5 +26,5 @@ async def welcome_pass(app, msg, once_again: bool = True) -> None:
|
|||||||
async def welcome_reject(app, msg):
|
async def welcome_reject(app, msg):
|
||||||
|
|
||||||
logWrite(f"User {msg.from_user.id} refused to start the application")
|
logWrite(f"User {msg.from_user.id} refused to start the application")
|
||||||
await msg.reply_text(locale("goodbye", "message"), reply_markup=ReplyKeyboardMarkup(locale("return", "keyboard"), resize_keyboard=True)) # type: ignore
|
await msg.reply_text(locale("goodbye", "message"), reply_markup=ReplyKeyboardMarkup(locale("return", "keyboard"), resize_keyboard=True))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
@ -137,7 +137,7 @@ except ModuleNotFoundError:
|
|||||||
|
|
||||||
def killProc(pid):
|
def killProc(pid):
|
||||||
if osname == "posix":
|
if osname == "posix":
|
||||||
from signal import SIGKILL # type: ignore
|
from signal import SIGKILL
|
||||||
kill(pid, SIGKILL)
|
kill(pid, SIGKILL)
|
||||||
else:
|
else:
|
||||||
p = Process(pid)
|
p = Process(pid)
|
||||||
|
Reference in New Issue
Block a user