From 842da9a58ae4117770b69c0a6cda9bb4ef4c70ed Mon Sep 17 00:00:00 2001 From: profitroll Date: Fri, 21 Oct 2022 15:11:13 +0200 Subject: [PATCH] Callbacks fixed --- locale/uk.json | 2 +- main.py | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/locale/uk.json b/locale/uk.json index 3b0a579..6144b8d 100644 --- a/locale/uk.json +++ b/locale/uk.json @@ -83,7 +83,7 @@ "button": { "sub_yes": "✅ Прийняти", "sub_no": "❌ Відхилити", - "sub_no_aggresive": "🤡 Відхилити (Токс)", + "sub_no_aggressive": "🤡 Відхилити (Токс)", "sub_no_russian": "🇷🇺 Відхилити (Русак)", "accepted": "✅ Прийнято", "declined": "❌ Відхилено" diff --git a/main.py b/main.py index 4e3bad1..0a5cadc 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +from datetime import datetime, timedelta from time import time from os import getpid, listdir, remove from modules.utils import * @@ -102,7 +103,7 @@ async def confirm_yes(app, msg): InlineKeyboardButton(text=locale("sub_no", "button"), callback_data=f"sub_no_{msg.from_user.id}") ], [ - InlineKeyboardButton(text=locale("sub_no_aggresive", "button"), callback_data=f"sub_no_aggresive_{msg.from_user.id}") + InlineKeyboardButton(text=locale("sub_no_aggressive", "button"), callback_data=f"sub_no_aggresive_{msg.from_user.id}") ], [ InlineKeyboardButton(text=locale("sub_no_russian", "button"), callback_data=f"sub_no_russian_{msg.from_user.id}") @@ -137,12 +138,19 @@ async def callback_query_accept(app, clb): user_locale = clb.from_user.language_code await app.send_message(configGet("admin_group"), f"Approved by {clb.from_user.id}") - await app.send_message(int(fullclb[2]), "You got approved") + + 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]), "You got approved", reply_markup=InlineKeyboardMarkup( + [[ + InlineKeyboardButton("Приєднатись", url=link.invite_link) + ]] + )) edited_markup = [[InlineKeyboardButton(text=locale("accepted", "button"), callback_data="nothing")]] await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) - await clb.answer(text=locale("sub_block", "callback", locale=user_locale).format(fullclb[2]), show_alert=True) + await clb.answer(text=locale("sub_accepted", "callback", locale=user_locale).format(fullclb[2]), show_alert=True) @app.on_callback_query(filters.regex("sub_no_[\s\S]*")) async def callback_query_refuse(app, clb): @@ -156,10 +164,10 @@ async def callback_query_refuse(app, clb): edited_markup = [[InlineKeyboardButton(text=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_block", "callback", locale=user_locale).format(fullclb[2]), show_alert=True) + await clb.answer(text=locale("sub_refused", "callback", locale=user_locale).format(fullclb[2]), show_alert=True) -@app.on_callback_query(filters.regex("sub_no_aggresive_[\s\S]*")) -async def callback_query_refuse(app, clb): +@app.on_callback_query(filters.regex("sub_no_aggressive_[\s\S]*")) +async def callback_query_refuse_aggressive(app, clb): fullclb = clb.data.split("_") user_locale = clb.from_user.language_code @@ -173,7 +181,7 @@ async def callback_query_refuse(app, clb): await clb.answer(text=locale("sub_block", "callback", locale=user_locale).format(fullclb[2]), show_alert=True) @app.on_callback_query(filters.regex("sub_no_russian_[\s\S]*")) -async def callback_query_refuse(app, clb): +async def callback_query_refuse_russian(app, clb): fullclb = clb.data.split("_") user_locale = clb.from_user.language_code