i think im a parasite or smth #1

Merged
Dogo6647 merged 1 commit from :master into master 2026-04-12 02:55:50 +09:00

View file

@ -9,12 +9,25 @@ from plyer import notification
import pygame as media import pygame as media
import webbrowser import webbrowser
import re import re
import subprocess
if sys.platform == "win32": if sys.platform == "win32":
ROOT = Path("C:/Users/Public") ROOT = Path("C:/Users/Public")
else: else:
ROOT = Path("/var/tmp") ROOT = Path("/var/tmp")
CHAT_FILE = ROOT / "r2chat" / "chat.txt"
try:
if sys.argv[1]!='chat':
CHANCHAN = sys.argv[1].replace(' ','_').replace('.','-')
CHANNEL = 'chat_'+CHANCHAN
else:
CHANNEL = 'chat'
CHANCHAN = 'chat'
except:
CHANNEL = 'chat'
CHANCHAN = 'chat'
CHAT_FILE = ROOT / "r2chat" / f"{CHANNEL}.txt"
CONFIG_FILE = Path.home() / "r2chat.config.json" CONFIG_FILE = Path.home() / "r2chat.config.json"
os.makedirs(os.path.dirname(CHAT_FILE), exist_ok=True) os.makedirs(os.path.dirname(CHAT_FILE), exist_ok=True)
@ -52,11 +65,13 @@ def load_config():
print(f":) created default config at {CONFIG_FILE}") print(f":) created default config at {CONFIG_FILE}")
return DEFAULT_CONFIG.copy() return DEFAULT_CONFIG.copy()
class r2chat: class r2chat:
def __init__(self, root): def __init__(self, root):
self.root = root self.root = root
self.cfg = load_config() self.cfg = load_config()
self.root.title(f"r2chat :: {username}") self.root.title(f"r2chat :: {username} / #{CHANCHAN}")
self.last_size = 0 self.last_size = 0
@ -120,6 +135,10 @@ class r2chat:
def send_message(self, event=None): def send_message(self, event=None):
msg = self.entry.get().strip() msg = self.entry.get().strip()
if msg and msg.startswith("/join #"):
subprocess.Popen(f'pythonw "{os.path.abspath(__file__)}" "{msg[7:len(msg)]}"', shell=True)
msg = ''
self.entry.delete(0, tk.END)
if msg: if msg:
timestamp = time.strftime("%y/%m/%d %H:%M") timestamp = time.strftime("%y/%m/%d %H:%M")
line = f"[{timestamp}] (({self.cfg['user_color']} | {username})): {msg}\n" line = f"[{timestamp}] (({self.cfg['user_color']} | {username})): {msg}\n"