Added Statistic Tracking

This commit is contained in:
2025-12-11 02:46:57 -06:00
parent fdc6df373d
commit 61dc5db6d0
4 changed files with 86 additions and 12 deletions

View File

@@ -1,24 +1,24 @@
#Jellycord version 1.0.9 # Jellycord version 1.1.0
# Discord # |Discord|
DISCORD_TOKEN=your_discord_bot_token DISCORD_TOKEN=your_discord_bot_token
PREFIX=! PREFIX=!
GUILD_IDS=123456789012345678,123456789012345678 GUILD_IDS=123456789012345678,123456789012345678
ADMIN_ROLE_IDS=111111111111111111,222222222222222222 ADMIN_ROLE_IDS=111111111111111111,222222222222222222
REQUIRED_ROLE_IDS=333333333333333333,444444444444444444 REQUIRED_ROLE_IDS=333333333333333333,444444444444444444
# Jellyfin # |Jellyfin|
JELLYFIN_URL=http://127.0.0.1:8096 JELLYFIN_URL=http://127.0.0.1:8096
JELLYFIN_API_KEY=your_jellyfin_api_key JELLYFIN_API_KEY=your_jellyfin_api_key
ENABLE_TRIAL_ACCOUNTS=false ENABLE_TRIAL_ACCOUNTS=false
TRIAL_TIME=24 # In hours TRIAL_TIME=24 # In hours
# Jellyseerr # |Jellyseerr|
JELLYSEERR_ENABLED=false JELLYSEERR_ENABLED=false
JELLYSEERR_URL=http://localhost:5055 JELLYSEERR_URL=http://localhost:5055
JELLYSEERR_API_KEY=your_api_key_here JELLYSEERR_API_KEY=your_api_key_here
# JFA-Go # |JFA-Go|
ENABLE_JFA=false ENABLE_JFA=false
JFA_URL=http://localhost:8056 JFA_URL=http://localhost:8056
JFA_USERNAME=yourusername JFA_USERNAME=yourusername
@@ -26,13 +26,13 @@ JFA_PASSWORD=yourpassword
JFA_API_KEY=your_api_key_here JFA_API_KEY=your_api_key_here
JFA_TOKEN= JFA_TOKEN=
# QBittorrent # |QBittorrent|
ENABLE_QBITTORRENT=false ENABLE_QBITTORRENT=false
QBIT_HOST=http://localhost:8080 QBIT_HOST=http://localhost:8080
QBIT_USERNAME=your_username QBIT_USERNAME=your_username
QBIT_PASSWORD=your_password QBIT_PASSWORD=your_password
# Proxmox # |Proxmox|
ENABLE_PROXMOX=false ENABLE_PROXMOX=false
PROXMOX_HOST=https://your-proxmox-server:8006 PROXMOX_HOST=https://your-proxmox-server:8006
PROXMOX_TOKEN_NAME=root@pam!yourtokenname PROXMOX_TOKEN_NAME=root@pam!yourtokenname
@@ -43,15 +43,17 @@ PROXMOX_VM_ID=
# Proxmox type can be "qemu" for VM, "lxc" for container # Proxmox type can be "qemu" for VM, "lxc" for container
PROXMOX_TYPE= PROXMOX_TYPE=
# MySQL # |MySQL|
DB_HOST=localhost DB_HOST=localhost
DB_USER=root DB_USER=root
DB_PASSWORD=password DB_PASSWORD=password
DB_NAME=jellyfin_bot DB_NAME=jellyfin_bot
# Time Settings # |General Settings|
TIMEZONE=America/Chicago TIMEZONE=America/Chicago
# Tracking only reports limited information about your instance for development reasons. (Tracking enabled Instance & Enabled Features)
TRACKING_ENABLED=true
# Logs # |Logs|
SYNC_LOG_CHANNEL_ID=555555555555555555 SYNC_LOG_CHANNEL_ID=555555555555555555
EVENT_LOGGING=false EVENT_LOGGING=false

View File

@@ -1,3 +1,7 @@
# 1.1.0
- The bot now sends limited info stats to a public frontend for development insight. (Reports enabled features and bot instance only | Jellyseerr, Proxmox, JFA, qBittorrent)
# 1.0.9 # 1.0.9
- You can now configure trial account duration - You can now configure trial account duration

