Sponsorship concept
This commit is contained in:
parent
4d0cf629e2
commit
654daed8c2
@ -28,7 +28,8 @@
|
||||
},
|
||||
"commands": {
|
||||
"rules": "Check out the rules",
|
||||
"reapply": "Resubmit the application"
|
||||
"reapply": "Resubmit the application",
|
||||
"sponsorship": "Apply for sponsor role"
|
||||
},
|
||||
"commands_admin": {
|
||||
"reboot": "Restart the bot",
|
||||
|
9
data/sponsor_default.json
Normal file
9
data/sponsor_default.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"filling": false,
|
||||
"applied": false,
|
||||
"approved": false,
|
||||
"stage": 0,
|
||||
"paid": null,
|
||||
"expires": null,
|
||||
"nickname": null
|
||||
}
|
0
data/sponsors/.gitkeep
Normal file
0
data/sponsors/.gitkeep
Normal file
1
main.py
1
main.py
@ -37,6 +37,7 @@ from modules.commands.message import *
|
||||
from modules.commands.reapply import *
|
||||
from modules.commands.reboot import *
|
||||
from modules.commands.rules import *
|
||||
from modules.commands.sponsorship import *
|
||||
from modules.commands.start import *
|
||||
from modules.commands.warn import *
|
||||
from modules.commands.warnings import *
|
||||
|
@ -1 +1,23 @@
|
||||
from app import app
|
||||
from datetime import datetime
|
||||
from os import path, sep
|
||||
from app import app
|
||||
from pyrogram import filters
|
||||
from modules.utils import configGet, jsonLoad, jsonSave
|
||||
|
||||
# Sponsorship command ==========================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.command(["sponsorship"], prefixes=["/"]))
|
||||
async def cmd_sponsorship(app, msg):
|
||||
if not path.exists(f"{configGet('data', 'locations')}{sep}sponsors{sep}{msg.from_user.id}.json"):
|
||||
jsonSave(jsonLoad(f"{configGet('data', 'locations')}{sep}sponsor_default.json"), f"{configGet('data', 'locations')}{sep}sponsors{sep}{msg.from_user.id}.json")
|
||||
sponsor = jsonLoad(f"{configGet('data', 'locations')}{sep}sponsors{sep}{msg.from_user.id}.json")
|
||||
if sponsor["approved"]:
|
||||
if sponsor["expires"] is not None:
|
||||
if datetime.strptime(sponsor["expires"], "%d.%m.%Y") > datetime.now():
|
||||
await msg.reply_text(f"You have an active sub til **{sponsor['expires']}**.")
|
||||
else:
|
||||
await msg.reply_text(f"Your sub expired {int((datetime.now()-datetime.strptime(sponsor['expires'], '%d.%m.%Y')).days)} days ago.")
|
||||
elif sponsor["approved"]:
|
||||
await msg.reply_text(f"Your sub expiration date is not valid.")
|
||||
else:
|
||||
await msg.reply_text(f"You have no active subscription.")
|
||||
# ==============================================================================================================================
|
Reference in New Issue
Block a user