Compare commits
4 Commits
414bfefb21
...
51b943b576
Author | SHA1 | Date | |
---|---|---|---|
51b943b576 | |||
de552db4c8 | |||
8beb33b7c3 | |||
05e3916478 |
@@ -4,7 +4,7 @@
|
|||||||
"goodbye": "Добре, дякуємо за чесність! Вибачте, але за таких умов ми не будемо тебе додавати до спільноти. Якщо передумаєш та захочеш приєднатись - просто натисни на кнопку.",
|
"goodbye": "Добре, дякуємо за чесність! Вибачте, але за таких умов ми не будемо тебе додавати до спільноти. Якщо передумаєш та захочеш приєднатись - просто натисни на кнопку.",
|
||||||
"privacy_notice": "Раді це чути!\n\nДля продовження треба буде заповнити невеличку анкетку. Будь ласка, віднесись до цього серйозно. Ми відповідально ставимось до персональних даних, тому ця анкета не буде передана третім особам, а буде використана лише для проходження до спільноти.",
|
"privacy_notice": "Раді це чути!\n\nДля продовження треба буде заповнити невеличку анкетку. Будь ласка, віднесись до цього серйозно. Ми відповідально ставимось до персональних даних, тому ця анкета не буде передана третім особам, а буде використана лише для проходження до спільноти.",
|
||||||
"question1": "Як до тебе можна звертатись?",
|
"question1": "Як до тебе можна звертатись?",
|
||||||
"question2": "Коли в тебе день народження?",
|
"question2": "Коли в тебе день народження?\n\nБудь ласка, у форматі ДД.ММ.РРРР",
|
||||||
"question3": "З якого ти міста або де проживаєш зараз?\n\n⚠️ Будь ласка, не вказуйте точних адрес! \"Київ\" або \"Київська Область\" є достатньою конкретизацією.\n\nПриклади:\n• Київ\n• Одеська область\n• Макіївка (Луганська область)",
|
"question3": "З якого ти міста або де проживаєш зараз?\n\n⚠️ Будь ласка, не вказуйте точних адрес! \"Київ\" або \"Київська Область\" є достатньою конкретизацією.\n\nПриклади:\n• Київ\n• Одеська область\n• Макіївка (Луганська область)",
|
||||||
"question4": "Коли вперше довелось дізнатись про Хололайв?",
|
"question4": "Коли вперше довелось дізнатись про Хололайв?",
|
||||||
"question5": "Чим тебе зацікавив Хололайв?",
|
"question5": "Чим тебе зацікавив Хололайв?",
|
||||||
|
@@ -83,13 +83,30 @@ async def callback_query_reapply_reject(app: Client, clb: CallbackQuery):
|
|||||||
# 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]*"))
|
@app.on_callback_query(filters.regex("reapply_old_[\s\S]*"))
|
||||||
async def callback_query_reapply_old(app: Client, clb: CallbackQuery):
|
async def callback_query_reapply_old(app: Client, clb: CallbackQuery):
|
||||||
fullclb = clb.data.split("_")
|
|
||||||
|
|
||||||
if HoloUser(clb.from_user).sponsorship_state()[0] == "fill":
|
fullclb = clb.data.split("_")
|
||||||
|
holo_user = HoloUser(clb.from_user)
|
||||||
|
|
||||||
|
if holo_user.sponsorship_state()[0] == "fill":
|
||||||
await clb.message.reply_text(locale("finish_sponsorship", "message"), quote=False)
|
await clb.message.reply_text(locale("finish_sponsorship", "message"), quote=False)
|
||||||
return
|
return
|
||||||
|
|
||||||
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
||||||
|
|
||||||
|
if col_tmp.find_one({"user": holo_user.id, "type": "application"}) is None and col_applications.find_one({"user": holo_user.id}) is not None:
|
||||||
|
col_tmp.insert_one(
|
||||||
|
{
|
||||||
|
"user": holo_user.id,
|
||||||
|
"type": "application",
|
||||||
|
"complete": True,
|
||||||
|
"sent": False,
|
||||||
|
"state": "fill",
|
||||||
|
"reapply": True,
|
||||||
|
"stage": 10,
|
||||||
|
"application": col_applications.find_one({"user": holo_user.id})["application"]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
await confirm_yes(app, message, kind="application")
|
await confirm_yes(app, message, kind="application")
|
||||||
await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button", locale=clb.from_user), "nothing")]]))
|
await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button", locale=clb.from_user), "nothing")]]))
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ from classes.holo_user import HoloUser
|
|||||||
from modules.logging import logWrite
|
from modules.logging import logWrite
|
||||||
from modules.utils import configGet, locale, should_quote
|
from modules.utils import configGet, locale, should_quote
|
||||||
from modules.handlers.welcome import welcome_pass
|
from modules.handlers.welcome import welcome_pass
|
||||||
from modules.database import col_tmp
|
from modules.database import col_tmp, col_applications
|
||||||
from modules import custom_filters
|
from modules import custom_filters
|
||||||
|
|
||||||
# Reapply command ==============================================================================================================
|
# Reapply command ==============================================================================================================
|
||||||
@@ -27,16 +27,20 @@ async def cmd_reapply(app: Client, msg: Message):
|
|||||||
if member.user.id == msg.from_user.id:
|
if member.user.id == msg.from_user.id:
|
||||||
left_chat = False
|
left_chat = False
|
||||||
|
|
||||||
if not left_chat:
|
if left_chat is True:
|
||||||
if holo_user.sponsorship_state()[0] == "fill":
|
|
||||||
await msg.reply_text(locale("finish_sponsorship", "message"), quote=should_quote(msg))
|
|
||||||
return
|
|
||||||
holo_user.application_restart(reapply=True)
|
|
||||||
await welcome_pass(app, msg, once_again=True)
|
|
||||||
|
|
||||||
else:
|
if (holo_user.application_state()[1] is True and holo_user.application_state()[0] != "fill"):
|
||||||
|
|
||||||
if holo_user.application_state()[1] is True and holo_user.application_state()[0] != "fill":
|
await msg.reply_text(locale("reapply_left_chat", "message", locale=holo_user), reply_markup=InlineKeyboardMarkup([
|
||||||
|
[
|
||||||
|
InlineKeyboardButton(locale("reapply_old_one", "button", locale=holo_user), f"reapply_old_{msg.id}")
|
||||||
|
],
|
||||||
|
[
|
||||||
|
InlineKeyboardButton(locale("reapply_new_one", "button", locale=holo_user), f"reapply_new_{msg.id}")
|
||||||
|
]
|
||||||
|
]))
|
||||||
|
|
||||||
|
elif col_tmp.find_one({"user": holo_user.id, "type": "application"}) is None and col_applications.find_one({"user": holo_user.id}) is not None:
|
||||||
|
|
||||||
await msg.reply_text(locale("reapply_left_chat", "message", locale=holo_user), reply_markup=InlineKeyboardMarkup([
|
await msg.reply_text(locale("reapply_left_chat", "message", locale=holo_user), reply_markup=InlineKeyboardMarkup([
|
||||||
[
|
[
|
||||||
@@ -52,6 +56,15 @@ async def cmd_reapply(app: Client, msg: Message):
|
|||||||
holo_user.application_restart(reapply=True)
|
holo_user.application_restart(reapply=True)
|
||||||
await welcome_pass(app, msg, once_again=True)
|
await welcome_pass(app, msg, once_again=True)
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
if holo_user.sponsorship_state()[0] == "fill":
|
||||||
|
await msg.reply_text(locale("finish_sponsorship", "message"), quote=should_quote(msg))
|
||||||
|
return
|
||||||
|
|
||||||
|
holo_user.application_restart(reapply=True)
|
||||||
|
await welcome_pass(app, msg, once_again=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
await msg.reply_text(locale("reapply_in_progress", "message", locale=holo_user).format(locale("confirm", "keyboard", locale=holo_user)[1][0]), reply_markup=InlineKeyboardMarkup([
|
await msg.reply_text(locale("reapply_in_progress", "message", locale=holo_user).format(locale("confirm", "keyboard", locale=holo_user)[1][0]), reply_markup=InlineKeyboardMarkup([
|
||||||
|
@@ -22,7 +22,7 @@ async def message_context(msg: Message) -> tuple:
|
|||||||
return 0, 0
|
return 0, 0
|
||||||
|
|
||||||
# Any other input ==============================================================================================================
|
# Any other input ==============================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.private)
|
@app.on_message(~ filters.scheduled & (filters.private | filters.chat(configGet("admin", "groups"))))
|
||||||
async def any_stage(app: Client, msg: Message):
|
async def any_stage(app: Client, msg: Message):
|
||||||
|
|
||||||
if msg.via_bot is None:
|
if msg.via_bot is None:
|
||||||
@@ -52,6 +52,9 @@ async def any_stage(app: Client, msg: Message):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if msg.chat.id == configGet("admin", "groups"):
|
||||||
|
return
|
||||||
|
|
||||||
if msg.text is not None:
|
if msg.text is not None:
|
||||||
|
|
||||||
if configGet("enabled", "features", "applications") is True:
|
if configGet("enabled", "features", "applications") is True:
|
||||||
|
@@ -30,7 +30,10 @@ async def welcome_pass(app: Client, msg: Message, once_again: bool = False) -> N
|
|||||||
if once_again is False:
|
if once_again is False:
|
||||||
holo_user.application_restart()
|
holo_user.application_restart()
|
||||||
|
|
||||||
logWrite(f"User {msg.from_user.id} confirmed starting the application")
|
if once_again is True:
|
||||||
|
logWrite(f"User {msg.from_user.id} confirmed starting the application")
|
||||||
|
else:
|
||||||
|
logWrite(f"User {msg.from_user.id} confirmed starting the application once again")
|
||||||
await msg.reply_text(locale("question1", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("question1", "force_reply", locale=msg.from_user)))
|
await msg.reply_text(locale("question1", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("question1", "force_reply", locale=msg.from_user)))
|
||||||
|
|
||||||
welcome_2 = []
|
welcome_2 = []
|
||||||
|
@@ -12,7 +12,7 @@ from pyrogram.types import BotCommand, BotCommandScopeChat, BotCommandScopeChatA
|
|||||||
from pyrogram.errors import bad_request_400
|
from pyrogram.errors import bad_request_400
|
||||||
from pyrogram.enums.chat_members_filter import ChatMembersFilter
|
from pyrogram.enums.chat_members_filter import ChatMembersFilter
|
||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
from modules.utils import configGet, jsonSave, locale, logWrite
|
from modules.utils import configGet, jsonLoad, jsonSave, locale, logWrite
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from modules.database import col_applications, col_sponsorships, col_youtube
|
from modules.database import col_applications, col_sponsorships, col_youtube
|
||||||
from xmltodict import parse
|
from xmltodict import parse
|
||||||
@@ -66,6 +66,8 @@ if configGet("enabled", "features", "applications") is True:
|
|||||||
for entry in col_applications.find():
|
for entry in col_applications.find():
|
||||||
if entry["application"]["2"].strftime("%d.%m") == datetime.now().strftime("%d.%m"):
|
if entry["application"]["2"].strftime("%d.%m") == datetime.now().strftime("%d.%m"):
|
||||||
try:
|
try:
|
||||||
|
if entry["user"] not in jsonLoad(path.join(configGet("cache", "locations"), "group_members")):
|
||||||
|
continue
|
||||||
tg_user = await app.get_users(entry["user"])
|
tg_user = await app.get_users(entry["user"])
|
||||||
await app.send_message( configGet("admin", "groups"), locale("birthday", "message").format(str(tg_user.first_name), str(tg_user.username), str(relativedelta(datetime.now(), entry["application"]["2"], '%d.%m.%Y').years)) ) # type: ignore
|
await app.send_message( configGet("admin", "groups"), locale("birthday", "message").format(str(tg_user.first_name), str(tg_user.username), str(relativedelta(datetime.now(), entry["application"]["2"], '%d.%m.%Y').years)) ) # type: ignore
|
||||||
logWrite(f"Notified admins about {entry['user']}'s birthday")
|
logWrite(f"Notified admins about {entry['user']}'s birthday")
|
||||||
@@ -82,6 +84,8 @@ if configGet("enabled", "features", "sponsorships") is True:
|
|||||||
async def check_sponsors():
|
async def check_sponsors():
|
||||||
for entry in col_sponsorships.find({"sponsorship.expires": {"$lt": datetime.now()+timedelta(days=2)}}):
|
for entry in col_sponsorships.find({"sponsorship.expires": {"$lt": datetime.now()+timedelta(days=2)}}):
|
||||||
try:
|
try:
|
||||||
|
if entry["user"] not in jsonLoad(path.join(configGet("cache", "locations"), "group_members")):
|
||||||
|
continue
|
||||||
tg_user = await app.get_users(entry["user"])
|
tg_user = await app.get_users(entry["user"])
|
||||||
until_expiry = relativedelta(datetime.now(), entry["sponsorship"]["expires"]).days
|
until_expiry = relativedelta(datetime.now(), entry["sponsorship"]["expires"]).days
|
||||||
await app.send_message( tg_user.id, locale("sponsorships_expires", "message").format(until_expiry) ) # type: ignore
|
await app.send_message( tg_user.id, locale("sponsorships_expires", "message").format(until_expiry) ) # type: ignore
|
||||||
@@ -92,9 +96,11 @@ if configGet("enabled", "features", "sponsorships") is True:
|
|||||||
for entry in col_sponsorships.find({"sponsorship.expires": {"$lt": datetime.now()}}):
|
for entry in col_sponsorships.find({"sponsorship.expires": {"$lt": datetime.now()}}):
|
||||||
try:
|
try:
|
||||||
holo_user = HoloUser(entry["user"])
|
holo_user = HoloUser(entry["user"])
|
||||||
|
col_sponsorships.find_one_and_delete({"user": holo_user.id})
|
||||||
|
if entry["user"] not in jsonLoad(path.join(configGet("cache", "locations"), "group_members")):
|
||||||
|
continue
|
||||||
await app.send_message( entry["user"], locale("sponsorships_expired", "message") ) # type: ignore
|
await app.send_message( entry["user"], locale("sponsorships_expired", "message") ) # type: ignore
|
||||||
await holo_user.label_reset(configGet("users", "groups"))
|
await holo_user.label_reset(configGet("users", "groups"))
|
||||||
col_sponsorships.find_one_and_delete({"user": holo_user.id})
|
|
||||||
try:
|
try:
|
||||||
tg_user = await app.get_users(entry["user"])
|
tg_user = await app.get_users(entry["user"])
|
||||||
logWrite(f"Notified user that sponsorship expired")
|
logWrite(f"Notified user that sponsorship expired")
|
||||||
|
Reference in New Issue
Block a user