View File

@@ -1,6 +1,11 @@
# Jellycord # Jellycord
![image](https://cdn.pengucc.com/images/projects/jellycord/readme/BannerRound.png) ![image](https://cdn.pengucc.com/images/projects/jellycord/readme/BannerRound.png)
![Live Player Count](https://img.shields.io/badge/dynamic/json?query=$.data.result[0].value[1]&url=https%3A%2F%2Fprometheus.pengucc.com%2Fapi%2Fv1%2Fquery%3Fquery%3Dinstance&style=for-the-badge&logo=nodedotjs&logoColor=white&label=Bot%20Instances&color=9964c5)
![Live Player Count](https://img.shields.io/badge/dynamic/json?query=$.data.result[0].value[1]&url=https%3A%2F%2Fprometheus.pengucc.com%2Fapi%2Fv1%2Fquery%3Fquery%3Djellyseerr&style=for-the-badge&logo=jellyfin&logoColor=white&label=Jellyseer%20Enabled&color=9964c5)
![Live Player Count](https://img.shields.io/badge/dynamic/json?query=$.data.result[0].value[1]&url=https%3A%2F%2Fprometheus.pengucc.com%2Fapi%2Fv1%2Fquery%3Fquery%3Dproxmox&style=for-the-badge&logo=proxmox&logoColor=white&label=Proxmox%20Enabled&color=9964c5)
![Live Player Count](https://img.shields.io/badge/dynamic/json?query=$.data.result[0].value[1]&url=https%3A%2F%2Fprometheus.pengucc.com%2Fapi%2Fv1%2Fquery%3Fquery%3Djfa&style=for-the-badge&logo=go&logoColor=white&label=JFA-GO%20Enabled&color=9964c5)
![Live Player Count](https://img.shields.io/badge/dynamic/json?query=$.data.result[0].value[1]&url=https%3A%2F%2Fprometheus.pengucc.com%2Fapi%2Fv1%2Fquery%3Fquery%3Dqbittorrent&style=for-the-badge&logo=qbittorrent&logoColor=white&label=qBittorrent%20Enabled&color=9964c5)
[![Online Members](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fdiscordapp.com%2Fapi%2Finvites%2FEdPJAhrDq8%3Fwith_counts%3Dtrue&query=approximate_presence_count&style=for-the-badge&logo=discord&logoColor=white&label=ONLINE%20MEMBERS&labelColor=grey&color=239eda)](https://discord.gg/EdPJAhrDq8) [![Online Members](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fdiscordapp.com%2Fapi%2Finvites%2FEdPJAhrDq8%3Fwith_counts%3Dtrue&query=approximate_presence_count&style=for-the-badge&logo=discord&logoColor=white&label=ONLINE%20MEMBERS&labelColor=grey&color=239eda)](https://discord.gg/EdPJAhrDq8)
![Latest Version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FPenguCCN%2FJellycord%2Fmain%2Fversion.json&query=%24.version&style=for-the-badge&logo=python&logoColor=white&label=Latest%20Version%3A&color=239eda) ![Latest Version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FPenguCCN%2FJellycord%2Fmain%2Fversion.json&query=%24.version&style=for-the-badge&logo=python&logoColor=white&label=Latest%20Version%3A&color=239eda)
@@ -13,7 +18,24 @@ This is a very simple and lightweight Jellyfin Discord bot for managing users. I
Fill out values in the .env and you're good to go! Fill out values in the .env and you're good to go!
## Features # 🛑 Disclaimer (Please Read) 🛑
This bot collects limited amounts of information, it is enabled by default and can be disabled in your environment file. Information Collected is limited to:
- Bot Instances
- Enabled Features
We do **not** and will **never** collect nor store:
- IP Address's.
- System Information.
- Information about Jellyfin or any related services.
## Why do we do this?
Adding these simply allows me to see what features users are interested in, allowing me to focus on improving/fixing highly used features.
# Features
- Automatic Account Cleanup - Automatic Account Cleanup
- Creating Accounts - Creating Accounts
@@ -24,7 +46,7 @@ Fill out values in the .env and you're good to go!
- Change bot prefix live - Change bot prefix live
- Checks for new releases - Checks for new releases
## Command Overview # Command Overview
**Pinging the bot will show you the necessary commands to create your account.** **Pinging the bot will show you the necessary commands to create your account.**

46
app.py
View File

@@ -18,6 +18,7 @@ from pathlib import Path
import tempfile import tempfile
import shutil import shutil
import pymysql import pymysql
import json
# ===================== # =====================
# ENV + VALIDATION # ENV + VALIDATION
@@ -84,6 +85,15 @@ VERSION_URL = "https://raw.githubusercontent.com/PenguCCN/Jellycord/main/version
RELEASES_URL = "https://github.com/PenguCCN/Jellycord/releases" RELEASES_URL = "https://github.com/PenguCCN/Jellycord/releases"
CHANGELOG_URL = "https://raw.githubusercontent.com/PenguCCN/Jellycord/refs/heads/main/CHANGELOG.md" CHANGELOG_URL = "https://raw.githubusercontent.com/PenguCCN/Jellycord/refs/heads/main/CHANGELOG.md"
TRACKING_ENABLED = os.getenv("TRACKING_ENABLED", "False").lower() == "true"
POST_ENDPOINTS = {
"botinstance": "https://jellycordstats.pengucc.com/api/instance",
"jellyseerr": "https://jellycordstats.pengucc.com/api/jellyseerr",
"proxmox": "https://jellycordstats.pengucc.com/api/proxmox",
"jfa": "https://jellycordstats.pengucc.com/api/jfa",
"qbittorrent": "https://jellycordstats.pengucc.com/api/qbittorrent"
}
# ===================== # =====================
# EVENT LOGGING # EVENT LOGGING
# ===================== # =====================
@@ -284,6 +294,7 @@ def delete_account(discord_id):
# ===================== # =====================
# JELLYFIN HELPERS # JELLYFIN HELPERS
# ===================== # =====================
def create_jellyfin_user(username, password): def create_jellyfin_user(username, password):
headers = {"X-Emby-Token": JELLYFIN_API_KEY} headers = {"X-Emby-Token": JELLYFIN_API_KEY}
data = {"Name": username, "Password": password} data = {"Name": username, "Password": password}
@@ -671,6 +682,8 @@ def restart_bot():
"""Replace current process with a new one.""" """Replace current process with a new one."""
os.execv(sys.executable, [sys.executable] + sys.argv) os.execv(sys.executable, [sys.executable] + sys.argv)
def build_payload(enabled: bool):
return {"value": 1 if enabled else 0}
# ===================== # =====================
# EVENTS # EVENTS
@@ -2337,6 +2350,33 @@ async def cleanup_task():
except Exception as e: except Exception as e:
print(f"[Cleanup] Failed to send removed message to sync channel: {e}") print(f"[Cleanup] Failed to send removed message to sync channel: {e}")
@tasks.loop(seconds=15)
async def periodic_post_task():
if not TRACKING_ENABLED:
return
features = {
"botinstance": TRACKING_ENABLED,
"jellyseerr": JELLYSEERR_ENABLED,
"proxmox": ENABLE_PROXMOX,
"jfa": ENABLE_JFA,
"qbittorrent": ENABLE_QBITTORRENT
}
for feature, enabled in features.items():
url = POST_ENDPOINTS.get(feature)
if not url:
print(f"[POST LOOP] No endpoint for: {feature}")
continue
payload = build_payload(enabled)
try:
response = requests.post(url, json=payload, timeout=10)
print(f"[POST LOOP] Sent {feature}{response.status_code} | Payload: {payload}")
except Exception as e:
print(f"[POST LOOP] Error sending POST for {feature}: {e}")
# ===================== # =====================
# JFA-Go Scheduled Token Refresh # JFA-Go Scheduled Token Refresh
# ===================== # =====================
@@ -2413,6 +2453,12 @@ async def on_ready():
if not check_for_updates.is_running(): if not check_for_updates.is_running():
check_for_updates.start() check_for_updates.start()
if TRACKING_ENABLED:
print("Tracking enabled — starting.")
periodic_post_task.start()
else:
print("Tracking disabled via .env")
await bot.change_presence( await bot.change_presence(
activity=discord.Activity(type=discord.ActivityType.watching, name=f"{PREFIX}help") activity=discord.Activity(type=discord.ActivityType.watching, name=f"{PREFIX}help")
) )