{"id":23907507,"url":"https://github.com/rezataheri01/telegram-store-bot","last_synced_at":"2026-02-16T14:35:05.867Z","repository":{"id":270489348,"uuid":"903919715","full_name":"RezaTaheri01/telegram-store-bot","owner":"RezaTaheri01","description":"A Telegram bot that serve as a digital store","archived":false,"fork":false,"pushed_at":"2025-03-02T13:50:47.000Z","size":684,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T23:43:25.352Z","etag":null,"topics":["digital-store","django","orm","polling","python","python-telegram-bot","telegram-bot"],"latest_commit_sha":null,"homepage":"https://t.me/gameStorePersiaBot","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RezaTaheri01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-15T22:15:35.000Z","updated_at":"2025-03-02T13:50:50.000Z","dependencies_parsed_at":"2025-01-23T10:23:09.403Z","dependency_job_id":"2fb16fd8-839e-4d23-8030-89e0f552086f","html_url":"https://github.com/RezaTaheri01/telegram-store-bot","commit_stats":null,"previous_names":["rezataheri01/telegram-store-bot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RezaTaheri01%2Ftelegram-store-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RezaTaheri01%2Ftelegram-store-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RezaTaheri01%2Ftelegram-store-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RezaTaheri01%2Ftelegram-store-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RezaTaheri01","download_url":"https://codeload.github.com/RezaTaheri01/telegram-store-bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249129747,"owners_count":21217429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["digital-store","django","orm","polling","python","python-telegram-bot","telegram-bot"],"created_at":"2025-01-05T03:12:26.966Z","updated_at":"2026-02-16T14:35:00.803Z","avatar_url":"https://github.com/RezaTaheri01.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telegram Bot with Django Integration 📢💻\n\nThis bot is a Python-based Telegram bot seamlessly integrated with a Django backend. It supports database management, payment handling, digital product selling, and dynamic user interactions.\n\n---\n\n## Features 🏢\n\n### Telegram Bot 📲\n- **Local Timezone**:\n  - Use **/timezone_set** to change your timezone.\n\n- **Multi-language Support**:\n  - Currently supports three languages, with the ability to add more.(There is a help comment in bot_settings.py)\n  - Users can change the language via the main menu.\n\n- **User Account Management**:\n  - Automatically creates user accounts if they don’t exist.\n  - Retrieves and displays user balance. 💳\n  - Displays user transaction history. 🔄\n\n- **Interactive Menu**:\n  - Provides options like **My Account**, **My Balance**, **Deposit**, and **Product Categories**.\n  - Includes inline keyboards for seamless navigation. 📝\n\n- **Payment Handling**:\n  - Generates unique payment links. 📡\n  - Processes payments via the Django backend.\n  - Updates user balance upon successful payment. ✔️\n\n- **Product Management**:\n  - Dynamically displays categories and products. 🛒\n  - Supports product purchases via balance deduction. 💸\n\n- **Customization**:\n  - In `bot_settings.py`, you can customize:\n    - Number of categories and products displayed per row.\n    - All text messages. 🖊️\n    - Primary and secondary languages.\n    - Inline button text and callback data.\n    - Payment link time limits. ⏳\n\n### Django Backend 📚\n\n- **Database Models**:\n  - `UserData`: Manages user account information. By default, the language is set to English (`en`). If your primary language isn’t English, update this in `bot_settings.py`.\n  - `Transaction`: Tracks payment transactions. 📋\n  - `Category`, `Product`, `ProductDetail`: Manages products and their details. 🛠️\n  - `ProductDetail`: The field detail that contain product info is encrypted 🔒 by ([django-encrypted-json-fields](https://pypi.org/project/django-encrypted-json-fields/))\n\n---\n\n## Installation ⚙️\n\n### Prerequisites 🔎\n\n1. Python 3.8 or higher 💾\n2. Django (latest version recommended) ⬆️\n3. PostgreSQL or any preferred database system configured in Django ([Learn More](https://docs.djangoproject.com/en/5.1/ref/databases/))\n4. Required libraries: `python-telegram-bot`, `asgiref`, `python-decouple`, etc.\n5. Dependencies are listed in `req.txt`\n\n### Setup Instructions 🔧\n\n1. **Clone the Repository**:\n   ```bash\n   git clone https://github.com/RezaTaheri01/telegram-store-bot.git\n   ```\n   ```bash\n   cd telegram-store-bot/telegram_store\n   ```\n\n2. **Install Dependencies**([virtual environment](https://realpython.com/python-virtual-environments-a-primer/#create-it) recommended):\n   ```bash\n   pip install -r req.txt\n   ```\n\n   \n3. **Configure the `.env` File**:  \n   Create a `.env` file in the project root and populate it with the following sample values:  \n   ```env\n   TOKEN=your-telegram-api-token   \n   SECRET_KEY=django-insecure-$kp!7e*2sv#%i%=qq(-#pspemkli#ruf_5i04(2q+eeoae_+2h\n   # Encrypting detail field with this key\n   ENCRYPTION_KEYS=6-QgONW6TUl5rt4Xq8u-wBwPcb15sIYS2CN6d69zueM=  \n   DEBUG=True\n   ALLOWED_HOSTS=localhost,127.0.0.1,your-domain.com\n   PAYMENT_DOMAIN=http://127.0.0.1:8000\n   ```\n\n4. **Migrate the Database** and  **Create Super User**:\n   ```bash\n   python manage.py makemigrations users payment products\n   ```\n   ```bash\n   python manage.py migrate\n   ```\n\n   ```bash\n   python manage.py createsuperuser\n   ```\n   \n\n5. **Run the Django Development Server**:\n   ```bash\n   python manage.py runserver\n   ```\n\n6. **Run the Telegram Bot**:\n   ```bash\n   python bot.py\n   ```\n\n---\n\n## Code Overview 🛠️\n\n### Telegram Bot 📲\n\n#### Key Features\n\n- **Core Functions**:\n  - `start_menu`: Displays the main menu. 🌐\n  - `change_language`: Allows users to change their language and updates the `UserData` language field. 🌎\n  - `check_create_account`: Automatically creates user accounts if they don’t exist. 🔧\n  - `user_balance`: Fetches and displays the user’s balance. 💳\n  - `deposit_money`: Initiates the deposit process and generates payment links. 💵\n  - `charge_account`: Updates the user’s balance upon successful payment. ✔️\n  - `get_name`: Retrieves names based on user language. 🌐\n  - `product_categories`: Dynamically displays product categories. 🛒\n  - `products`: Lists products under a selected category. 🍾\n  - `product_payment_detail`: Displays payment details for a product. 💸\n  - `payment`: Handles product purchases and balance deductions. 💰\n  - `get_user_language`: Retrieves the user’s language from a language cache or the database. 🌐\n\n#### Conversation States\n\n- `ENTER_AMOUNT`: Captures the deposit amount entered by the user. 💵\n\n#### Error Handling 🛠️\n\n- Logs all errors to `bot_logs.log`.\n- Notifies users of issues without disrupting the bot experience. ⚠️\n\n---\n\n### Payment Link Workflow 🔗\n\n- **Link Format**:\n  ```\n  PAYMENT_URL + /payment/confirm/?chat_id={chat_id}\u0026user_id={user_id}\u0026amount={amount}\u0026bot_link={bot_link}\u0026transaction={transaction}\n  ```\n- Redirects users to a Django view for payment processing.\n\n---\n\n## Usage 🚀\n\n1. **Start the Bot**:\n   - Send `/start` to the bot. 📢\n   - Explore options like **My Account**, **My Balance**, **Deposit**, or **Product Categories**.\n\n2. **Deposit Money**:\n   - Select the **Deposit** option from the menu. 💵\n   - Enter the desired amount.\n   - Click the payment link to complete the transaction. ✔️\n   - Verify the updated balance in your account. 💳\n\n3. **Browse Products**:\n   - Select **Product Categories** from the menu. 🛒\n   - Choose a category and view available products. 🍾\n   - Purchase a product using your balance. 💰\n\n---\n\n## Logs 🔍\n\n- All errors are logged in `bot_logs.log` with detailed messages. 📄\n\n---\n\n## Notes 📊\n\n- Ensure the Django server is running for smooth payment processing. ⚙️\n- Update the `PAYMENT_URL`, `ALLOWED_HOSTS` in the .env to match your server’s address when deploying. 🔗\n\n---\n\n## License 🔒\n\nThis project is licensed under the MIT License. See the [`LICENSE`](https://github.com/RezaTaheri01/telegram-store-bot/blob/main/LICENSE) file for more details. 🔖\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezataheri01%2Ftelegram-store-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frezataheri01%2Ftelegram-store-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezataheri01%2Ftelegram-store-bot/lists"}