Added sponsorship support
This commit is contained in:
@@ -77,7 +77,7 @@ async def callback_query_reapply_reject(app, clb):
|
||||
async def callback_query_reapply_old(app, clb):
|
||||
fullclb = clb.data.split("_")
|
||||
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
||||
await confirm_yes(app, message)
|
||||
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")]]))
|
||||
|
||||
# Start a new application when user reapplies after leaving the chat
|
||||
|
@@ -1,10 +1,10 @@
|
||||
from datetime import datetime
|
||||
from app import app
|
||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply
|
||||
from pyrogram import filters
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import configGet, locale, logWrite
|
||||
from modules.database import col_tmp,col_sponsorships
|
||||
from modules.database import col_tmp, col_sponsorships
|
||||
|
||||
# Callbacks sponsorship ========================================================================================================
|
||||
@app.on_callback_query(filters.regex("sponsor_apply_[\s\S]*"))
|
||||
@@ -15,24 +15,51 @@ async def callback_query_sponsor_apply(app, clb):
|
||||
|
||||
logWrite(f"User {holo_user.id} applied for sponsorship")
|
||||
|
||||
col_tmp.insert_one(
|
||||
{
|
||||
"user": holo_user.id,
|
||||
"type": "sponsorship",
|
||||
"complete": False,
|
||||
"sent": False,
|
||||
"state": "fill",
|
||||
"stage": 1,
|
||||
"sponsorship": {
|
||||
"streamer": None,
|
||||
"expires": datetime.fromtimestamp(0),
|
||||
"proof": None,
|
||||
"label": ""
|
||||
}
|
||||
}
|
||||
)
|
||||
holo_user.sponsorship_restart()
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("sponsor_started", "button")), callback_data="nothing")]]
|
||||
|
||||
await clb.message.edit(text=locale("sponsorship_apply", "message"), reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sponsor_started", "callback").format(holo_user.id), show_alert=False)
|
||||
await app.send_message(holo_user.id, locale(f"sponsor1", "message", locale=holo_user.locale), reply_markup=ForceReply(placeholder=str(locale(f"sponsor1", "force_reply", locale=holo_user.locale))))
|
||||
await clb.answer(text=locale("sponsor_started", "callback").format(holo_user.id), show_alert=False)
|
||||
|
||||
@app.on_callback_query(filters.regex("sponsor_yes_[\s\S]*"))
|
||||
async def callback_query_sponsor_yes(app, clb):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin_group"), locale("sponsor_approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
|
||||
await app.send_message(holo_user.id, locale("sponsor_approved", "message", locale=holo_user))
|
||||
logWrite(f"User {holo_user.id} got approved by {clb.from_user.id}")
|
||||
|
||||
if col_sponsorships.find_one({"user": holo_user.id}) is not None:
|
||||
col_sponsorships.update_one({"date": {"$eq": datetime.now()}, "admin": {"$eq": clb.from_user.id}, "sponsorship": {"$eq": col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]}})
|
||||
else:
|
||||
col_sponsorships.insert_one({"user": holo_user.id, "date": datetime.now(), "admin": clb.from_user.id, "sponsorship": col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]})
|
||||
|
||||
col_tmp.update_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}}, {"$set": {"state": "approved", "sent": False}})
|
||||
|
||||
await holo_user.set_label(configGet("destination_group"), col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]["label"])
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||
|
||||
await app.edit_message_caption(clb.message.chat.id, clb.message.id, caption=clb.message.caption, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=f"✅ Confirmed {fullclb[2]}", show_alert=False)
|
||||
|
||||
@app.on_callback_query(filters.regex("sponsor_no_[\s\S]*"))
|
||||
async def callback_query_sponsor_no(app, clb):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin_group"), locale("sponsor_rejected_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
|
||||
await app.send_message(holo_user.id, locale("sponsor_rejected", "message", locale=holo_user))
|
||||
logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id}")
|
||||
|
||||
col_tmp.update_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}}, {"$set": {"state": "rejected", "sent": False}})
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]]
|
||||
|
||||
await app.edit_message_caption(clb.message.chat.id, clb.message.id, caption=clb.message.caption, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=f"❌ Rejected {fullclb[2]}", show_alert=False)
|
Reference in New Issue
Block a user