Configurable Trial Duration
This commit is contained in:
1
.env
1
.env
@@ -9,6 +9,7 @@ REQUIRED_ROLE_IDS=333333333333333333,444444444444444444
|
||||
JELLYFIN_URL=http://127.0.0.1:8096
|
||||
JELLYFIN_API_KEY=your_jellyfin_api_key
|
||||
ENABLE_TRIAL_ACCOUNTS=false
|
||||
TRIAL_TIME=24 # In hours
|
||||
|
||||
# Jellyseerr
|
||||
JELLYSEERR_ENABLED=false
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# 1.0.9
|
||||
|
||||
- You can now configure trial account duration
|
||||
|
||||
# 1.0.8
|
||||
|
||||
- Fixed update message
|
||||
|
||||
@@ -58,7 +58,7 @@ Fill out values in the .env and you're good to go!
|
||||
|
||||
- `!link` <jellyfin_username> @user - Manually link accounts
|
||||
- `!unlink` @user - Manually unlink accounts
|
||||
- `!listvalidusers` - Show number of valid and invalid accounts
|
||||
- `!validusers` - Show number of valid and invalid accounts
|
||||
- `!cleanup` - Remove Jellyfin accounts from users without roles
|
||||
- `!lastcleanup` - See Last cleanup time, and time remaining before next cleanup
|
||||
- `!searchaccount` <jellyfin_username> - Find linked Discord user
|
||||
|
||||
13
app.py
13
app.py
@@ -34,6 +34,7 @@ SYNC_LOG_CHANNEL_ID = get_env_var("SYNC_LOG_CHANNEL_ID", int)
|
||||
JELLYFIN_URL = get_env_var("JELLYFIN_URL")
|
||||
JELLYFIN_API_KEY = get_env_var("JELLYFIN_API_KEY")
|
||||
ENABLE_TRIAL_ACCOUNTS = os.getenv("ENABLE_TRIAL_ACCOUNTS", "False").lower() == "true"
|
||||
TRIAL_TIME = int(os.getenv("TRIAL_TIME", 24))
|
||||
|
||||
JELLYSEERR_ENABLED = os.getenv("JELLYSEERR_ENABLED", "false").lower() == "true"
|
||||
JELLYSEERR_URL = os.getenv("JELLYSEERR_URL", "").rstrip("/")
|
||||
@@ -919,7 +920,7 @@ async def refreshjfakey(ctx):
|
||||
|
||||
@bot.command()
|
||||
async def trialaccount(ctx, username: str = None, password: str = None):
|
||||
"""Create a 24-hour trial Jellyfin account. DM-only, one-time per user."""
|
||||
f"""Create a {TRIAL_TIME}-hour trial Jellyfin account. DM-only, one-time per user."""
|
||||
log_event(f"trialaccount invoked by {ctx.author}")
|
||||
|
||||
# Ensure trial accounts are enabled
|
||||
@@ -987,7 +988,7 @@ async def trialaccount(ctx, username: str = None, password: str = None):
|
||||
cur.close()
|
||||
conn.close()
|
||||
|
||||
await ctx.send(f"✅ Trial Jellyfin account **{username}** created! It will expire in 24 hours.\n🌐 Login here: {JELLYFIN_URL}")
|
||||
await ctx.send(f"✅ Trial Jellyfin account **{username}** created! It will expire in {TRIAL_TIME} hours.\n🌐 Login here: {JELLYFIN_URL}")
|
||||
log_event(f"Trial account created for {ctx.author} ({username})")
|
||||
else:
|
||||
cur.close()
|
||||
@@ -1223,7 +1224,7 @@ async def cleanup(ctx):
|
||||
await ctx.send("✅ Cleanup complete.")
|
||||
|
||||
@bot.command()
|
||||
async def listvalidusers(ctx):
|
||||
async def validusers(ctx):
|
||||
"""Admin-only: List how many registered users have a valid role."""
|
||||
if not has_admin_role(ctx.author):
|
||||
await ctx.send("❌ You don’t have permission to use this command.")
|
||||
@@ -1791,7 +1792,7 @@ async def help_command(ctx):
|
||||
f"`{PREFIX}shows2watch` - Lists 5 random show suggestions from the Jellyfin Library"
|
||||
]
|
||||
if ENABLE_TRIAL_ACCOUNTS:
|
||||
user_cmds.append(f"`{PREFIX}trialaccount <username> <password>` - Create a 24-hour trial Jellyfin account")
|
||||
user_cmds.append(f"`{PREFIX}trialaccount <username> <password>` - Create a {TRIAL_TIME}-hour trial Jellyfin account")
|
||||
|
||||
embed.add_field(name="🎬 Jellyfin Commands", value="\n".join(user_cmds), inline=False)
|
||||
|
||||
@@ -1811,7 +1812,7 @@ async def help_command(ctx):
|
||||
admin_cmds = [
|
||||
link_command,
|
||||
f"`{PREFIX}unlink @user` - Manually unlink accounts",
|
||||
f"`{PREFIX}listvalidusers` - Show number of valid and invalid accounts",
|
||||
f"`{PREFIX}validusers` - Show number of valid and invalid accounts",
|
||||
f"`{PREFIX}cleanup` - Remove Jellyfin accounts from users without roles",
|
||||
f"`{PREFIX}lastcleanup` - See last cleanup time and time remaining",
|
||||
f"`{PREFIX}searchaccount <jellyfin_username>` - Find linked Discord user",
|
||||
@@ -1938,7 +1939,7 @@ async def cleanup_task():
|
||||
else:
|
||||
created_at_local = created_at_utc.astimezone(LOCAL_TZ)
|
||||
|
||||
if now_local > created_at_local + datetime.timedelta(hours=24):
|
||||
if now_local > created_at_local + datetime.timedelta(hours=TRIAL_TIME):
|
||||
# Delete trial Jellyfin user
|
||||
try:
|
||||
delete_jellyfin_user(trial.get("jellyfin_username"))
|
||||
|
||||
Reference in New Issue
Block a user