diff --git a/config_example.json b/config_example.json index 04e36d7..785a6a4 100644 --- a/config_example.json +++ b/config_example.json @@ -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", diff --git a/data/sponsor_default.json b/data/sponsor_default.json new file mode 100644 index 0000000..1d13728 --- /dev/null +++ b/data/sponsor_default.json @@ -0,0 +1,9 @@ +{ + "filling": false, + "applied": false, + "approved": false, + "stage": 0, + "paid": null, + "expires": null, + "nickname": null +} \ No newline at end of file diff --git a/data/sponsors/.gitkeep b/data/sponsors/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py index 3ce0bdf..14da1f9 100644 --- a/main.py +++ b/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 * diff --git a/modules/commands/sponsorship.py b/modules/commands/sponsorship.py index e524e69..bde9db1 100644 --- a/modules/commands/sponsorship.py +++ b/modules/commands/sponsorship.py @@ -1 +1,23 @@ -from app import app \ No newline at end of file +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.") +# ============================================================================================================================== \ No newline at end of file