# lakki99/save-restricted-content architecture

> Architecture diagram of the GitHub repository lakki99/save-restricted-content, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lakki99/save-restricted-content
- Repository: https://github.com/lakki99/save-restricted-content

## Overview

This is a Telegram bot that accepts links to restricted posts and sends the referenced content to the requester. The main workflow parses a post or range, obtains a logged-in user session (or configured account), retrieves posts, then downloads and resends their content. Login/logout and admin broadcasts are separate capabilities. The sampled handler excerpt omits some retrieval and dispatch code, so links show only supported interactions; the README documents usage modes not fully visible in the excerpt.

Main entry points: [`bot.py`](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/bot.py) (Bot client), [`TechVJ/start.py`](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/start.py) (Command and link handlers), [`TechVJ/generate.py`](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/generate.py) (Session login), [`TechVJ/broadcast.py`](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/broadcast.py) (Broadcast handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_bot["Bot client<br/>[bot.py]"]
  node_start["Command and link handlers<br/>[start.py]"]
  node_help["Help content<br/>[strings.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_content["Content retrieval"]
  node_content_flow["Link and media handling<br/>[start.py]"]
end

subgraph group_accounts["Accounts and users"]
  node_sessions["Session login<br/>[generate.py]"]
  node_database[("User and session store<br/>[db.py]")]
end

subgraph group_admin["Administration"]
  node_broadcast["Broadcast handler<br/>[broadcast.py]"]
end

node_user(("Telegram user"))
node_admin_user(("Bot admin"))
node_telegram["Telegram"]

node_user -->|"sends commands or links"| node_bot
node_admin_user -->|"sends broadcast command"| node_bot
node_bot -->|"dispatches plugins"| node_start
node_start -->|"uses help text"| node_help
node_start -->|"checks and registers users"| node_database
node_start -->|"handles post links"| node_content_flow
node_content_flow -->|"reads session"| node_database
node_content_flow -->|"joins chats and retrieves media"| node_telegram
node_content_flow -->|"sends content and status"| node_user
node_user -->|"requests login or logout"| node_sessions
node_sessions -->|"authenticates account"| node_telegram
node_sessions -->|"reads and stores session"| node_database
node_bot -->|"dispatches plugins"| node_broadcast
node_broadcast -->|"lists and removes users"| node_database
node_broadcast -->|"copies messages to users"| node_telegram
node_bot -->|"reads credentials"| node_config
node_sessions -->|"reads API credentials"| node_config
node_broadcast -->|"reads admin IDs"| node_config

click node_bot "https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/bot.py"
click node_start "https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/start.py"
click node_help "https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/strings.py"
click node_content_flow "https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/start.py"
click node_sessions "https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/generate.py"
click node_database "https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/database/db.py"
click node_broadcast "https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/broadcast.py"
click node_config "https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/config.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bot,node_start,node_help,node_config,node_user toneBlue
class node_content_flow toneAmber
class node_sessions,node_database toneMint
class node_broadcast toneRose
class node_admin_user,node_telegram toneIndigo
```

## Components

### Bot runtime

- [Bot client](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/bot.py): `bot.py`
- [Command and link handlers](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/start.py): `TechVJ/start.py`
- [Help content](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/strings.py): `TechVJ/strings.py`
- [Runtime configuration](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/config.py): `config.py`

### Content retrieval

- [Link and media handling](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/start.py): `TechVJ/start.py`

### Accounts and users

- [Session login](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/generate.py): `TechVJ/generate.py`
- [User and session store](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/database/db.py): `database/db.py`

### Administration

- [Broadcast handler](https://github.com/lakki99/save-restricted-content/blob/TechVJ-Login/TechVJ/broadcast.py): `TechVJ/broadcast.py`

### Other components

- **Telegram user**
- **Bot admin**
- **Telegram**

## Connections

- Telegram user → Bot client: sends commands or links
- Bot admin → Bot client: sends broadcast command
- Bot client → Command and link handlers: dispatches plugins
- Command and link handlers → Help content: uses help text
- Command and link handlers → User and session store: checks and registers users
- Command and link handlers → Link and media handling: handles post links
- Link and media handling → User and session store: reads session
- Link and media handling → Telegram: joins chats and retrieves media
- Link and media handling → Telegram user: sends content and status
- Telegram user → Session login: requests login or logout
- Session login → Telegram: authenticates account
- Session login → User and session store: reads and stores session
- Bot client → Broadcast handler: dispatches plugins
- Broadcast handler → User and session store: lists and removes users
- Broadcast handler → Telegram: copies messages to users
- Bot client → Runtime configuration: reads credentials
- Session login → Runtime configuration: reads API credentials
- Broadcast handler → Runtime configuration: reads admin IDs
