This commit is contained in:
norohind committed 2025-05-24 00:39:24 +00:00
1 parent 5ba816715e
commit a37f162b21
1 file changed
+68 -20
+68 -20
View File
@@ -62,7 +62,7 @@ class App:
self.running = True self.running = True
if not (discord_webhook_url.startswith("https://") or do_mock_discord): if not (discord_webhook_url.startswith("https://") or do_mock_discord):
msg = f'{discord_webhook_url} не вебхук, так то' msg = f"{discord_webhook_url} не вебхук, так то"
print(msg) print(msg)
raise RuntimeError(msg) raise RuntimeError(msg)
@@ -184,27 +184,54 @@ class DeathLogGUI:
config_frame.pack(fill=tk.X, pady=5) config_frame.pack(fill=tk.X, pady=5)
# Log file path # Log file path
ttk.Label(config_frame, text="Log File Path:").grid(row=0, column=0, sticky=tk.W, pady=2) ttk.Label(config_frame, text="Log File Path:").grid(
ttk.Entry(config_frame, textvariable=self.log_path, width=50).grid(row=0, column=1, sticky=tk.W+tk.E, pady=2, padx=5) row=0, column=0, sticky=tk.W, pady=2
ttk.Button(config_frame, text="Browse", command=self.browse_log_file).grid(row=0, column=2, pady=2) )
ttk.Entry(config_frame, textvariable=self.log_path, width=50).grid(
row=0, column=1, sticky=tk.W + tk.E, pady=2, padx=5
)
ttk.Button(config_frame, text="Browse", command=self.browse_log_file).grid(
row=0, column=2, pady=2
)
# Discord webhook URL # Discord webhook URL
ttk.Label(config_frame, text="Discord Webhook URL:").grid(row=1, column=0, sticky=tk.W, pady=2) ttk.Label(config_frame, text="Discord Webhook URL:").grid(
ttk.Entry(config_frame, textvariable=self.webhook_url, width=50).grid(row=1, column=1, sticky=tk.W+tk.E, pady=2, padx=5) row=1, column=0, sticky=tk.W, pady=2
)
ttk.Entry(config_frame, textvariable=self.webhook_url, width=50).grid(
row=1, column=1, sticky=tk.W + tk.E, pady=2, padx=5
)
# Checkboxes # Checkboxes
ttk.Checkbutton(config_frame, text="Process existing log entries", variable=self.do_backread).grid(row=2, column=0, columnspan=2, sticky=tk.W, pady=2) ttk.Checkbutton(
ttk.Checkbutton(config_frame, text="Mock Discord (don't send actual messages)", variable=self.do_mock_discord).grid(row=3, column=0, columnspan=2, sticky=tk.W, pady=2) config_frame, text="Process existing log entries", variable=self.do_backread
ttk.Checkbutton(config_frame, text="Hide NPC kills (_NPC_ in name)", variable=self.hide_npc_kills).grid(row=4, column=0, columnspan=2, sticky=tk.W, pady=2) ).grid(row=2, column=0, columnspan=2, sticky=tk.W, pady=2)
ttk.Checkbutton(
config_frame,
text="Mock Discord (don't send actual messages)",
variable=self.do_mock_discord,
).grid(row=3, column=0, columnspan=2, sticky=tk.W, pady=2)
ttk.Checkbutton(
config_frame,
text="Hide NPC kills (_NPC_ in name)",
variable=self.hide_npc_kills,
).grid(row=4, column=0, columnspan=2, sticky=tk.W, pady=2)
# Control buttons # Control buttons
control_frame = ttk.Frame(main_frame) control_frame = ttk.Frame(main_frame)
control_frame.pack(fill=tk.X, pady=5) control_frame.pack(fill=tk.X, pady=5)
self.start_button = ttk.Button(control_frame, text="Start Monitoring", command=self.start_monitoring) self.start_button = ttk.Button(
control_frame, text="Start Monitoring", command=self.start_monitoring
)
self.start_button.pack(side=tk.LEFT, padx=5) self.start_button.pack(side=tk.LEFT, padx=5)
self.stop_button = ttk.Button(control_frame, text="Stop Monitoring", command=self.stop_monitoring, state=tk.DISABLED) self.stop_button = ttk.Button(
control_frame,
text="Stop Monitoring",
command=self.stop_monitoring,
state=tk.DISABLED,
)
self.stop_button.pack(side=tk.LEFT, padx=5) self.stop_button.pack(side=tk.LEFT, padx=5)
# Status indicator # Status indicator
@@ -212,21 +239,27 @@ class DeathLogGUI:
status_frame = ttk.Frame(main_frame) status_frame = ttk.Frame(main_frame)
status_frame.pack(fill=tk.X, pady=5) status_frame.pack(fill=tk.X, pady=5)
ttk.Label(status_frame, text="Status:").pack(side=tk.LEFT) ttk.Label(status_frame, text="Status:").pack(side=tk.LEFT)
self.status_label = ttk.Label(status_frame, textvariable=self.status_var, foreground="red") self.status_label = ttk.Label(
status_frame, textvariable=self.status_var, foreground="red"
)
self.status_label.pack(side=tk.LEFT, padx=5) self.status_label.pack(side=tk.LEFT, padx=5)
# Kill events display # Kill events display
kills_frame = ttk.LabelFrame(main_frame, text="Recent Kill Events", padding="10") kills_frame = ttk.LabelFrame(
main_frame, text="Recent Kill Events", padding="10"
)
kills_frame.pack(fill=tk.BOTH, expand=True, pady=5) kills_frame.pack(fill=tk.BOTH, expand=True, pady=5)
self.kill_display = scrolledtext.ScrolledText(kills_frame, wrap=tk.WORD, height=10) self.kill_display = scrolledtext.ScrolledText(
kills_frame, wrap=tk.WORD, height=10
)
self.kill_display.pack(fill=tk.BOTH, expand=True) self.kill_display.pack(fill=tk.BOTH, expand=True)
self.kill_display.config(state=tk.DISABLED) self.kill_display.config(state=tk.DISABLED)
def browse_log_file(self): def browse_log_file(self):
filename = filedialog.askopenfilename( filename = filedialog.askopenfilename(
title="Select Star Citizen Log File", title="Select Star Citizen Log File",
filetypes=[("Log Files", "*.log"), ("All Files", "*.*")] filetypes=[("Log Files", "*.log"), ("All Files", "*.*")],
) )
if filename: if filename:
self.log_path.set(filename) self.log_path.set(filename)
@@ -245,10 +278,12 @@ class DeathLogGUI:
do_backread=self.do_backread.get(), do_backread=self.do_backread.get(),
do_mock_discord=self.do_mock_discord.get(), do_mock_discord=self.do_mock_discord.get(),
hide_npc_kills=self.hide_npc_kills.get(), hide_npc_kills=self.hide_npc_kills.get(),
kill_callback=self.on_kill kill_callback=self.on_kill,
) )
self.monitor_thread = threading.Thread(target=self.app.process_lines, daemon=True) self.monitor_thread = threading.Thread(
target=self.app.process_lines, daemon=True
)
self.monitor_thread.start() self.monitor_thread.start()
self.status_var.set("Monitoring active") self.status_var.set("Monitoring active")
@@ -285,7 +320,9 @@ class DeathLogGUI:
if kill.victim == kill.killer: if kill.victim == kill.killer:
formatted_message = f"[{timestamp}] 🤦 {kill.victim} (self-kill)\n" formatted_message = f"[{timestamp}] 🤦 {kill.victim} (self-kill)\n"
else: else:
formatted_message = f"[{timestamp}] 💀 {kill.victim} killed by 🔫 {kill.killer}\n" formatted_message = (
f"[{timestamp}] 💀 {kill.victim} killed by 🔫 {kill.killer}\n"
)
self.recent_kills.append(formatted_message) self.recent_kills.append(formatted_message)
if len(self.recent_kills) > self.max_kills_to_display: if len(self.recent_kills) > self.max_kills_to_display:
@@ -307,13 +344,24 @@ def main():
try: try:
# Check if we should run in GUI mode or CLI mode # Check if we should run in GUI mode or CLI mode
import sys import sys
if len(sys.argv) > 1 and sys.argv[1] == "--cli": if len(sys.argv) > 1 and sys.argv[1] == "--cli":
# CLI mode # CLI mode
if DEBUG is True: if DEBUG is True:
app = App(Path("./Game.log"), DEFAULT_DISCORD_WEBHOOK_URL, do_mock_discord=True, do_backread=True, hide_npc_kills=False) app = App(
Path("./Game.log"),
DEFAULT_DISCORD_WEBHOOK_URL,
do_mock_discord=True,
do_backread=True,
hide_npc_kills=False,
)
else: else:
app = App(DEFAULT_LOG_FILE_PATH, DEFAULT_DISCORD_WEBHOOK_URL, hide_npc_kills=False) app = App(
DEFAULT_LOG_FILE_PATH,
DEFAULT_DISCORD_WEBHOOK_URL,
hide_npc_kills=False,
)
app.process_lines() app.process_lines()
else: else: