# Installationsvejledning – Twitch PHP Bot

## 1️⃣ Download
Klon eller hent ZIP fra GitHub:

```
git clone https://github.com/<dit-brugernavn>/twitch-php-bot.git
Placer i din webserver, fx:

makefile
C:\xampp\htdocs\bot\
```

2️⃣ Krav
PHP 8.1+

Aktiverede extensions:
pdo_sqlite
curl
mbstring
json
Tjek i php.ini at disse ikke er udkommenteret.

3️⃣ Konfiguration
Opret filen .env i projektets rod:

.env
```
TWITCH_CHANNEL=ditkanalnavn
TWITCH_OAUTH=oauth:xxxxxxxxxxxxxxxxxxxx
TWITCH_CLIENT_ID=din_client_id
TWITCH_CLIENT_SECRET=din_client_secret
Hent OAuth-token her: https://twitchapps.com/tmi/
```

4️⃣ Database & Admin
Gå til http://localhost/bot/web/migrate_users.php → sikrer korrekte kolonner
Gå til http://localhost/bot/web/create_admin.php → opretter admin

Login:
Brugernavn: admin
Adgangskode: demo

5️⃣ Start botten
Åbn http://localhost/bot/web/login.php

Log ind og klik Start
Botten kører i PHP bag kulissen og svarer på chat-kommandoer.

6️⃣ (Valgfrit) Live-log via WebSocket
Installer Node.js → kør:

```
npm install ws
node ws_server.js
```
Dashboardet skifter automatisk til WebSocket, hvis tilgængelig.

---

#English
Installation Guide – Twitch PHP Bot

##1️⃣ Download

Clone or download the ZIP from GitHub:
```
git clone https://github.com/<your-username>/twitch-php-bot.git
```

Place it in your web server directory, for example:
```
C:\xampp\htdocs\bot\
```
<br>
2️⃣ Requirements

PHP 8.1+

Enabled extensions:
```
pdo_sqlite  
curl  
mbstring  
json
```

Check your php.ini file and make sure these are not commented out.

3️⃣ Configuration

Create a file named .env in the project root:

.env
```
TWITCH_CHANNEL=yourchannelname
TWITCH_OAUTH=oauth:xxxxxxxxxxxxxxxxxxxx
TWITCH_CLIENT_ID=your_client_id
TWITCH_CLIENT_SECRET=your_client_secret
```

Get your OAuth token here: https://twitchapps.com/tmi/

4️⃣ Database & Admin

Open:
```
http://localhost/bot/web/migrate_users.php
```

→ ensures correct table columns

Then open:
```
http://localhost/bot/web/create_admin.php
```

→ creates your admin user

Login credentials:
```
Username: admin  
Password: demo
```


5️⃣ Start the Bot

Go to:
```
http://localhost/bot/web/login.php
```

Log in and click Start
The bot runs in PHP behind the scenes and responds to chat commands.

6️⃣ (Optional) Live Log via WebSocket

Install Node.js, then run:
```
npm install ws
node ws_server.js
```

The dashboard will automatically switch to WebSocket mode if available.