Spaces:
Running
Running
Hermes Agent commited on
Commit ·
2438b28
1
Parent(s): 18afab5
docs: record Flash File payment & subscription architecture plan
Browse files- docs/FLASH_FILE_PAYMENT_PLAN.md +210 -0
docs/FLASH_FILE_PAYMENT_PLAN.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Architectural Plan: Flash File Dual-Mode Access & ₹10/Month Subscription Engine
|
| 2 |
+
|
| 3 |
+
> [!NOTE]
|
| 4 |
+
> **Environment Guardrail**: This entire system remains strictly dormant when `PAYMENT` (or `Payment`) is unset or `False`. When disabled, the bot operates with **zero modifications** to its current free streaming pipeline. Only when `PAYMENT=True` is explicitly configured does the dual-mode gateway activate.
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
## 1. System Architecture & Dual Flow
|
| 9 |
+
|
| 10 |
+
```mermaid
|
| 11 |
+
flowchart TD
|
| 12 |
+
Start([User sends media to @flashfilezbot]) --> CheckEnv{Var.PAYMENT_ENABLED == True?}
|
| 13 |
+
CheckEnv -- No (Default) --> StandardFlow[Normal Instant FileToLink Streaming]
|
| 14 |
+
CheckEnv -- Yes --> CheckAuth{Is Owner, Admin, or Active Subscriber?}
|
| 15 |
+
|
| 16 |
+
CheckAuth -- Yes --> StandardFlow
|
| 17 |
+
CheckAuth -- No --> PaywallCard[Render Professional Subscription Paywall]
|
| 18 |
+
|
| 19 |
+
PaywallCard --> ActionA[User taps 'Pay ₹10 via GPay']
|
| 20 |
+
PaywallCard --> ActionB[User taps 'Request 1-Time Access from Admin']
|
| 21 |
+
|
| 22 |
+
ActionA --> DirectGPay[Launches GPay / PhonePe with UPI URI]
|
| 23 |
+
DirectGPay --> UserConfirms[User taps 'I Have Paid']
|
| 24 |
+
UserConfirms --> AdminSubNotification[Admin Channel: Payment Verification Card]
|
| 25 |
+
AdminSubNotification --> AdminApproveSub{Admin taps Approve 30-Day Plan}
|
| 26 |
+
AdminApproveSub -- Yes --> SubActivated[Account Unlocked for 30 Days + User Alerted]
|
| 27 |
+
AdminApproveSub -- No --> SubRejected[User Notified of Rejection]
|
| 28 |
+
|
| 29 |
+
ActionB --> AdminFileNotification[Admin Channel: 1-Time File Request Card]
|
| 30 |
+
AdminFileNotification --> AdminFileDecision{Admin Decision}
|
| 31 |
+
AdminFileDecision -- Grant 1-Time Link --> DeliverFileLink[Delivers Specific Stream Link + Upgrade CTA]
|
| 32 |
+
AdminFileDecision -- Grant 24h Pass --> GrantDayPass[Unlocks All Files for 24 Hours]
|
| 33 |
+
AdminFileDecision -- Reject --> NotifyFileRejection[User Notified]
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## 2. Configuration & Safe Fallback (`Thunder/vars.py`)
|
| 39 |
+
|
| 40 |
+
All payment configurations are isolated with safe defaults:
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
# Payment & Subscription Configuration
|
| 44 |
+
PAYMENT_ENABLED: bool = str_to_bool(os.getenv("PAYMENT", os.getenv("Payment", "False")))
|
| 45 |
+
SUB_PRICE: int = int(os.getenv("SUB_PRICE", "10"))
|
| 46 |
+
UPI_ID: str = os.getenv("UPI_ID", "jishnupg2005-2@okaxis").strip()
|
| 47 |
+
UPI_NAME: str = os.getenv("UPI_NAME", "Flash File").strip()
|
| 48 |
+
ADMIN_CHANNEL: int = int(os.getenv("ADMIN_CHANNEL", os.getenv("PAYMENT_LOG_CHANNEL", "0")))
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
> [!IMPORTANT]
|
| 52 |
+
> If `ADMIN_CHANNEL` is `0` or unset, approval cards automatically route directly to the Bot Owner's private chat (`Var.OWNER_ID`), ensuring 100% operational reliability with zero mandatory channel setup.
|
| 53 |
+
|
| 54 |
+
---
|
| 55 |
+
|
| 56 |
+
## 3. Database Schema & Persistence (`Thunder/utils/database.py`)
|
| 57 |
+
|
| 58 |
+
A new dedicated collection `subscriptions` in MongoDB tracks active memberships:
|
| 59 |
+
|
| 60 |
+
```json
|
| 61 |
+
{
|
| 62 |
+
"_id": 123456789,
|
| 63 |
+
"user_name": "Jishnu",
|
| 64 |
+
"plan": "premium_monthly",
|
| 65 |
+
"amount_paid": 10,
|
| 66 |
+
"subscribed_at": "2026-10-31T13:20:00Z",
|
| 67 |
+
"expires_at": "2026-11-30T13:20:00Z",
|
| 68 |
+
"is_active": true,
|
| 69 |
+
"payment_method": "UPI_GPay",
|
| 70 |
+
"history": [
|
| 71 |
+
{
|
| 72 |
+
"tx_id": "SUB-123456789-1730380800",
|
| 73 |
+
"granted_by": "admin",
|
| 74 |
+
"days": 30,
|
| 75 |
+
"date": "2026-10-31T13:20:00Z"
|
| 76 |
+
}
|
| 77 |
+
]
|
| 78 |
+
}
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### Key DB Methods
|
| 82 |
+
1. `is_subscribed(user_id: int) -> bool`: Checks whether user has an active, non-expired subscription.
|
| 83 |
+
2. `get_subscription(user_id: int) -> Optional[dict]`: Retrieves expiration date and remaining days.
|
| 84 |
+
3. `add_subscription(user_id: int, days: int = 30) -> datetime`: Extends or creates a subscription from current time (or extends existing active expiry).
|
| 85 |
+
4. `remove_subscription(user_id: int) -> bool`: Immediately revokes access.
|
| 86 |
+
5. `get_subscribers_summary() -> dict`: Counts active paying subscribers and calculated monthly revenue.
|
| 87 |
+
|
| 88 |
+
---
|
| 89 |
+
|
| 90 |
+
## 4. User Interface & Professional Typography
|
| 91 |
+
|
| 92 |
+
### A. The User Paywall Message
|
| 93 |
+
Presented when an unsubscribed user sends a media file in private chat:
|
| 94 |
+
|
| 95 |
+
```markdown
|
| 96 |
+
✨ **Flash File Premium Access** ✨
|
| 97 |
+
|
| 98 |
+
📁 **File:** `Deadpool & Wolverine (2024).mkv`
|
| 99 |
+
📦 **Size:** `1.84 GB` | ⏱️ **Duration:** `02:07:31`
|
| 100 |
+
|
| 101 |
+
━━━━━━━━━━━━━━━━━━━━━━━━
|
| 102 |
+
To access high-speed streaming, unlimited file conversions, and direct multi-thread downloads, activate your **Flash File Pass**.
|
| 103 |
+
|
| 104 |
+
💎 **Monthly Membership:** **₹10 / Month**
|
| 105 |
+
• Unlimited video streaming & zero buffer delay
|
| 106 |
+
• Dedicated high-bandwidth cloud workers
|
| 107 |
+
• Batch conversions & permanent links
|
| 108 |
+
|
| 109 |
+
━━━━━━━━━━━━━━━━━━━━━━━━
|
| 110 |
+
👇 **Select an option below to proceed:**
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
**Inline Buttons:**
|
| 114 |
+
```
|
| 115 |
+
[ 📱 Pay ₹10 via Google Pay / UPI ] (UPI Intent Deep Link)
|
| 116 |
+
[ 📩 Request 1-Time Access from Admin ] (Triggers Admin Card)
|
| 117 |
+
[ ⚡ I Have Completed Payment ] (Triggers Verification Notification)
|
| 118 |
+
[ ℹ️ Learn More & Help ]
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
### B. UPI Deep Link Specification
|
| 122 |
+
The payment button uses the standard NPCI UPI Intent protocol:
|
| 123 |
+
```
|
| 124 |
+
upi://pay?pa=jishnupg2005-2@okaxis&pn=Flash%20File&am=10&cu=INR&tn=FlashFile_Sub_{user_id}
|
| 125 |
+
```
|
| 126 |
+
* On Android: Directly invokes the UPI App Selector (Google Pay, PhonePe, Paytm, BHIM, Cred) with the receiver name, UPI ID, and exact ₹10 amount locked in.
|
| 127 |
+
* Note contains `FlashFile_Sub_{user_id}` for instant cross-referencing.
|
| 128 |
+
|
| 129 |
+
---
|
| 130 |
+
|
| 131 |
+
## 5. Admin Management Cards (Telegram Channel / Owner DM)
|
| 132 |
+
|
| 133 |
+
### Card A: Subscription Payment Approval Card
|
| 134 |
+
Fired when a user taps *"⚡ I Have Completed Payment"*:
|
| 135 |
+
|
| 136 |
+
```markdown
|
| 137 |
+
💎 **New Subscription Payment Request**
|
| 138 |
+
|
| 139 |
+
👤 **Subscriber:** [Jishnu](tg://user?id=123456789)
|
| 140 |
+
🆔 **User ID:** `123456789`
|
| 141 |
+
💰 **Plan:** **₹10.00 / 30 Days**
|
| 142 |
+
🏦 **UPI Reference:** `FlashFile_Sub_123456789`
|
| 143 |
+
🕒 **Submitted:** `31 Oct 2026, 01:25 PM UTC`
|
| 144 |
+
|
| 145 |
+
━━━━━━━━━━━━━━━━━━━━━━━━
|
| 146 |
+
Verify the credit in your Google Pay account, then select an action:
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
**Action Buttons:**
|
| 150 |
+
```
|
| 151 |
+
[ ✅ Approve (30 Days Pass) ] [ 🎁 Grant 7 Days Trial ]
|
| 152 |
+
[ ❌ Decline Request ] [ 👤 View Profile ]
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
* Clicking `[ ✅ Approve (30 Days Pass) ]`:
|
| 156 |
+
1. Updates the message in the channel to: `✅ Approved by Admin (30 Days granted to Jishnu)`.
|
| 157 |
+
2. Extends user's DB record by 30 days.
|
| 158 |
+
3. Sends an instant celebration alert to the user:
|
| 159 |
+
> *"🎉 **Payment Verified!** Your 30-Day Flash File Premium membership is now active until **30-Nov-2026**. Enjoy unlimited streaming!"*
|
| 160 |
+
|
| 161 |
+
---
|
| 162 |
+
|
| 163 |
+
### Card B: 1-Time Temporary File Access Card
|
| 164 |
+
Fired when the user requests a temporary pass for a specific movie:
|
| 165 |
+
|
| 166 |
+
```markdown
|
| 167 |
+
🎬 **Temporary File Access Request**
|
| 168 |
+
|
| 169 |
+
👤 **Requester:** [Alex](tg://user?id=987654321) (`@alex`)
|
| 170 |
+
🆔 **User ID:** `987654321`
|
| 171 |
+
📁 **Media:** `Interstellar (2014) IMAX 1080p.mkv`
|
| 172 |
+
📦 **Size:** `2.45 GB`
|
| 173 |
+
|
| 174 |
+
━━━━━━━━━━━━━━━━━━━━━━━━
|
| 175 |
+
Authorize free link delivery or invite them to subscribe:
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
**Action Buttons:**
|
| 179 |
+
```
|
| 180 |
+
[ 🚀 Grant This File Only ] [ 🎁 Grant 24h Free Pass ]
|
| 181 |
+
[ ❌ Reject Request ]
|
| 182 |
+
```
|
| 183 |
+
|
| 184 |
+
* Clicking `[ 🚀 Grant This File Only ]`:
|
| 185 |
+
1. The bot forwards the media to the bin channel, generates the canonical streaming & download links, and sends them directly to the user with an upgrade banner:
|
| 186 |
+
> *"🎁 **Free Access Granted!** Here is your stream link for **Interstellar (2014)**.\n\nEnjoy the movie! To stream all movies without waiting for admin approval, [Subscribe for ₹10/month]."*
|
| 187 |
+
2. Updates admin card: `🚀 Granted 1-Time Access by Admin`.
|
| 188 |
+
|
| 189 |
+
---
|
| 190 |
+
|
| 191 |
+
## 6. Admin & User Command Suite
|
| 192 |
+
|
| 193 |
+
| Command | Permission | Description |
|
| 194 |
+
| :--- | :--- | :--- |
|
| 195 |
+
| `/plan` or `/myplan` | All Users | Displays current subscription status, plan name, and exact days remaining. |
|
| 196 |
+
| `/subscribe` or `/buy` | All Users | Opens the ₹10 subscription dialog with the instant GPay payment link. |
|
| 197 |
+
| `/addsub <user_id> [days]` | Owner / Admin | Manually assigns or extends a subscription (default: 30 days). |
|
| 198 |
+
| `/remsub <user_id>` | Owner / Admin | Immediately cancels and removes a user's subscription. |
|
| 199 |
+
| `/subscribers` | Owner / Admin | Shows total active paying members, expiring soon counts, and total revenue. |
|
| 200 |
+
|
| 201 |
+
---
|
| 202 |
+
|
| 203 |
+
## 7. Implementation Checklist
|
| 204 |
+
|
| 205 |
+
- [ ] **Step 1:** Add environment variables & types in [`Thunder/vars.py`](file:///data/antigravity/Jellyfin/Thunder/vars.py) (`PAYMENT_ENABLED`, `SUB_PRICE`, `UPI_ID`, `ADMIN_CHANNEL`).
|
| 206 |
+
- [ ] **Step 2:** Implement subscription methods in [`Thunder/utils/database.py`](file:///data/antigravity/Jellyfin/Thunder/utils/database.py).
|
| 207 |
+
- [ ] **Step 3:** Create dedicated plugin [`Thunder/bot/plugins/subscription.py`](file:///data/antigravity/Jellyfin/Thunder/bot/plugins/subscription.py) containing all commands, callbacks, and notification dispatchers.
|
| 208 |
+
- [ ] **Step 4:** Integrate gating logic in [`Thunder/bot/plugins/stream.py`](file:///data/antigravity/Jellyfin/Thunder/bot/plugins/stream.py) (strict zero-change bypass if `PAYMENT_ENABLED == False`).
|
| 209 |
+
- [ ] **Step 5:** Add professional notification templates in [`Thunder/utils/messages.py`](file:///data/antigravity/Jellyfin/Thunder/utils/messages.py).
|
| 210 |
+
- [ ] **Step 6:** Validate with unit tests and push to GitHub and Hugging Face spaces.
|