Upload files to "/"
This commit is contained in:
100
bot.py
Normal file
100
bot.py
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
import aiohttp
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
API_BASE_URL = "http://127.0.0.1:8000" # Change if API is remote
|
||||||
|
|
||||||
|
# Add the privileged message_content intent here
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
bot = commands.Bot(command_prefix="!", intents=intents)
|
||||||
|
|
||||||
|
user_sessions = {} # Track user's active session_id here
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_ready():
|
||||||
|
print(f"Bot connected as {bot.user}")
|
||||||
|
|
||||||
|
@bot.command(name="start")
|
||||||
|
async def start_session(ctx):
|
||||||
|
username = str(ctx.author)
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
payload = {"username": username}
|
||||||
|
async with session.post(f"{API_BASE_URL}/session/start", json=payload) as resp:
|
||||||
|
if resp.status == 200:
|
||||||
|
data = await resp.json()
|
||||||
|
user_sessions[username] = data["session_id"]
|
||||||
|
await ctx.send(f"Session started for **{username}**. Session ID: {data['session_id']}")
|
||||||
|
else:
|
||||||
|
await ctx.send(f"Failed to start session. Status code: {resp.status}")
|
||||||
|
|
||||||
|
@bot.command(name="stop")
|
||||||
|
async def stop_session(ctx):
|
||||||
|
username = str(ctx.author)
|
||||||
|
session_id = user_sessions.get(username)
|
||||||
|
if not session_id:
|
||||||
|
await ctx.send("You don't have an active session. Use `!start` to begin one.")
|
||||||
|
return
|
||||||
|
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.post(f"{API_BASE_URL}/session/{session_id}/stop") as resp:
|
||||||
|
if resp.status == 200:
|
||||||
|
data = await resp.json()
|
||||||
|
user_sessions.pop(username, None)
|
||||||
|
await ctx.send(
|
||||||
|
f"Session stopped for **{username}**.\n"
|
||||||
|
f"Duration: {data['duration_seconds']} seconds\n"
|
||||||
|
f"Carbon Footprint: {data['carbon_footprint_kg']:.6f} kg CO2\n"
|
||||||
|
f"Entropy Score: {data['entropy_score']:.4f} bits"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await ctx.send(f"Failed to stop session. Status code: {resp.status}")
|
||||||
|
|
||||||
|
@bot.command(name="leaderboard")
|
||||||
|
async def leaderboard(ctx):
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(f"{API_BASE_URL}/leaderboard") as resp:
|
||||||
|
if resp.status == 200:
|
||||||
|
data = await resp.json()
|
||||||
|
lifetime = data.get("top_lifetime_users", [])
|
||||||
|
trivia = data.get("top_trivia_users", [])
|
||||||
|
|
||||||
|
embed = discord.Embed(title="Cosmic Timer Leaderboards", color=0x00ff00)
|
||||||
|
if lifetime:
|
||||||
|
lifetime_text = "\n".join(
|
||||||
|
[f"#{i+1} **{u['username']}** — {u['lifetime_seconds']} sec" for i, u in enumerate(lifetime)]
|
||||||
|
)
|
||||||
|
embed.add_field(name="Top Lifetime Users", value=lifetime_text, inline=False)
|
||||||
|
if trivia:
|
||||||
|
trivia_text = "\n".join(
|
||||||
|
[f"#{i+1} **{u['username']}** — {u['trivia_points']} points" for i, u in enumerate(trivia)]
|
||||||
|
)
|
||||||
|
embed.add_field(name="Top Trivia Users", value=trivia_text, inline=False)
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
else:
|
||||||
|
await ctx.send(f"Failed to fetch leaderboard. Status code: {resp.status}")
|
||||||
|
|
||||||
|
@bot.command(name="stats")
|
||||||
|
async def user_stats(ctx, member: discord.Member = None):
|
||||||
|
member = member or ctx.author
|
||||||
|
username = str(member)
|
||||||
|
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(f"{API_BASE_URL}/user/{username}/stats") as resp:
|
||||||
|
if resp.status == 200:
|
||||||
|
data = await resp.json()
|
||||||
|
embed = discord.Embed(title=f"Stats for {username}", color=0x3498db)
|
||||||
|
embed.add_field(name="Lifetime Seconds", value=data["lifetime_seconds"])
|
||||||
|
embed.add_field(name="Trivia Points", value=data["trivia_points"])
|
||||||
|
embed.add_field(name="Carbon Footprint (kg CO2)", value=f"{data['carbon_footprint_kg']:.6f}")
|
||||||
|
embed.add_field(name="Entropy Score (bits)", value=f"{data['entropy_score']:.4f}")
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
else:
|
||||||
|
await ctx.send(f"User stats not found for {username}.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
TOKEN = "MTQwNDEzOTY0MTAxOTMwMjAyMQ.GyuOPC.eMCigYAsIZbziZmi-PDVNrzSoNZuCkoLuSkw0U"
|
||||||
|
bot.run(TOKEN)
|
||||||
|
|
||||||
13
cosmic_data.json
Normal file
13
cosmic_data.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"users": {
|
||||||
|
"gahx": {
|
||||||
|
"lifetime_seconds": 7306,
|
||||||
|
"trivia_count": 11
|
||||||
|
},
|
||||||
|
"Fizzgig": {
|
||||||
|
"lifetime_seconds": 3,
|
||||||
|
"trivia_count": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"trivia": {}
|
||||||
|
}
|
||||||
BIN
cosmic_timer.db
Normal file
BIN
cosmic_timer.db
Normal file
Binary file not shown.
332
cosmic_timer.py
Normal file
332
cosmic_timer.py
Normal file
@@ -0,0 +1,332 @@
|
|||||||
|
import json
|
||||||
|
import random
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import sqlite3
|
||||||
|
import sys
|
||||||
|
import select
|
||||||
|
import math
|
||||||
|
|
||||||
|
DATA_FILE = "cosmic_data.json"
|
||||||
|
TRIVIA_FILE = "trivia_facts.json"
|
||||||
|
DB_FILE = "cosmic_timer.db"
|
||||||
|
|
||||||
|
TRIVIA_WEIGHTS = {
|
||||||
|
"300": 1, # 5 minutes
|
||||||
|
"600": 2, # 10 minutes
|
||||||
|
"1800": 5, # 30 minutes
|
||||||
|
"3600": 10, # 1 hour
|
||||||
|
}
|
||||||
|
|
||||||
|
CARBON_PER_SECOND_KG = 0.0000005 # Estimated kg CO2 per second of runtime
|
||||||
|
|
||||||
|
def init_db():
|
||||||
|
conn = sqlite3.connect(DB_FILE)
|
||||||
|
c = conn.cursor()
|
||||||
|
# Create or update users table to include carbon_footprint_kg and entropy_score
|
||||||
|
c.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
|
username TEXT PRIMARY KEY,
|
||||||
|
lifetime_seconds INTEGER DEFAULT 0,
|
||||||
|
trivia_points INTEGER DEFAULT 0,
|
||||||
|
carbon_footprint_kg REAL DEFAULT 0,
|
||||||
|
entropy_score REAL DEFAULT 0
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
# If running on existing DB missing the columns, add them
|
||||||
|
c.execute("PRAGMA table_info(users)")
|
||||||
|
columns = [col[1] for col in c.fetchall()]
|
||||||
|
if "carbon_footprint_kg" not in columns:
|
||||||
|
c.execute("ALTER TABLE users ADD COLUMN carbon_footprint_kg REAL DEFAULT 0")
|
||||||
|
if "entropy_score" not in columns:
|
||||||
|
c.execute("ALTER TABLE users ADD COLUMN entropy_score REAL DEFAULT 0")
|
||||||
|
|
||||||
|
c.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS sessions (
|
||||||
|
session_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
username TEXT NOT NULL,
|
||||||
|
start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
end_time TIMESTAMP,
|
||||||
|
duration_seconds INTEGER DEFAULT 0,
|
||||||
|
FOREIGN KEY(username) REFERENCES users(username)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
c.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS trivia_events (
|
||||||
|
event_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
username TEXT NOT NULL,
|
||||||
|
session_id INTEGER,
|
||||||
|
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
trivia_time_seconds INTEGER,
|
||||||
|
points_awarded INTEGER,
|
||||||
|
FOREIGN KEY(username) REFERENCES users(username),
|
||||||
|
FOREIGN KEY(session_id) REFERENCES sessions(session_id)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
c.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS leaderboard_history (
|
||||||
|
record_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
username TEXT NOT NULL,
|
||||||
|
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
lifetime_rank INTEGER,
|
||||||
|
trivia_rank INTEGER,
|
||||||
|
FOREIGN KEY(username) REFERENCES users(username)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
conn.commit()
|
||||||
|
return conn
|
||||||
|
|
||||||
|
def list_tables():
|
||||||
|
conn = sqlite3.connect(DB_FILE)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute("SELECT name FROM sqlite_master WHERE type='table'")
|
||||||
|
tables = [row[0] for row in c.fetchall()]
|
||||||
|
conn.close()
|
||||||
|
print("\n📜 Tables in cosmic_timer.db:")
|
||||||
|
for t in tables:
|
||||||
|
print(f" - {t}")
|
||||||
|
|
||||||
|
def ensure_user_exists(c, username):
|
||||||
|
c.execute("SELECT 1 FROM users WHERE username = ?", (username,))
|
||||||
|
if not c.fetchone():
|
||||||
|
c.execute("INSERT INTO users (username) VALUES (?)", (username,))
|
||||||
|
|
||||||
|
def calculate_carbon_footprint(lifetime_seconds):
|
||||||
|
return lifetime_seconds * CARBON_PER_SECOND_KG
|
||||||
|
|
||||||
|
def calculate_entropy_score(trivia_events_count, total_seconds):
|
||||||
|
# Prevent division by zero or log(0)
|
||||||
|
if total_seconds == 0 or trivia_events_count == 0:
|
||||||
|
return 0.0
|
||||||
|
p = trivia_events_count / total_seconds
|
||||||
|
# Entropy per second using binary log (bits)
|
||||||
|
entropy = -p * math.log2(p) - (1 - p) * math.log2(1 - p) if 0 < p < 1 else 0
|
||||||
|
# Scale by total_seconds to get total entropy "bits" accumulated
|
||||||
|
return entropy * total_seconds
|
||||||
|
|
||||||
|
def update_user_stats(c, username, session_seconds, trivia_points_this_session):
|
||||||
|
# Count trivia events for this user from trivia_events table
|
||||||
|
c.execute("SELECT COUNT(*) FROM trivia_events WHERE username = ?", (username,))
|
||||||
|
trivia_events_count = c.fetchone()[0] or 0
|
||||||
|
|
||||||
|
c.execute("SELECT lifetime_seconds, trivia_points FROM users WHERE username = ?", (username,))
|
||||||
|
row = c.fetchone()
|
||||||
|
lifetime_seconds = (row[0] if row else 0) + session_seconds
|
||||||
|
trivia_points = (row[1] if row else 0) + trivia_points_this_session
|
||||||
|
carbon_footprint = calculate_carbon_footprint(lifetime_seconds)
|
||||||
|
entropy_score = calculate_entropy_score(trivia_events_count, lifetime_seconds)
|
||||||
|
|
||||||
|
c.execute('''
|
||||||
|
UPDATE users SET lifetime_seconds = ?, trivia_points = ?, carbon_footprint_kg = ?, entropy_score = ? WHERE username = ?
|
||||||
|
''', (lifetime_seconds, trivia_points, carbon_footprint, entropy_score, username))
|
||||||
|
|
||||||
|
return lifetime_seconds, trivia_points, carbon_footprint, entropy_score
|
||||||
|
|
||||||
|
def update_session_end(c, session_id, session_seconds):
|
||||||
|
c.execute('''
|
||||||
|
UPDATE sessions SET end_time = CURRENT_TIMESTAMP, duration_seconds = ? WHERE session_id = ?
|
||||||
|
''', (session_seconds, session_id))
|
||||||
|
|
||||||
|
def insert_trivia_event(c, username, session_id, trivia_time_seconds, points_awarded):
|
||||||
|
c.execute('''
|
||||||
|
INSERT INTO trivia_events (username, session_id, trivia_time_seconds, points_awarded)
|
||||||
|
VALUES (?, ?, ?, ?)
|
||||||
|
''', (username, session_id, trivia_time_seconds, points_awarded))
|
||||||
|
|
||||||
|
def insert_leaderboard_snapshot(c, username):
|
||||||
|
c.execute("SELECT username FROM users ORDER BY lifetime_seconds DESC")
|
||||||
|
lifetime_rank_list = [r[0] for r in c.fetchall()]
|
||||||
|
lifetime_rank = lifetime_rank_list.index(username) + 1 if username in lifetime_rank_list else None
|
||||||
|
|
||||||
|
c.execute("SELECT username FROM users ORDER BY trivia_points DESC")
|
||||||
|
trivia_rank_list = [r[0] for r in c.fetchall()]
|
||||||
|
trivia_rank = trivia_rank_list.index(username) + 1 if username in trivia_rank_list else None
|
||||||
|
|
||||||
|
c.execute('''
|
||||||
|
INSERT INTO leaderboard_history (username, lifetime_rank, trivia_rank)
|
||||||
|
VALUES (?, ?, ?)
|
||||||
|
''', (username, lifetime_rank, trivia_rank))
|
||||||
|
return lifetime_rank, trivia_rank
|
||||||
|
|
||||||
|
def load_trivia_data(path, default={}):
|
||||||
|
if os.path.exists(path):
|
||||||
|
try:
|
||||||
|
with open(path, 'r') as f:
|
||||||
|
data = json.load(f)
|
||||||
|
return {str(k): v for k, v in data.items()}
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Warning: Failed to load {path} due to {e}, loading default.")
|
||||||
|
else:
|
||||||
|
print(f"Notice: {path} not found, initializing new data structure.")
|
||||||
|
return default
|
||||||
|
|
||||||
|
def format_time(seconds):
|
||||||
|
hrs = seconds // 3600
|
||||||
|
mins = (seconds % 3600) // 60
|
||||||
|
secs = seconds % 60
|
||||||
|
return f"{hrs:02d}:{mins:02d}:{secs:02d}"
|
||||||
|
|
||||||
|
def pick_random_fact(facts):
|
||||||
|
return random.choice(facts) if facts else None
|
||||||
|
|
||||||
|
def clear_terminal():
|
||||||
|
os.system('cls' if os.name == 'nt' else 'clear')
|
||||||
|
|
||||||
|
def display_leaderboard(title, leaderboard, key, limit=10):
|
||||||
|
print(f"\n {title}\n")
|
||||||
|
if not leaderboard:
|
||||||
|
print("(No users yet)")
|
||||||
|
return
|
||||||
|
print(f"{'Rank':>4} {'Username':<20} {title}")
|
||||||
|
print("-" * 36)
|
||||||
|
for i, entry in enumerate(leaderboard[:limit], start=1):
|
||||||
|
name = entry['username']
|
||||||
|
value = entry[key]
|
||||||
|
display_val = format_time(value) if key == 'lifetime_seconds' else str(value)
|
||||||
|
print(f"{i:>4} {name:<20} {display_val}")
|
||||||
|
|
||||||
|
def display_entropy_leaderboard(c, limit=10):
|
||||||
|
c.execute("SELECT username, entropy_score FROM users ORDER BY entropy_score DESC LIMIT ?", (limit,))
|
||||||
|
entropy_lb = [{"username": r[0], "entropy_score": r[1]} for r in c.fetchall()]
|
||||||
|
|
||||||
|
print("\n Top 10 Users by Entropy Score\n")
|
||||||
|
if not entropy_lb:
|
||||||
|
print("(No users yet)")
|
||||||
|
return
|
||||||
|
print(f"{'Rank':>4} {'Username':<20} Entropy Score (bits)")
|
||||||
|
print("-" * 36)
|
||||||
|
for i, entry in enumerate(entropy_lb, start=1):
|
||||||
|
print(f"{i:>4} {entry['username']:<20} {entry['entropy_score']:.4f}")
|
||||||
|
|
||||||
|
def non_blocking_input(timeout=0.0):
|
||||||
|
"""Non-blocking input on Unix and fallback on Windows."""
|
||||||
|
if os.name == 'nt':
|
||||||
|
import msvcrt
|
||||||
|
if msvcrt.kbhit():
|
||||||
|
return msvcrt.getwch()
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
if select.select([sys.stdin], [], [], timeout)[0]:
|
||||||
|
return sys.stdin.readline().strip()
|
||||||
|
return None
|
||||||
|
|
||||||
|
def run_timer():
|
||||||
|
username = input("Enter your username for leaderboard tracking: ").strip() or "Anonymous"
|
||||||
|
|
||||||
|
conn = init_db()
|
||||||
|
c = conn.cursor()
|
||||||
|
trivia_data = load_trivia_data(TRIVIA_FILE, {})
|
||||||
|
|
||||||
|
ensure_user_exists(c, username)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
def session_loop():
|
||||||
|
c.execute("INSERT INTO sessions (username) VALUES (?)", (username,))
|
||||||
|
session_id = c.lastrowid
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
session_seconds = 0
|
||||||
|
trivia_points_this_session = 0
|
||||||
|
shown_markers = set()
|
||||||
|
shown_facts = []
|
||||||
|
|
||||||
|
print("Cosmic Timer started.")
|
||||||
|
print("Type 'p' to pause, 'q' to quit, or 't' to list DB tables.\n")
|
||||||
|
|
||||||
|
intervals = [300, 600, 1800, 3600] # base intervals to loop after 1 hour
|
||||||
|
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
time.sleep(1)
|
||||||
|
session_seconds += 1
|
||||||
|
|
||||||
|
# Determine the trivia key based on current session_seconds
|
||||||
|
if session_seconds <= 3600:
|
||||||
|
key = str(session_seconds)
|
||||||
|
else:
|
||||||
|
# Loop intervals after the first hour
|
||||||
|
elapsed_after_hour = session_seconds - 3600
|
||||||
|
cycle_time = elapsed_after_hour % 3600
|
||||||
|
|
||||||
|
# Find if cycle_time matches one of the intervals exactly
|
||||||
|
if cycle_time in intervals:
|
||||||
|
key = str(cycle_time)
|
||||||
|
else:
|
||||||
|
key = None
|
||||||
|
|
||||||
|
if key and key in trivia_data and session_seconds not in shown_markers:
|
||||||
|
fact = pick_random_fact(trivia_data[key])
|
||||||
|
if fact:
|
||||||
|
shown_facts.append(f"⏱ {format_time(session_seconds)} → {fact}")
|
||||||
|
shown_markers.add(session_seconds)
|
||||||
|
weight = TRIVIA_WEIGHTS.get(key, 1)
|
||||||
|
trivia_points_this_session += weight
|
||||||
|
insert_trivia_event(c, username, session_id, session_seconds, weight)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
clear_terminal()
|
||||||
|
print(f" Cosmic Timer — User: {username}")
|
||||||
|
print(f"Session Time: {format_time(session_seconds)}\n")
|
||||||
|
print(" Trivia So Far:")
|
||||||
|
for f in shown_facts:
|
||||||
|
print(f)
|
||||||
|
|
||||||
|
cmd = non_blocking_input()
|
||||||
|
|
||||||
|
if cmd:
|
||||||
|
cmd = cmd.lower()
|
||||||
|
if cmd == 'p':
|
||||||
|
input("\n=== PAUSED === Press Enter to continue...")
|
||||||
|
elif cmd == 'q':
|
||||||
|
raise KeyboardInterrupt
|
||||||
|
elif cmd == 't':
|
||||||
|
list_tables()
|
||||||
|
input("\nPress Enter to continue...")
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
return session_seconds, trivia_points_this_session, shown_facts, session_id
|
||||||
|
|
||||||
|
while True:
|
||||||
|
session_seconds, trivia_points_this_session, shown_facts, session_id = session_loop()
|
||||||
|
|
||||||
|
lifetime_seconds, total_trivia_points, carbon_footprint, entropy_score = update_user_stats(
|
||||||
|
c, username, session_seconds, trivia_points_this_session)
|
||||||
|
update_session_end(c, session_id, session_seconds)
|
||||||
|
lifetime_rank, trivia_rank = insert_leaderboard_snapshot(c, username)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
clear_terminal()
|
||||||
|
print("\n\nExiting Cosmic Timer.")
|
||||||
|
print(f"User: {username}")
|
||||||
|
print(f"Session Runtime: {format_time(session_seconds)}")
|
||||||
|
print(f"Lifetime Runtime: {format_time(lifetime_seconds)}")
|
||||||
|
print(f"Estimated Carbon Footprint: {carbon_footprint:.6f} kg CO2")
|
||||||
|
print(f"Trivia Points This Session: {trivia_points_this_session}")
|
||||||
|
print(f"Total Trivia Points: {total_trivia_points}")
|
||||||
|
print(f"Entropy Score: {entropy_score:.4f} bits")
|
||||||
|
|
||||||
|
if shown_facts:
|
||||||
|
print("\n Grand Cosmic Fact:")
|
||||||
|
print(random.choice(shown_facts))
|
||||||
|
else:
|
||||||
|
print("\n(No cosmic facts were obtained this run.)")
|
||||||
|
|
||||||
|
c.execute("SELECT username, lifetime_seconds FROM users ORDER BY lifetime_seconds DESC LIMIT 10")
|
||||||
|
lifetime_lb = [{"username": r[0], "lifetime_seconds": r[1]} for r in c.fetchall()]
|
||||||
|
c.execute("SELECT username, trivia_points FROM users ORDER BY trivia_points DESC LIMIT 10")
|
||||||
|
trivia_lb = [{"username": r[0], "trivia_points": r[1]} for r in c.fetchall()]
|
||||||
|
|
||||||
|
display_leaderboard("Top 10 Users by Lifetime Time", lifetime_lb, "lifetime_seconds")
|
||||||
|
display_leaderboard("Top 10 Users by Trivia Points", trivia_lb, "trivia_points")
|
||||||
|
display_entropy_leaderboard(c)
|
||||||
|
|
||||||
|
choice = input("\nStart a new session? (y/n): ").strip().lower()
|
||||||
|
if choice != 'y':
|
||||||
|
break
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
print("\n May you be as productive as the universe is efficent!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run_timer()
|
||||||
|
|
||||||
66
trivia_facts.json
Normal file
66
trivia_facts.json
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"300": [
|
||||||
|
"Your brain has generated about 0.001 kWh of energy in the last 5 minutes.",
|
||||||
|
"The ISS has traveled roughly 2,300 km around Earth.",
|
||||||
|
"Light travels ~90 million km — nearly the Earth–Sun distance.",
|
||||||
|
"The Sun emits more energy than all of humanity uses in a year.",
|
||||||
|
"Over 1.5 billion tons of hydrogen fuse into helium in the Sun.",
|
||||||
|
"The Earth rotates about 1.25 degrees on its axis.",
|
||||||
|
"15,000 stars are born somewhere in the observable universe.",
|
||||||
|
"Voyager 1 travels ~300 km deeper into interstellar space.",
|
||||||
|
"~450,000 neutrinos from the Sun have passed through each square millimeter of your body.",
|
||||||
|
"The Milky Way moves ~3,750 km through the cosmic microwave background.",
|
||||||
|
"Around 200 gamma-ray bursts from distant galaxies have zoomed silently across space.",
|
||||||
|
"Earth’s magnetic field has shifted by a measurable fraction — an echo of its slow reversal dance.",
|
||||||
|
"Your heart pumped about 1,000 gallons of blood.",
|
||||||
|
"You blinked about 75 times in the last 5 minutes"
|
||||||
|
|
||||||
|
],
|
||||||
|
"600": [
|
||||||
|
"10 minutes ago, somewhere in the world, 1000+ earthquakes just occurred—most too small to feel.",
|
||||||
|
"Earth moves ~18,000 km in its orbit around the Sun.",
|
||||||
|
"The solar system orbits ~1,000 km closer to its galactic destiny.",
|
||||||
|
"Roughly 30,000 stars have been born — some already dying in violence.",
|
||||||
|
"A star collapses into a black hole in a distant, unseeable corner.",
|
||||||
|
"Hundreds of meteoroids the size of grains hit Earth's atmosphere.",
|
||||||
|
"A single photon from the edge of the observable universe has just reached Earth — 13.8 billion years in transit.",
|
||||||
|
"On a neutron star, a crustquake releases more energy than all nuclear weapons ever built.",
|
||||||
|
"Jupiter's magnetic field has just sculpted a filament of plasma millions of kilometers long.",
|
||||||
|
"Somewhere, two black holes are spiraling closer by a few millimeters — set to merge in a billion years.",
|
||||||
|
"Earth’s atmosphere thins, shifts, breathes — weather patterns ripple outward from it like planetary skin.",
|
||||||
|
"Did you feel that? Gravity waves from distant, massive mergers of black holes or neutron stars will ripple through spacetime",
|
||||||
|
"In the last 10 minutes, Cosmic rays—charged atomic nuclei traveling at nearly light speed—will slam into Earth's atmosphere by the trillions in ten minutes, generating showers of secondary particles cascading through the air above us."
|
||||||
|
|
||||||
|
],
|
||||||
|
"1800": [
|
||||||
|
"In 30 minutes, the Sun has emitted more energy than humans have used in all of history.",
|
||||||
|
"Half an hour of typing burns about 30 calories.",
|
||||||
|
"Earth rotates ~7.5 degrees; every point on the equator moves ~1,800 km.",
|
||||||
|
"The Sun emits more photons than there are grains of sand on Earth — and that’s just now.",
|
||||||
|
"The Milky Way rotates ~180,000 km at its outer edge.",
|
||||||
|
"Over 90,000 stars have gone supernova and vanished from history’s eye.",
|
||||||
|
"The Moon’s gravity has pulled Earth’s oceans a few centimeters closer — the tide turning.",
|
||||||
|
"The Andromeda Galaxy has come ~180 km closer to collision with the Milky Way.",
|
||||||
|
"Roughly 100 white dwarfs have formed from dying sunlike stars.",
|
||||||
|
"Cosmic rays have slammed into Earth’s atmosphere with the energy of baseballs.",
|
||||||
|
"A rogue planet — orphaned from any star — has drifted thousands of kilometers through cold void.",
|
||||||
|
"Somewhere, a planet just entered the habitable zone of a red dwarf, quietly waiting for life."
|
||||||
|
|
||||||
|
],
|
||||||
|
"3600": [
|
||||||
|
"In the past hour, Earth’s rotation has carried you about 1,670 km along its surface (at the equator).",
|
||||||
|
"60 minutes ago, the oldest light we can detect was still traveling for 13.8 billion years to reach us.",
|
||||||
|
"Earth moves ~107,000 km in its solar orbit — faster than any spacecraft we’ve launched.",
|
||||||
|
"~360,000 stars have gone supernova, each altering space-time and matter forever.",
|
||||||
|
"The Moon drifts 3.8 cm farther from Earth — a heartbeat of loss.",
|
||||||
|
"The Solar System has rotated ~720,000 km around the galactic core.",
|
||||||
|
"Over 300 million tons of cosmic dust have shifted in galaxies across the local group.",
|
||||||
|
"A galaxy cluster somewhere has absorbed another — thousands of galaxies now eaten.",
|
||||||
|
"The Sun loses ~1.3 billion tons of mass to solar radiation.",
|
||||||
|
"Jupiter’s magnetic field has completed a full rotation of its auroral arcs.",
|
||||||
|
"~10,000 gamma-ray bursts have happened across the cosmos. Most we will never see.",
|
||||||
|
"A trillion neutrinos from cosmic sources have passed through your body — silent messengers of ancient violence."
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user