2026-03-02 10:56:08 -05:00
2026-03-02 09:48:34 -05:00
2026-03-02 09:48:34 -05:00
2026-03-02 09:48:34 -05:00
2026-03-02 09:48:34 -05:00
2026-03-02 09:48:49 -05:00
2026-03-02 10:56:08 -05:00
2026-03-02 09:48:49 -05:00
2026-03-02 09:48:49 -05:00
2026-03-02 09:48:49 -05:00
2026-03-02 09:49:12 -05:00
2026-03-02 09:49:12 -05:00

🚀 Advanced Chat Server & Client

A feature-rich, production-ready chat server and client built with Python and WebSockets. Works on local development and hosted deployment (Ubuntu).

Features

Core Features

  • Unified Client: Single client for both Server and P2P LAN modes
  • File Sharing: Send and receive files
  • Real-time Messaging: Instant communication with low latency
  • Multiple Rooms: Join different channels with password protection
  • User Authentication: Secure identification for server-based chat
  • Admin System: Comprehensive moderation tools
  • SSL/TLS Support: Encrypted connections for server mode

Advanced Features

  1. Account & Registration

    • User registration with password hashing
    • Secure authentication
    • Nickname management
  2. Room Management

    • Create public and private rooms
    • Password-protected rooms
    • Room topics and announcements
    • User lists per room
  3. Invite System

    • Generate time-limited invite codes
    • Configurable max uses
    • Invite tracking and revocation
  4. Message Search

    • Full-text search across messages
    • Filter by room, user, and date
    • Search history
  5. Message Replies

    • Thread-based conversations
    • Quote original messages
    • Reply tracking
  6. User Blocks

    • Block/ignore users
    • Temporary or permanent blocks
    • Block list management
  7. Command Aliases

    • Create custom command shortcuts
    • Alias usage tracking
    • Personal alias management
  8. Room Announcements

    • Broadcast important messages
    • Time-limited announcements
    • Announcement history
  9. Scheduled Messages

    • Schedule messages for future delivery
    • Multiple time formats (HH:MM, +1h, +30m, +7d)
    • Cancel scheduled messages
  10. Room Bookmarks

    • Save favorite rooms/commands
    • Quick access to bookmarks
    • Usage statistics
  11. Message Export

    • Export room history
    • Export user messages
    • Multiple export formats
  12. Room Backups

    • Password-protected backups
    • Full room state preservation
    • Backup restoration
  13. Notification Rules

    • Keyword notifications
    • User-specific notifications
    • @mention support
    • Cooldown periods
  14. Offline Messages

    • Queue messages for offline users
    • Automatic delivery on reconnect
    • Message expiration
  15. Admin System

    • Admin privilege management
    • Clear chat history
    • User management
    • System monitoring

🛠️ Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)
  • Optional (for Advanced Features):
    • cryptography: Required for End-to-End Encryption (E2EE)
    • Pillow: Required for ASCII Image Art features
    • prompt-toolkit

Windows (Local Development)

  1. Clone or download this repository
  2. Run the setup script:
    setup_windows.bat
    
  3. Edit .env file with your configuration
  4. Start the server:
    python server.py
    
  5. In a new terminal, start the client:
    python client.py
    

Manual Installation

# Install dependencies
pip install -r requirements.txt

# Copy environment template
cp .env.example .env

# Edit .env with your configuration
# Start server
python server.py

# In another terminal, start client
python client.py

⚙️ Configuration

Edit the .env file to configure the server:

# ==============================================================================
# Chat Server Example Configuration
# Copy this file to .env and adjust the values for your environment
# ==============================================================================

# -----------------
# Server Settings
# -----------------
HOST=0.0.0.0
PORT=8765

# -----------------
# Security & Auth
# -----------------
# The global administrator password for top-level commands (/admin)
ADMIN_PASSWORD=admin123

# (Optional) SSL/TLS Configuration
USE_SSL=false
SSL_CERT_PATH=
SSL_KEY_PATH=

# -----------------
# Database & State
# -----------------
# Location of the server SQLite database
DB_PATH=data/chat.db

# -----------------
# Operations & Logs
# -----------------
LOG_LEVEL=INFO
LOG_FILE=logs/chat_server.log

# -----------------
# Chat Parameters
# -----------------
# Maximum messages sent back to clients upon joining a room
MAX_HISTORY=100
MAX_MESSAGE_LENGTH=4096
MAX_NICKNAME_LENGTH=32

# Anti-Spam limits
RATE_LIMIT_MESSAGES=120
RATE_LIMIT_WINDOW=60

# -----------------
# Maintenance 
# -----------------
# Delete unused/empty rooms after this many hours
ROOM_EXPIRATION_HOURS=24
# Whether to automatically delete very old message history from the DB periodically
AUTO_HISTORY_CLEAR=false

# -----------------
# Backups 
# -----------------
BACKUP_DIR=backups
AUTO_BACKUP_ENABLED=false
AUTO_BACKUP_INTERVAL=86400

# -----------------
# Network & Timeout
# -----------------
SESSION_TIMEOUT=3600
KEEPALIVE_INTERVAL=30
RECONNECT_TIMEOUT=300

🎮 Usage

Server

Start the server with default settings:

python server.py

Or with custom options:

python server.py --host 0.0.0.0 --port 8765 --admin-pass mypassword

Client

Start the unified client:

python client.py

The client will prompt you to choose a server:

  1. On default it will say wss://server.wholeworldcoding.com/radio
  2. If you are running the server locally please type: ws:/localhost:8765

File Sharing

To share a file:

  1. Type /send <file_path>
  2. Others in the room will see a file offer
  3. They can type /accept <file_id> to download

Files are saved to the ./downloads folder by default.

Commands

Type /help in the client to see all available commands.

🔒 Security Features

  • Password Hashing: PBKDF2-HMAC-SHA256 with salt
  • SSL/TLS Support: Encrypted connections
  • Rate Limiting: Prevent spam and abuse (120 msg / 60s)
  • Input Validation: Sanitize all user inputs
  • Session Management: Automatic timeout and cleanup
  • Admin Controls: Privilege-based access control

🌐 Deployment

Local Network

  1. Start server on your machine
  2. Find your local IP address
  3. Clients connect to: ws://YOUR_LOCAL_IP:8765

Public Internet (Ubuntu Server)

  1. Deploy the server
  2. Configure firewall to allow port 8765
  3. Clients connect to: wss://yourdomain.com:8765

📊 Monitoring

Systemd Service (Ubuntu)

  • sudo systemctl status chatserver
  • sudo journalctl -u chatserver -f

Log Files

  • tail -f chat_server.log

🗄️ Database

The server uses SQLite for persistence (chat.db).

🐛 Troubleshooting

Connection Issues

  1. Cannot connect to server: Check if server is running and firewall status.
  2. SSL/TLS errors: Verify certificate paths in .env.
  3. Database errors: Check disk space and permissions.

📝 Development

Project Structure

radio/
├── server.py           # Main server application
├── client.py           # Unified client (Server & P2P Mode)
├── config.py           # Configuration management
├── requirements.txt    # Python dependencies
├── .env.example        # Environment template
├── .env                # Your configuration
├── setup_windows.bat   # Windows setup script
├── README.md           # Main documentation
├── docs/               # Detailed documentation files
├── chat.db             # SQLite database
└── logs/               # Log files directory

Contributing

Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request.

📜 License

This project is open source and available under the MIT License.


Made with ❤️ for the chat community

Description
No description provided
Readme 132 KiB
Languages
Python 99.4%
Batchfile 0.6%