Spaces:
Running
Running
Delete credit_card
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- credit_card/.gitattributes +0 -35
- credit_card/.gitignore +0 -34
- credit_card/32982-360.mp4 +0 -3
- credit_card/DEPLOY_GUIDE.md +0 -55
- credit_card/DEPLOY_INSTRUCTIONS.md +0 -34
- credit_card/Dockerfile +0 -44
- credit_card/README.md +0 -0
- credit_card/admins/__init__.py +0 -0
- credit_card/admins/__pycache__/__init__.cpython-310.pyc +0 -0
- credit_card/admins/__pycache__/__init__.cpython-312.pyc +0 -0
- credit_card/admins/__pycache__/__init__.cpython-37.pyc +0 -0
- credit_card/admins/__pycache__/admin.cpython-310.pyc +0 -0
- credit_card/admins/__pycache__/admin.cpython-312.pyc +0 -0
- credit_card/admins/__pycache__/admin.cpython-37.pyc +0 -0
- credit_card/admins/__pycache__/apps.cpython-310.pyc +0 -0
- credit_card/admins/__pycache__/apps.cpython-312.pyc +0 -0
- credit_card/admins/__pycache__/apps.cpython-37.pyc +0 -0
- credit_card/admins/__pycache__/models.cpython-310.pyc +0 -0
- credit_card/admins/__pycache__/models.cpython-312.pyc +0 -0
- credit_card/admins/__pycache__/models.cpython-37.pyc +0 -0
- credit_card/admins/__pycache__/views.cpython-310.pyc +0 -0
- credit_card/admins/__pycache__/views.cpython-312.pyc +0 -0
- credit_card/admins/__pycache__/views.cpython-37.pyc +0 -0
- credit_card/admins/admin.py +0 -3
- credit_card/admins/apps.py +0 -6
- credit_card/admins/management/__init__.py +0 -0
- credit_card/admins/management/__pycache__/__init__.cpython-312.pyc +0 -0
- credit_card/admins/management/commands/__init__.py +0 -0
- credit_card/admins/management/commands/__pycache__/__init__.cpython-312.pyc +0 -0
- credit_card/admins/management/commands/__pycache__/run_telegram_bot.cpython-312.pyc +0 -0
- credit_card/admins/management/commands/run_telegram_bot.py +0 -188
- credit_card/admins/migrations/__init__.py +0 -0
- credit_card/admins/migrations/__pycache__/__init__.cpython-310.pyc +0 -0
- credit_card/admins/migrations/__pycache__/__init__.cpython-312.pyc +0 -0
- credit_card/admins/migrations/__pycache__/__init__.cpython-37.pyc +0 -0
- credit_card/admins/models.py +0 -3
- credit_card/admins/tests.py +0 -3
- credit_card/admins/views.py +0 -60
- credit_card/credit_card/__init__.py +0 -0
- credit_card/credit_card/__pycache__/__init__.cpython-310.pyc +0 -0
- credit_card/credit_card/__pycache__/__init__.cpython-312.pyc +0 -0
- credit_card/credit_card/__pycache__/__init__.cpython-37.pyc +0 -0
- credit_card/credit_card/__pycache__/settings.cpython-310.pyc +0 -0
- credit_card/credit_card/__pycache__/settings.cpython-312.pyc +0 -0
- credit_card/credit_card/__pycache__/settings.cpython-37.pyc +0 -0
- credit_card/credit_card/__pycache__/urls.cpython-310.pyc +0 -0
- credit_card/credit_card/__pycache__/urls.cpython-312.pyc +0 -0
- credit_card/credit_card/__pycache__/urls.cpython-37.pyc +0 -0
- credit_card/credit_card/__pycache__/views.cpython-310.pyc +0 -0
- credit_card/credit_card/__pycache__/views.cpython-312.pyc +0 -0
credit_card/.gitattributes
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/.gitignore
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
# Python
|
| 2 |
-
*.pyc
|
| 3 |
-
*.pyo
|
| 4 |
-
*.pyd
|
| 5 |
-
__pycache__/
|
| 6 |
-
*.so
|
| 7 |
-
*.dll
|
| 8 |
-
*.dylib
|
| 9 |
-
|
| 10 |
-
# Django
|
| 11 |
-
*.log
|
| 12 |
-
local_settings.py
|
| 13 |
-
# db.sqlite3
|
| 14 |
-
db.sqlite3-journal
|
| 15 |
-
media/
|
| 16 |
-
|
| 17 |
-
# Environments
|
| 18 |
-
.env
|
| 19 |
-
.venv
|
| 20 |
-
env/
|
| 21 |
-
venv/
|
| 22 |
-
ENV/
|
| 23 |
-
env.bak/
|
| 24 |
-
venv.bak/
|
| 25 |
-
|
| 26 |
-
# Editors
|
| 27 |
-
.vscode/
|
| 28 |
-
.idea/
|
| 29 |
-
*.sublime-project
|
| 30 |
-
*.sublime-workspace
|
| 31 |
-
|
| 32 |
-
# OS
|
| 33 |
-
.DS_Store
|
| 34 |
-
Thumbs.db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/32982-360.mp4
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a51ce85f68f0673a83e948098d60de37ca3a4784afadbfadf1024f067e0e852d
|
| 3 |
-
size 1050131
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/DEPLOY_GUIDE.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
# 🚀 Deployment Guide: Hugging Face Spaces (Free Alternative)
|
| 3 |
-
|
| 4 |
-
Since Vercel cannot handle large Machine Learning apps (limit is 250MB, your app is >1GB), and proper "Background Worker" hosting usually costs money on Render/Heroku, the best **Free** alternative for ML demos is **Hugging Face Spaces**.
|
| 5 |
-
|
| 6 |
-
### Why Hugging Face Spaces?
|
| 7 |
-
* **Completely Free**: 16GB RAM, 2 vCPU.
|
| 8 |
-
* **Support for Docker**: Can run your custom environment.
|
| 9 |
-
* **Good for ML**: Designed specifically for apps like yours (TensorFlow, PyTorch).
|
| 10 |
-
|
| 11 |
-
---
|
| 12 |
-
|
| 13 |
-
## Step 1: Create the Space
|
| 14 |
-
1. Go to [huggingface.co/spaces](https://huggingface.co/spaces).
|
| 15 |
-
2. Click **Create new Space**.
|
| 16 |
-
3. **Name**: `fraud-detection-app` (or similar).
|
| 17 |
-
4. **License**: Openrail or MIT.
|
| 18 |
-
5. **SDK**: Select **Docker**.
|
| 19 |
-
6. **Public/Private**: Public.
|
| 20 |
-
|
| 21 |
-
## Step 2: Upload Your Code
|
| 22 |
-
You can upload your code directly via the browser or use git.
|
| 23 |
-
1. On the Space page, click **"Files"**.
|
| 24 |
-
2. Click **"Add file"** -> **"Upload files"**.
|
| 25 |
-
3. Upload **ALL** your project files (the folders `credit_card`, `admins`, `users`, `media`, `templates` and files `manage.py`, `requirements.txt`, `db.sqlite3`).
|
| 26 |
-
* *Important*: Make sure you upload the `Dockerfile` I created for you.
|
| 27 |
-
|
| 28 |
-
## Step 3: Configure Permissions
|
| 29 |
-
Hugging Face Spaces limits port 8000 by default. My `Dockerfile` is already configured for this, but we need to ensure the Telegram Bot starts.
|
| 30 |
-
|
| 31 |
-
### Update Dockerfile for Bot + Web
|
| 32 |
-
Change the `CMD` in your `Dockerfile` to run BOTH the server and the bot.
|
| 33 |
-
(I have updated the Dockerfile below in the chat, please enable it).
|
| 34 |
-
|
| 35 |
-
## Step 4: Environment Variables
|
| 36 |
-
1. Go to **Settings** in your Space.
|
| 37 |
-
2. Scroll to **"Variables and secrets"**.
|
| 38 |
-
3. Add the following:
|
| 39 |
-
* `SECRET_KEY`: (Your Django secret key)
|
| 40 |
-
* `DEBUG`: `False`
|
| 41 |
-
|
| 42 |
-
---
|
| 43 |
-
|
| 44 |
-
## ⚠️ Important Limitations of Cloud Deployment
|
| 45 |
-
**The "Remote Control" features will STOP working.**
|
| 46 |
-
* Currently, when you click "Open Admin (Host)" on Telegram, it opens the browser on your **laptop**.
|
| 47 |
-
* If you deploy to the cloud, clicking that button will try to open a browser on the **Cloud Server** (which has no screen). You will not see anything happen.
|
| 48 |
-
* **Recommendation**: If you built this bot specifically to control your laptop, **DO NOT DEPLOY**. Use `ngrok` instead.
|
| 49 |
-
|
| 50 |
-
## Alternative: ngrok (Best for Remote Control)
|
| 51 |
-
If you want to access your app from your phone but keep it running on your laptop (so "Open Browser" works):
|
| 52 |
-
1. Download **ngrok** from [ngrok.com](https://ngrok.com).
|
| 53 |
-
2. Run: `ngrok http 8000`
|
| 54 |
-
3. It gives you a URL like `https://xyz.ngrok-free.app`.
|
| 55 |
-
4. Update your `run_telegram_bot.py` with this new URL.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/DEPLOY_INSTRUCTIONS.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
# 🚀 Deployment Instructions for Hugging Face
|
| 3 |
-
|
| 4 |
-
Your project is now fully configured for a free deployment that keeps your Telegram bot running 24/7!
|
| 5 |
-
|
| 6 |
-
## Credentials
|
| 7 |
-
- **Admin Login**: `admin`
|
| 8 |
-
- **Password**: `admin123`
|
| 9 |
-
|
| 10 |
-
## Step 1: Create a Space on Hugging Face
|
| 11 |
-
1. Go to [huggingface.co/new-space](https://huggingface.co/new-space) (Sign up if needed).
|
| 12 |
-
2. **Space Name**: `fraud-detection-bot` (or similar).
|
| 13 |
-
3. **License**: Select any (e.g., Apache 2.0).
|
| 14 |
-
4. **SDK**: Select **Docker** (Crucial step!).
|
| 15 |
-
5. **Space Hardware**: Keep "CPU basic (Free)".
|
| 16 |
-
6. Click **Create Space**.
|
| 17 |
-
|
| 18 |
-
## Step 2: Upload Your Code
|
| 19 |
-
1. Once created, you will see a page with instructions.
|
| 20 |
-
2. Click on the **Files** tab at the top.
|
| 21 |
-
3. Click **Add file** -> **Upload files**.
|
| 22 |
-
4. Drag and drop **ALL the files** from your `credit_card` folder into the upload area.
|
| 23 |
-
- Make sure to include: `Dockerfile`, `requirements.txt`, `manage.py`, `start.sh`, `db.sqlite3`, and all folders (`credit_card`, `admins`, `users`, `templates`).
|
| 24 |
-
5. In the "Commit changes" box, type "Initial deploy" and click **Commit changes to main**.
|
| 25 |
-
|
| 26 |
-
## Step 3: Wait for Build
|
| 27 |
-
1. Click the **App** tab.
|
| 28 |
-
2. You will see "Building". Wait a few minutes.
|
| 29 |
-
3. Once it says "Running", your app is live!
|
| 30 |
-
4. Your Telegram bot will automatically start working.
|
| 31 |
-
|
| 32 |
-
## Troubleshooting
|
| 33 |
-
- If the build fails, check the "Logs" tab for errors.
|
| 34 |
-
- If the bot doesn't reply, check if the token is correct in your code or add it as a "Secret" in the Space settings (Settings -> Repository secrets -> New secret).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/Dockerfile
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
# Use an official Python runtime as a parent image
|
| 3 |
-
# Using 3.8 based on TensorFlow 2.4 compatibility
|
| 4 |
-
FROM python:3.8-slim
|
| 5 |
-
|
| 6 |
-
# Set environment variables
|
| 7 |
-
ENV PYTHONDONTWRITEBYTECODE 1
|
| 8 |
-
ENV PYTHONUNBUFFERED 1
|
| 9 |
-
|
| 10 |
-
# Set work directory
|
| 11 |
-
WORKDIR /app
|
| 12 |
-
|
| 13 |
-
# Install system dependencies
|
| 14 |
-
# libgl1-mesa-glx is often needed for opencv (cv2)
|
| 15 |
-
# gcc and python3-dev are needed for building some python packages
|
| 16 |
-
RUN apt-get update && apt-get install -y \
|
| 17 |
-
gcc \
|
| 18 |
-
libgl1-mesa-glx \
|
| 19 |
-
libglib2.0-0 \
|
| 20 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 21 |
-
|
| 22 |
-
# Install python dependencies
|
| 23 |
-
COPY requirements.txt /app/
|
| 24 |
-
RUN pip install --upgrade pip
|
| 25 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
-
|
| 27 |
-
# Copy project
|
| 28 |
-
COPY . /app/
|
| 29 |
-
|
| 30 |
-
# Collect static files
|
| 31 |
-
# RUN python manage.py collectstatic --noinput
|
| 32 |
-
# (Commented out because it might fail without proper static storage config, enables manual run if needed)
|
| 33 |
-
|
| 34 |
-
# Expose port 7860 (Hugging Face Default)
|
| 35 |
-
EXPOSE 7860
|
| 36 |
-
|
| 37 |
-
# Default command (overridden by Render/Docker Compose)
|
| 38 |
-
# Start both the web server and the telegram bot
|
| 39 |
-
# Copy and make the start script executable
|
| 40 |
-
COPY start.sh /app/
|
| 41 |
-
RUN chmod +x /app/start.sh
|
| 42 |
-
|
| 43 |
-
# Start using the script
|
| 44 |
-
CMD ["/app/start.sh"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/README.md
DELETED
|
Binary file (30 Bytes)
|
|
|
credit_card/admins/__init__.py
DELETED
|
File without changes
|
credit_card/admins/__pycache__/__init__.cpython-310.pyc
DELETED
|
Binary file (231 Bytes)
|
|
|
credit_card/admins/__pycache__/__init__.cpython-312.pyc
DELETED
|
Binary file (233 Bytes)
|
|
|
credit_card/admins/__pycache__/__init__.cpython-37.pyc
DELETED
|
Binary file (228 Bytes)
|
|
|
credit_card/admins/__pycache__/admin.cpython-310.pyc
DELETED
|
Binary file (272 Bytes)
|
|
|
credit_card/admins/__pycache__/admin.cpython-312.pyc
DELETED
|
Binary file (277 Bytes)
|
|
|
credit_card/admins/__pycache__/admin.cpython-37.pyc
DELETED
|
Binary file (269 Bytes)
|
|
|
credit_card/admins/__pycache__/apps.cpython-310.pyc
DELETED
|
Binary file (510 Bytes)
|
|
|
credit_card/admins/__pycache__/apps.cpython-312.pyc
DELETED
|
Binary file (539 Bytes)
|
|
|
credit_card/admins/__pycache__/apps.cpython-37.pyc
DELETED
|
Binary file (501 Bytes)
|
|
|
credit_card/admins/__pycache__/models.cpython-310.pyc
DELETED
|
Binary file (269 Bytes)
|
|
|
credit_card/admins/__pycache__/models.cpython-312.pyc
DELETED
|
Binary file (274 Bytes)
|
|
|
credit_card/admins/__pycache__/models.cpython-37.pyc
DELETED
|
Binary file (266 Bytes)
|
|
|
credit_card/admins/__pycache__/views.cpython-310.pyc
DELETED
|
Binary file (1.77 kB)
|
|
|
credit_card/admins/__pycache__/views.cpython-312.pyc
DELETED
|
Binary file (2.71 kB)
|
|
|
credit_card/admins/__pycache__/views.cpython-37.pyc
DELETED
|
Binary file (1.76 kB)
|
|
|
credit_card/admins/admin.py
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
from django.contrib import admin
|
| 2 |
-
|
| 3 |
-
# Register your models here.
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/admins/apps.py
DELETED
|
@@ -1,6 +0,0 @@
|
|
| 1 |
-
from django.apps import AppConfig
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
class AdminsConfig(AppConfig):
|
| 5 |
-
default_auto_field = 'django.db.models.BigAutoField'
|
| 6 |
-
name = 'admins'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/admins/management/__init__.py
DELETED
|
File without changes
|
credit_card/admins/management/__pycache__/__init__.cpython-312.pyc
DELETED
|
Binary file (244 Bytes)
|
|
|
credit_card/admins/management/commands/__init__.py
DELETED
|
File without changes
|
credit_card/admins/management/commands/__pycache__/__init__.cpython-312.pyc
DELETED
|
Binary file (253 Bytes)
|
|
|
credit_card/admins/management/commands/__pycache__/run_telegram_bot.cpython-312.pyc
DELETED
|
Binary file (12.1 kB)
|
|
|
credit_card/admins/management/commands/run_telegram_bot.py
DELETED
|
@@ -1,188 +0,0 @@
|
|
| 1 |
-
import logging
|
| 2 |
-
import asyncio
|
| 3 |
-
from django.core.management.base import BaseCommand
|
| 4 |
-
from django.conf import settings
|
| 5 |
-
from users.models import UserRegistrationModel
|
| 6 |
-
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardMarkup
|
| 7 |
-
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, CallbackQueryHandler, MessageHandler, filters
|
| 8 |
-
from asgiref.sync import sync_to_async
|
| 9 |
-
import webbrowser
|
| 10 |
-
|
| 11 |
-
# Constants
|
| 12 |
-
TOKEN = '8394032591:AAG_9Kitz0j1A00mvD3iBVgWlJe9as6Oix8'
|
| 13 |
-
|
| 14 |
-
# Configure Logging
|
| 15 |
-
logging.basicConfig(
|
| 16 |
-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
| 17 |
-
level=logging.INFO
|
| 18 |
-
)
|
| 19 |
-
logger = logging.getLogger(__name__)
|
| 20 |
-
|
| 21 |
-
class Command(BaseCommand):
|
| 22 |
-
help = 'Runs the Telegram Bot for FraudGuard Admin'
|
| 23 |
-
|
| 24 |
-
def handle(self, *args, **options):
|
| 25 |
-
self.stdout.write(self.style.SUCCESS('Starting Telegram Bot...'))
|
| 26 |
-
|
| 27 |
-
application = ApplicationBuilder().token(TOKEN).build()
|
| 28 |
-
|
| 29 |
-
# Add handlers
|
| 30 |
-
application.add_handler(CommandHandler('start', self.start))
|
| 31 |
-
application.add_handler(CommandHandler('help', self.help_command))
|
| 32 |
-
application.add_handler(CommandHandler('pending', self.pending_users))
|
| 33 |
-
application.add_handler(CommandHandler('menu', self.menu))
|
| 34 |
-
application.add_handler(CommandHandler('links', self.links))
|
| 35 |
-
|
| 36 |
-
# Handle Buttons
|
| 37 |
-
application.add_handler(CallbackQueryHandler(self.button_handler))
|
| 38 |
-
|
| 39 |
-
# Handle Menu Text (if they type the menu options)
|
| 40 |
-
application.add_handler(MessageHandler(filters.Regex('^(PENDING USERS|LINKS|STATS)$'), self.menu_handler))
|
| 41 |
-
|
| 42 |
-
# Run
|
| 43 |
-
application.run_polling()
|
| 44 |
-
|
| 45 |
-
async def start(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 46 |
-
keyboard = [
|
| 47 |
-
["PENDING USERS", "LINKS"],
|
| 48 |
-
["STATS"]
|
| 49 |
-
]
|
| 50 |
-
reply_markup = ReplyKeyboardMarkup(keyboard, resize_keyboard=True)
|
| 51 |
-
|
| 52 |
-
await update.message.reply_text(
|
| 53 |
-
"🤖 *Welcome to FraudGuard Bot!*\n\n"
|
| 54 |
-
"I can help you manage your application directly from Telegram.\n\n"
|
| 55 |
-
"🔹 *Approve Users*: Get notified and activate new registrations.\n"
|
| 56 |
-
"🔹 *Quick Links*: Access your Admin and User portals.\n"
|
| 57 |
-
"🔹 *Stats*: See system status.\n\n"
|
| 58 |
-
"Use the menu below or type /help.",
|
| 59 |
-
reply_markup=reply_markup,
|
| 60 |
-
parse_mode='Markdown'
|
| 61 |
-
)
|
| 62 |
-
|
| 63 |
-
async def help_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 64 |
-
await update.message.reply_text(
|
| 65 |
-
"📋 *Available Commands:*\n\n"
|
| 66 |
-
"/start - Main Menu\n"
|
| 67 |
-
"/pending - List users waiting for activation\n"
|
| 68 |
-
"/links - Get direct links to your app pages\n"
|
| 69 |
-
"/stats - View application statistics\n"
|
| 70 |
-
"/menu - Show the keyboard menu",
|
| 71 |
-
parse_mode='Markdown'
|
| 72 |
-
)
|
| 73 |
-
|
| 74 |
-
async def menu(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 75 |
-
await self.start(update, context)
|
| 76 |
-
|
| 77 |
-
async def menu_handler(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 78 |
-
text = update.message.text
|
| 79 |
-
if text == "PENDING USERS":
|
| 80 |
-
await self.pending_users(update, context)
|
| 81 |
-
elif text == "LINKS":
|
| 82 |
-
await self.links(update, context)
|
| 83 |
-
elif text == "STATS":
|
| 84 |
-
await self.stats(update, context)
|
| 85 |
-
|
| 86 |
-
async def pending_users(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 87 |
-
users = await sync_to_async(list)(UserRegistrationModel.objects.filter(status='waiting'))
|
| 88 |
-
|
| 89 |
-
if not users:
|
| 90 |
-
await update.message.reply_text("✅ No pending user registrations found.")
|
| 91 |
-
return
|
| 92 |
-
|
| 93 |
-
await update.message.reply_text(f"found {len(users)} pending users:")
|
| 94 |
-
|
| 95 |
-
for user in users:
|
| 96 |
-
keyboard = [
|
| 97 |
-
[
|
| 98 |
-
InlineKeyboardButton("✅ Activate", callback_data=f"activate_{user.id}"),
|
| 99 |
-
InlineKeyboardButton("❌ Delete", callback_data=f"delete_{user.id}"),
|
| 100 |
-
]
|
| 101 |
-
]
|
| 102 |
-
reply_markup = InlineKeyboardMarkup(keyboard)
|
| 103 |
-
text = (
|
| 104 |
-
f"👤 *Registration Request*\n"
|
| 105 |
-
f"━━━━━━━━━━━━━━━━━━\n"
|
| 106 |
-
f"**Name:** {user.name}\n"
|
| 107 |
-
f"**ID:** `{user.loginid}`\n"
|
| 108 |
-
f"**Email:** {user.email}\n"
|
| 109 |
-
f"**Mobile:** {user.mobile}\n"
|
| 110 |
-
f"**Locality:** {user.locality}"
|
| 111 |
-
)
|
| 112 |
-
await update.message.reply_text(text, reply_markup=reply_markup, parse_mode='Markdown')
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
async def stats(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 117 |
-
total_users = await sync_to_async(UserRegistrationModel.objects.count)()
|
| 118 |
-
active_users = await sync_to_async(UserRegistrationModel.objects.filter(status='activated').count)()
|
| 119 |
-
pending_users = await sync_to_async(UserRegistrationModel.objects.filter(status='waiting').count)()
|
| 120 |
-
|
| 121 |
-
text = (
|
| 122 |
-
"📊 *System Statistics*\n"
|
| 123 |
-
f"━━━━━━━━━━━━━━━━━━\n"
|
| 124 |
-
f"**Total Users:** {total_users}\n"
|
| 125 |
-
f"**Active:** {active_users}\n"
|
| 126 |
-
f"**Pending:** {pending_users}\n"
|
| 127 |
-
)
|
| 128 |
-
await update.message.reply_text(text, parse_mode='Markdown')
|
| 129 |
-
|
| 130 |
-
async def links(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 131 |
-
keyboard = [
|
| 132 |
-
[InlineKeyboardButton("🖥 Open Admin (Host)", callback_data="open_admin")],
|
| 133 |
-
[InlineKeyboardButton("🖥 Open User Login (Host)", callback_data="open_user")],
|
| 134 |
-
[InlineKeyboardButton("� Open Registration (Host)", callback_data="open_register")],
|
| 135 |
-
[InlineKeyboardButton("🖥 Open Home (Host)", callback_data="open_home")],
|
| 136 |
-
]
|
| 137 |
-
reply_markup = InlineKeyboardMarkup(keyboard)
|
| 138 |
-
|
| 139 |
-
text = (
|
| 140 |
-
"� *Remote Control Links*\n"
|
| 141 |
-
"Click below to open these pages **on your laptop/server**."
|
| 142 |
-
)
|
| 143 |
-
await update.message.reply_text(text, reply_markup=reply_markup, parse_mode='Markdown')
|
| 144 |
-
|
| 145 |
-
async def button_handler(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 146 |
-
query = update.callback_query
|
| 147 |
-
await query.answer()
|
| 148 |
-
|
| 149 |
-
data = query.data
|
| 150 |
-
base_url = "http://127.0.0.1:8000"
|
| 151 |
-
|
| 152 |
-
match data:
|
| 153 |
-
case "open_admin":
|
| 154 |
-
webbrowser.open(f"{base_url}/admins/AdminLoginCheck/")
|
| 155 |
-
await query.edit_message_text("✅ Opened **Admin Login** on host machine.", parse_mode='Markdown')
|
| 156 |
-
return
|
| 157 |
-
case "open_user":
|
| 158 |
-
webbrowser.open(f"{base_url}/users/UserLoginCheck/")
|
| 159 |
-
await query.edit_message_text("✅ Opened **User Login** on host machine.", parse_mode='Markdown')
|
| 160 |
-
return
|
| 161 |
-
case "open_register":
|
| 162 |
-
webbrowser.open(f"{base_url}/UserRegisterForm")
|
| 163 |
-
await query.edit_message_text("✅ Opened **Registration** on host machine.", parse_mode='Markdown')
|
| 164 |
-
return
|
| 165 |
-
case "open_home":
|
| 166 |
-
webbrowser.open(f"{base_url}/")
|
| 167 |
-
await query.edit_message_text("✅ Opened **Home Page** on host machine.", parse_mode='Markdown')
|
| 168 |
-
return
|
| 169 |
-
|
| 170 |
-
# Handle User Actions (Activate/Delete)
|
| 171 |
-
try:
|
| 172 |
-
action, user_id = data.split('_')
|
| 173 |
-
user_id = int(user_id)
|
| 174 |
-
|
| 175 |
-
user = await sync_to_async(UserRegistrationModel.objects.get)(id=user_id)
|
| 176 |
-
|
| 177 |
-
if action == 'activate':
|
| 178 |
-
user.status = 'activated'
|
| 179 |
-
await sync_to_async(user.save)()
|
| 180 |
-
await query.edit_message_text(text=f"✅ User *{user.name}* has been **ACTIVATED**.", parse_mode='Markdown')
|
| 181 |
-
elif action == 'delete':
|
| 182 |
-
await sync_to_async(user.delete)()
|
| 183 |
-
await query.edit_message_text(text=f"❌ User *{user.name}* has been **DELETED**.", parse_mode='Markdown')
|
| 184 |
-
|
| 185 |
-
except UserRegistrationModel.DoesNotExist:
|
| 186 |
-
await query.edit_message_text(text="⚠️ User not found (might have been processed already).")
|
| 187 |
-
except Exception as e:
|
| 188 |
-
await query.edit_message_text(text=f"⚠️ Error: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/admins/migrations/__init__.py
DELETED
|
File without changes
|
credit_card/admins/migrations/__pycache__/__init__.cpython-310.pyc
DELETED
|
Binary file (242 Bytes)
|
|
|
credit_card/admins/migrations/__pycache__/__init__.cpython-312.pyc
DELETED
|
Binary file (244 Bytes)
|
|
|
credit_card/admins/migrations/__pycache__/__init__.cpython-37.pyc
DELETED
|
Binary file (239 Bytes)
|
|
|
credit_card/admins/models.py
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
from django.db import models
|
| 2 |
-
|
| 3 |
-
# Create your models here.
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/admins/tests.py
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
from django.test import TestCase
|
| 2 |
-
|
| 3 |
-
# Create your tests here.
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/admins/views.py
DELETED
|
@@ -1,60 +0,0 @@
|
|
| 1 |
-
from django.shortcuts import render
|
| 2 |
-
|
| 3 |
-
# Create your views here.
|
| 4 |
-
from django.shortcuts import render
|
| 5 |
-
|
| 6 |
-
# Create your views here.
|
| 7 |
-
from django.shortcuts import render
|
| 8 |
-
|
| 9 |
-
# Create your views here.
|
| 10 |
-
from django.shortcuts import render,redirect
|
| 11 |
-
from django.contrib import messages
|
| 12 |
-
from users.models import UserRegistrationModel
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# Create your views here.
|
| 16 |
-
def AdminLoginCheck(request):
|
| 17 |
-
if request.method == 'POST':
|
| 18 |
-
usrid = request.POST.get('loginid')
|
| 19 |
-
pswd = request.POST.get('pswd')
|
| 20 |
-
print("User ID is = ", usrid)
|
| 21 |
-
if usrid == 'admin' and pswd == 'admin':
|
| 22 |
-
return redirect('adminhome')
|
| 23 |
-
else:
|
| 24 |
-
messages.error(request, 'Invalid Administrator Credentials')
|
| 25 |
-
return render(request, 'AdminLogin.html', {})
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
def RegisterUsersView(request):
|
| 30 |
-
data = UserRegistrationModel.objects.all()
|
| 31 |
-
return render(request, 'admins/viewregisterusers.html', context={'data': data})
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
def ActivaUsers(request):
|
| 37 |
-
if request.method == 'GET':
|
| 38 |
-
user_id = request.GET.get('uid')
|
| 39 |
-
|
| 40 |
-
if user_id: # Ensure user_id is not None
|
| 41 |
-
status = 'activated'
|
| 42 |
-
print("Activating user with ID =", user_id)
|
| 43 |
-
UserRegistrationModel.objects.filter(id=user_id).update(status=status)
|
| 44 |
-
|
| 45 |
-
# Redirect to the view where users are listed after activation
|
| 46 |
-
return redirect('RegisterUsersView') # Replace with your actual URL name
|
| 47 |
-
|
| 48 |
-
def DeleteUsers(request):
|
| 49 |
-
if request.method == 'GET':
|
| 50 |
-
user_id = request.GET.get('uid')
|
| 51 |
-
|
| 52 |
-
if user_id: # Ensure user_id is not None
|
| 53 |
-
print("Deleting user with ID =", user_id)
|
| 54 |
-
UserRegistrationModel.objects.filter(id=user_id).delete()
|
| 55 |
-
|
| 56 |
-
# Redirect to the view where users are listed after deletion
|
| 57 |
-
return redirect('RegisterUsersView') # Replace with your actual URL name
|
| 58 |
-
def adminhome(request):
|
| 59 |
-
return render(request,'admins/AdminHome.html')
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
credit_card/credit_card/__init__.py
DELETED
|
File without changes
|
credit_card/credit_card/__pycache__/__init__.cpython-310.pyc
DELETED
|
Binary file (236 Bytes)
|
|
|
credit_card/credit_card/__pycache__/__init__.cpython-312.pyc
DELETED
|
Binary file (238 Bytes)
|
|
|
credit_card/credit_card/__pycache__/__init__.cpython-37.pyc
DELETED
|
Binary file (233 Bytes)
|
|
|
credit_card/credit_card/__pycache__/settings.cpython-310.pyc
DELETED
|
Binary file (2.52 kB)
|
|
|
credit_card/credit_card/__pycache__/settings.cpython-312.pyc
DELETED
|
Binary file (3.09 kB)
|
|
|
credit_card/credit_card/__pycache__/settings.cpython-37.pyc
DELETED
|
Binary file (2.55 kB)
|
|
|
credit_card/credit_card/__pycache__/urls.cpython-310.pyc
DELETED
|
Binary file (2.01 kB)
|
|
|
credit_card/credit_card/__pycache__/urls.cpython-312.pyc
DELETED
|
Binary file (2.83 kB)
|
|
|
credit_card/credit_card/__pycache__/urls.cpython-37.pyc
DELETED
|
Binary file (2.07 kB)
|
|
|
credit_card/credit_card/__pycache__/views.cpython-310.pyc
DELETED
|
Binary file (636 Bytes)
|
|
|
credit_card/credit_card/__pycache__/views.cpython-312.pyc
DELETED
|
Binary file (758 Bytes)
|
|
|