# ZeroIRC Web

A lightweight, modern web‑based IRC client built with vanilla JavaScript and Node.js.  
It connects to any IRC server through a WebSocket gateway, offering a familiar desktop‑like experience directly in the browser.

## Features

- **Full IRC command set** – join, part, list, whois, nick, away, kick, ban, ctcp, mode, topic, and many more, including short aliases (`/j`, `/l`, `/w`, …)
- **Server manager** – save and manage multiple IRC servers with individual nicknames and channels, just like the desktop version
- **Favourites** – mark servers and channels as favourites for quick access
- **Channel list** – browse, search and join channels with a built‑in channel list view
- **Auto‑join** – automatically join your favourite channels on connect
- **Responsive UI** – adapts to desktop and mobile browsers
- **Double‑click tab close** – close tabs by double‑clicking (or double‑tapping on mobile)
- **Emoji picker** – insert emojis into messages
- **Mention notifications** – desktop notifications when someone mentions your nickname

## Architecture
Browser (SPA) <── WebSocket ──> Node.js gateway <── TCP ──> IRC server


The Node.js gateway (`server.js`) acts as a bridge between the browser and the IRC server. It uses the `ws` library for WebSocket communication and the `irc` library to handle the IRC protocol.

## Requirements

- **Node.js** >= 18.x
- **npm** (shipped with Node.js)
- **Nginx** (optional, but recommended for production)

## Manual installation

1. **Clone or copy the project** to a directory of your choice, for example `/opt/zeroirc-web`:
   ```bash
   git clone https://github.com/your-org/zeroirc-web.git /opt/zeroirc-web
   cd /opt/zeroirc-web
2. Install dependencies:
    npm install
3. Run the gateway:
    node server.js
    The server will listen on port 3000 by default (change it by setting the PORT environment variable).
4. Open the client – navigate to http://localhost:3000 in your browser.

## Production deployment with Nginx
For production it is recommended to place Nginx in front of the Node.js process and serve the static files through it as well.

1. Copy the project to /opt/zeroirc-web and install dependencies as described above.
2. Create a systemd service (/etc/systemd/system/zeroirc-gateway.service):
[Unit]
Description=ZeroIRC WebSocket Gateway
After=network.target

[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/opt/zeroirc-web
ExecStart=/usr/bin/node server.js
Restart=on-failure
RestartSec=5
Environment=PORT=3000

[Install]
WantedBy=multi-user.target

# Then enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable --now zeroirc-gateway

3. Configure Nginx (example /etc/nginx/sites-available/zeroirc): 
server {
    listen 80;
    server_name your-domain.com;

    root /opt/zeroirc-web;
    index index.html;

    location /ws/ {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
        proxy_read_timeout 86400s;
    }

    location / {
        try_files $uri $uri/ =404;
    }
}

# Enable the site and restart Nginx:
sudo ln -s /etc/nginx/sites-available/zeroirc /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default   # optional, remove default site
sudo nginx -t && sudo systemctl reload nginx

4. (Optional) Enable SSL with Certbot:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com

## Automatic deployment (Ubuntu 20.04 – 26.04)
The repository includes a deploy-zeroircweb.sh script that fully automates the setup on a fresh Ubuntu server.

The script performs the following steps:
- Installs Nginx, Node.js 20.x, Certbot (optional)
- Copies the project to /opt/zeroirc-web
- Installs npm dependencies
- Creates a systemd service for Node.js
- Configures Nginx (with or without SSL)
- Starts the service

# Usage:
Copy the project files to the server (e.g., via scp).
Edit DOMAIN and EMAIL variables at the top of deploy-zeroircweb.sh if you want SSL.
Run the script as root:

sudo bash deploy-zeroircweb.sh

If no domain is provided the application will be available via HTTP on port 80.

## Development
For local development you can use server-dev.js which includes automatic restart on file changes:

npm install --include=dev
npm run dev

## License

ZeroIRC Web is distributed under the terms of the **MIT License**.  
You are free to copy, modify, distribute, and use the software for any purpose, provided that the original copyright notice and this permission notice are included in all copies or substantial portions of the software.

---

The full license text can be found in the LICENSE file included in the project repository.

## ZeroIRC Web – a web companion to the ZeroIRC desktop client.
Visit zeroirc.net for more information.