Add referral system and user balance tracking
Introduce balance field to User model with Alembic migration. Add referral menu, admin /refpay command, and deep link sharing. Update Dockerfile to multi-stage build and add Postgres service to compose. Fix deep link parsing logic and conditional proxy initialization.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import urllib.parse
|
||||
from typing import Optional
|
||||
from random import choice
|
||||
from datetime import datetime, timedelta, timezone
|
||||
@@ -175,10 +176,15 @@ def format_subscription_link(link: Optional[str] = None):
|
||||
return f"<code>{link or '...'}</code>"
|
||||
|
||||
|
||||
def format_share_deep_link(link: str):
|
||||
return f"https://t.me/share/url/?url={urllib.parse.quote_plus(link)}"
|
||||
|
||||
|
||||
def format_support_subscription(
|
||||
subscription: SubscriptionPlan,
|
||||
full_name: str,
|
||||
user_id: int,
|
||||
balance: int,
|
||||
username: Optional[str] = None,
|
||||
) -> str:
|
||||
username = format_username(username)
|
||||
@@ -196,6 +202,7 @@ def format_support_subscription(
|
||||
devices=subscription.devices,
|
||||
whitelist_description=whitelist_description,
|
||||
price=calculate_price(subscription),
|
||||
balance=balance,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user