Gwuh
This commit is contained in:
parent
cc1fa75880
commit
782fca6574
35
README.MD
Normal file
35
README.MD
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Kuma Discord Status Bot
|
||||
|
||||
This script integrates [Uptime Kuma](https://github.com/louislam/uptime-kuma) status pages with Discord, posting live status updates to specified channels.
|
||||
|
||||
## Features
|
||||
|
||||
- Fetches status from Uptime Kuma API.
|
||||
- Posts and updates rich embed messages in Discord channels.
|
||||
- Supports multiple channels and status pages.
|
||||
- Updates every 5 minutes via cron.
|
||||
|
||||
## Setup
|
||||
|
||||
### 1. Requirements
|
||||
|
||||
- Node.js (v16+ recommended)
|
||||
- Discord bot token
|
||||
- Uptime Kuma instance with API access
|
||||
|
||||
### 2. Configuration
|
||||
Create a `.env` file in the root directory with the following variables:
|
||||
```
|
||||
KUMA_BASE_URL=https://your-uptime-kuma-instance.com
|
||||
TOKEN=your-discord-bot-token
|
||||
```
|
||||
|
||||
### 3. Subscription Configuration
|
||||
Create a `subs.json` file in the root directory to define which channels should receive updates.
|
||||
Example:
|
||||
```json
|
||||
{
|
||||
"channel_id_1": "status_page_id_1",
|
||||
"channel_id_2": "status_page_id_2"
|
||||
}
|
||||
```
|
6
index.js
6
index.js
|
@ -48,7 +48,9 @@ function getStatus(input) {
|
|||
let fieldParts = [];
|
||||
|
||||
for (monitor of cat.monitors) {
|
||||
const monitorText = `${monitor.heartbeats[0].status ? "<:online:1307359583785713744>" : "<:offline:1307359600592424971>"} ${monitor.name}\n`;
|
||||
const status = new Boolean(monitor.heartbeats[0].status); // Turn it into a boolean because 0 and 1 are not always reliable in JS
|
||||
console.log(`Monitor: ${monitor.name}, Status: ${status}`);
|
||||
const monitorText = `${status ? "<:online:1307359583785713744>" : "<:offline:1307359600592424971>"} ${monitor.name}\n`;
|
||||
|
||||
// Check if adding this monitor's text will exceed 1024 characters
|
||||
if (fieldText.length + monitorText.length > 1024) {
|
||||
|
@ -61,7 +63,7 @@ function getStatus(input) {
|
|||
}
|
||||
|
||||
// If the monitor is offline, increment the offline count
|
||||
if (!monitor.heartbeats[0].status) offline++;
|
||||
if (!status) offline++;
|
||||
total++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue