i think im a parasite or smth #1
1 changed files with 342 additions and 323 deletions
23
r2chat.py
23
r2chat.py
|
|
@ -9,12 +9,25 @@ from plyer import notification
|
|||
import pygame as media
|
||||
import webbrowser
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
if sys.platform == "win32":
|
||||
ROOT = Path("C:/Users/Public")
|
||||
else:
|
||||
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"
|
||||
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}")
|
||||
return DEFAULT_CONFIG.copy()
|
||||
|
||||
|
||||
|
||||
class r2chat:
|
||||
def __init__(self, root):
|
||||
self.root = root
|
||||
self.cfg = load_config()
|
||||
self.root.title(f"r2chat :: {username}")
|
||||
self.root.title(f"r2chat :: {username} / #{CHANCHAN}")
|
||||
|
||||
self.last_size = 0
|
||||
|
||||
|
|
@ -120,6 +135,10 @@ class r2chat:
|
|||
|
||||
def send_message(self, event=None):
|
||||
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:
|
||||
timestamp = time.strftime("%y/%m/%d %H:%M")
|
||||
line = f"[{timestamp}] (({self.cfg['user_color']} | {username})): {msg}\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue