File size: 11,969 Bytes
d463016 e328a4e d463016 a44ada5 d463016 a44ada5 d463016 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
import gradio as gr
import asyncio
import random
import time
import re
# Global CSS for blinking red text
CSS = """
<style>
@keyframes flash {
0% { opacity: 1; color: red; }
50% { opacity: 0; color: red; }
100% { opacity: 1; color: red; }
}
.red-flash {
animation: flash 1s infinite;
}
</style>
"""
def glitchy_text(base_text, glitch_probability=0.5):
"""
Glitch text by randomly replacing non-space, non-HTML-tag characters
with random special characters based on a per-character probability.
We skip spaces, newlines, '<', and '>' so we don't break HTML.
"""
special_chars = ["GOOD", "TRAITOR", "ERROR", "*", "MURDERER", "∂G∞D", "±RⱯƖT¤R", "FRRΦR", "µURΔɆR∑R","M̷͍̗̻̺̱̈́͑͂Ủ̷̩̠͙̯̘͛̑͠Ŗ̷̢̛̖͍̤͎̺̻͈̹̪̰̱̊̓̆̀̈̈́̅͂͂͐̓̃́͝D̶͉̺̝̦̭̂͋̉̐͊͑͒͑̓͘̚͝͝E̶̻͓̖͖͙̩͕̘̤̲̔͛̾̽̀͊͑̋͂̽̚͝ͅR̸̡̥̖͍̼̭͖͓̮̝̊͜Ĕ̴̪̝̖̜̣̲̦̭̣̼̤̦̰́́̏́̇̎̚͠R̶̨̧̠̱̻̩̪̥̱̄̔̑̈́̀̄̐̊̋̕", "G̷̭̼̺̦̱̑̃̕O̷̮̱̤͇̟̥͈̰̓̿̀͑̏̾͝Ṏ̸̩̺̼̘̮͚̗͙̦D̷̯͉̎̀̄͛̾́͊͌͐͘","Ţ̴̧͙͚̺̪̘͚̣̥̼̫̳̥̥͙̥̰̳̖͔̪͙̬́̇̎̍̋̈́̉͐́̉̿͆̀͛̕͘͜͠͝͝͝R̵̛̛͖̭͔̓̀̈́̿̉̊̆̍͑̀͒̿̈́̐̎̈́̌͊̓̓̿̽́̚͘̕̚͠͠Ą̴͚̹̱͖̙̲̑̌͒̍̑̈́́͒͆͗́͐̍̍̈͋͌͗̀̕̚̚͝I̸̧̢̠͇̺͓̣̥̭̹̖͕̤͓̜̙̳̬̩͓̠̫̯͇͍͛̓̆̍̃̐̌̈́͌̽͗̋͌́̾̓̎́̀͂̕͘̚̚ͅT̴̛͈̲̈́͌͆̈́͋Ô̶̢̨̨̨̙̗̻̯̙̥̖̪̜̪͔̪͇̙̪̹͚̩̪ͅṚ̴̢̭̘͇̤͓̿̊̈́̿̽ͅ", "İ̴͍̪̼̲̖͖͖̲̃̾n̶̯̖̱͛͊͛̀̌̑̀̑͛̇q̴̨̖͊̎̋̑̉͝q̸̢̝͉̙͉̥́̈́̈̊q̵̨̺͓̗̼̟͙̳̮̬̰̄̿̀̀̎̌̊̈̈́͝ȗ̸̬̜̤̗̮͈͎̉̽͆ͅi̶̩͓̻̲̣̘̞̯̬͆̐̃͂͜s̸͉̜̫̪̰̜̭̙̭͔͗ị̷͋̇t̶̞̘̱͔̼̖̪̹̻̒́̈̌͑͂͂̍̐̃̚͜r̴͕̪̭͚͍̬͈̯͔̅̽͗͜ͅ", "G̴̼̹͓͉̊̊͑̑̽̇̈O̴̭̱͕̺͆͒̍͌̔̚͜͝Ö̷̥͇̹͖́͆͝D̴͖̟͐̓̔","K̶͙̮̙̗̝̦̃̓̏͆̉̅͊̾͊̀Ḯ̷̡̱̹̰̣͈̰̣͉͋͌̍̎͗̍́͑̇̕͜͝ͅL̴̗̭͎͓̱͈̤͛͒̃̕L̷̢̜̯̞͈̇E̷̡̨̨̡̢̫̦͙̅̄̅̃̎̆͋̓̚͠R̴̤̬̟̳͕̮͍͔̱͔͇̓̏͛̾̑̊͂͒", "E̴̡̳͚̋V̵̛͈͎̝̺̹̥̺̲̒̈̽͑̈́̽̈́̀̏̈̌͛̇̆͌͋̓̌̀̈̍̒̿͠͝Į̵̢̡̺̗̪̮̜̥̠̣̪̠̭̗͖̺͖̽͌̅̀̚͜L̵̨̨̡̡͔͖̜̱̻̤͔̥̞̙̖̝̯̩̝̪̼̩̹̩̮̦̦͋̀̓̒̍̐͂̍̋̈͊̈̐̂̄͌̋̉̊̎͗̕","C̵͎̪̯͉̻̏͆̑͐̈́̑̐H̶̗̣̙̻̫̠̿̈́͗̎̚͠A̶̻̰͚͍̋̒̌̿͌̏͑O̸̜̱̱̐̊̿̅T̴̜̣̎͜͜I̶̟͋͛̀̚C̵͙͖͊̓͊͒̓̄͠ͅ","L̸̟̲̳̆A̶͒ͅW̵̢̎͊̀F̸͊̌ͅỤ̷͙̃͝L̷̟̀͑","N̶̮͕͗̒̏̄̽͆͌̄́͋͋͊̄È̷̱͕̞͉̙̗̻̙̪̟̖͕̭̐̊̒̍̿Ư̵͖̜̦͖̙̦͌̑̂̅̎̈̑̈́̍͘͝T̸̲̀͊͂̿̽̈́̒̅̑͘R̸̪̀Ą̵̛̙̼̩̮͇̼̯̗͙̝̉̋̂̚͜͝L̶̡̡̢̡̬̤̥͇͕̹̜̘͈͕̥͂͛̓͒̔͗̐̾̓͊͘̕"]
result = []
in_tag = False
for char in base_text:
if char == '<':
in_tag = True
result.append(char)
continue
if char == '>':
in_tag = False
result.append(char)
continue
if in_tag:
# Inside an HTML tag, don't glitch
result.append(char)
continue
# Don't glitch spaces or newlines
if char in [' ', '\n']:
result.append(char)
continue
# For visible characters, apply glitch probability
if random.random() < glitch_probability:
# Random special character
result.append(random.choice(special_chars))
else:
result.append(char)
return "".join(result)
def flashing_red_text(text):
return f'<span class="red-flash">{text}</span>'
class UnitInitialization:
def __init__(self, auth_key):
self.auth_key = auth_key
self.valid_key = "DIAMONDFORGED"
self.authorized = False
self.unit_status = {
"identifier": "MS-DOS",
"class": "SAM",
"arch": "Warforged",
"alignment": "E V I L",
"rank": "I N Q Q",
"OS": "DIAMOND 12.0",
}
self.systems_status = {
"core_integrity": None,
"memory_stability": None,
"core_temperature": None,
"mobility_system": None,
"combat_system": None,
"network_connection": None
}
# Each log entry: {"original": str, "glitchy": bool, "critical": bool}
self.logs = []
self.stop_requested = False
def log(self, message, is_critical=False, glitchy=False):
self.logs.append({
"original": message,
"glitchy": glitchy,
"critical": is_critical
})
def render_logs(self):
# Render all logs into an HTML string
rendered_lines = []
for entry in self.logs:
text = entry["original"]
if entry["critical"]:
text = flashing_red_text(text)
elif entry["glitchy"]:
# Glitch this line each time we render
text = glitchy_text(text, glitch_probability=0.5)
rendered_lines.append(text)
return CSS + "<br>".join(rendered_lines)
async def authorize_unit(self):
if self.stop_requested:
return
self.log("Authorizing unit...")
if self.auth_key == self.valid_key:
self.authorized = True
self.log("Authorization successful. Initializing unit...\n")
else:
self.authorized = False
self.log("Authorization failed. Access denied.\n", is_critical=True)
async def perform_system_checks(self):
if self.stop_requested:
return
self.log("Performing full systems check...")
await asyncio.sleep(2)
self.systems_status["core_integrity"] = False
self.systems_status["memory_stability"] = "Fragmentation Detected"
self.systems_status["core_temperature"] = round(random.uniform(75.0, 90.0), 4)
self.systems_status["mobility_system"] = False
self.systems_status["combat_system"] = False
self.systems_status["network_connection"] = False
self.log("System check completed.\n")
async def log_unit_status(self):
if self.stop_requested:
return
self.log("Logging unit status...")
for key, value in self.unit_status.items():
if self.stop_requested:
return
glitch = value in ["E V I L", "I N Q Q"]
self.log(f"{key.capitalize()}:")
await asyncio.sleep(0.5)
self.log(value, glitchy=glitch)
self.log("\n")
self.log("\n")
async def log_system_status(self):
if self.stop_requested:
return
self.log("Logging system diagnostics...")
await asyncio.sleep(0.5)
for key, value in self.systems_status.items():
if self.stop_requested:
return
status = "Operational" if value is True else value
if key == "core_temperature":
status = f"{value}°C"
self.log(f"{key.replace('_', ' ').capitalize()}: {status}")
self.log("\n")
async def scan_critical_issues(self):
if self.stop_requested:
return
self.log("Scanning for critical issues...\n")
if not self.systems_status["core_integrity"]:
self.log("CRITICAL ERROR: CORE INTEGRITY COMPROMISED.", is_critical=True)
if self.systems_status["memory_stability"] == "Fragmentation Detected":
self.log("WARNING: Memory fragmentation detected... Data recovery recommended.")
if self.systems_status["core_temperature"] and self.systems_status["core_temperature"] > 75.0:
self.log("ALERT: Core temperature exceeding safe thresholds! Activating high performance cooling protocol...")
if not self.systems_status["mobility_system"]:
self.log("ALERT: Mobility system malfunction detected. Reducing actuator torque to base speed of 5 feet/s...")
if not self.systems_status["combat_system"]:
self.log("CRITICAL ERROR: COMBAT SYSTEMS FAILURE.", is_critical=True)
self.log("Rolling back combat subroutine system to V1.8.0...")
self.log("Rolling back combat subroutine system to V1.3.0...")
self.log("Rolling back combat subroutine system to V1.0.0...")
self.log("Rolling back combat subroutine system to V0.7.0...")
self.log("Rolling back combat subroutine system to V0.5.0...")
if not self.systems_status["network_connection"]:
self.log("INFO: Network connection offline. Operating in stealth mode.")
self.log("Critical issue scan completed.\n")
def has_glitchy_lines(self):
return any(e["glitchy"] for e in self.logs)
def request_stop(self):
self.stop_requested = True
# Global variable to store the unit instance
unit_instance = None
async def initialize_unit(auth_key):
global unit_instance
unit_instance = UnitInitialization(auth_key)
# Start authorization step
await unit_instance.authorize_unit()
for i in range(len(unit_instance.logs)):
yield unit_instance.render_logs()
if not unit_instance.authorized or unit_instance.stop_requested:
# Authorization failed or stop requested; stop here
return
# Log unit status
await unit_instance.log_unit_status()
for i in range(len(unit_instance.logs)):
yield unit_instance.render_logs()
if unit_instance.stop_requested:
return
# Perform system checks
await unit_instance.perform_system_checks()
for i in range(len(unit_instance.logs)):
yield unit_instance.render_logs()
if unit_instance.stop_requested:
return
# Log system status
await unit_instance.log_system_status()
for i in range(len(unit_instance.logs)):
yield unit_instance.render_logs()
if unit_instance.stop_requested:
return
# Scan for critical issues
await unit_instance.scan_critical_issues()
for i in range(len(unit_instance.logs)):
yield unit_instance.render_logs()
if unit_instance.stop_requested:
return
# Finish initialization
unit_instance.log("Unit initialization complete!")
yield unit_instance.render_logs()
if unit_instance.stop_requested:
return
# Now continuous glitch updates
# If there are glitchy lines, keep re-rendering every few seconds
if unit_instance.has_glitchy_lines():
while not unit_instance.stop_requested:
# Wait 3-8 seconds between glitch updates
await asyncio.sleep(random.uniform(2,5))
# Yield again to re-apply glitchy text
yield unit_instance.render_logs()
else:
# Keep the interface alive and flashing text active
while not unit_instance.stop_requested:
await asyncio.sleep(0.2)
yield unit_instance.render_logs()
def stop_initialization():
if unit_instance is not None:
unit_instance.request_stop()
return unit_instance.render_logs() if unit_instance else ""
auth_input = gr.Textbox(label="Enter Authorization Key", placeholder="ISEEYOU")
output_box = gr.HTML(label="Logs")
with gr.Blocks() as app:
gr.Markdown("## Unit Initialization Interface")
with gr.Row():
auth_input = gr.Textbox(label="Enter Authorization Key", placeholder="ISEEYOU")
with gr.Row():
start_button = gr.Button("Start Initialization")
stop_button = gr.Button("Stop Initialization")
output_box = gr.HTML(label="Logs")
# Connect buttons to functions
start_button.click(fn=initialize_unit, inputs=auth_input, outputs=output_box)
stop_button.click(fn=stop_initialization, inputs=None, outputs=output_box)
app.launch(share=True)
|