From c0f16c69f698fcfe37ff0614848fdb442eea2198 Mon Sep 17 00:00:00 2001 From: Profitroll <47523801+profitrollgame@users.noreply.github.com> Date: Sun, 4 Dec 2022 15:05:51 +0100 Subject: [PATCH] Reapply now also sends link --- main.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/main.py b/main.py index 0e94aaf..fb1560f 100644 --- a/main.py +++ b/main.py @@ -368,6 +368,7 @@ async def callback_query_accept(app, clb): configSet(["link"], link.invite_link, file=fullclb[2]) logWrite(f"User {fullclb[2]} got an invite link {link.invite_link}") + else: await app.send_message(int(fullclb[2]), locale("approved_joined", "message")) @@ -483,6 +484,32 @@ async def callback_reapply_query_accept(app, clb): 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 + need_link = True + + async for member in app.get_chat_members(configGet("destination_group")): + if member.user.id == int(fullclb[2]): + need_link = False + + if need_link: + 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)) + + await app.send_message(int(fullclb[2]), locale("read_rules", "message")) + + for rule_msg in locale("rules"): + await app.send_message(int(fullclb[2]), rule_msg) + + await app.send_message(int(fullclb[2]), locale("approved", "message"), reply_markup=InlineKeyboardMarkup( + [[ + InlineKeyboardButton(str(locale("join", "button")), url=link.invite_link) + ]] + )) + + configSet(["link"], link.invite_link, file=fullclb[2]) + logWrite(f"User {fullclb[2]} got an invite link {link.invite_link}") + + else: + await app.send_message(int(fullclb[2]), locale("approved_joined", "message")) + @app.on_callback_query(filters.regex("reapply_no_[\s\S]*")) # type: ignore async def callback_query_reapply_refuse(app, clb):