forked from Dogo6647/r2chat
Compare commits
No commits in common. "win7he-patch-1" and "master" have entirely different histories.
win7he-pat
...
master
3 changed files with 9 additions and 114 deletions
|
|
@ -1,4 +0,0 @@
|
|||
def chn(a):
|
||||
return a.replace(' ','_').replace('.','-').replace('\\','/').replace(':','/')
|
||||
def dir(a)
|
||||
return a.replace('/','+')
|
||||
19
r2chat.py
19
r2chat.py
|
|
@ -10,7 +10,6 @@ import pygame as media
|
|||
import webbrowser
|
||||
import re
|
||||
import subprocess
|
||||
import pathify
|
||||
|
||||
if sys.platform == "win32":
|
||||
ROOT = Path("C:/Users/Public")
|
||||
|
|
@ -19,8 +18,8 @@ else:
|
|||
|
||||
try:
|
||||
if sys.argv[1]!='chat':
|
||||
CHANCHAN = pathify.chn(sys.argv[1])
|
||||
CHANNEL = 'chat_'+pathify.dir(CHANCHAN)
|
||||
CHANCHAN = sys.argv[1].replace(' ','_').replace('.','-')
|
||||
CHANNEL = 'chat_'+CHANCHAN
|
||||
else:
|
||||
CHANNEL = 'chat'
|
||||
CHANCHAN = 'chat'
|
||||
|
|
@ -181,13 +180,13 @@ class r2chat:
|
|||
status = new_status
|
||||
|
||||
if status == "online":
|
||||
self.write_system_message(msg=f'((#00af00 | ◉)) {self.cfg["status_join"]}')
|
||||
self.write_system_message(msg=f'◉ {self.cfg["status_join"]}')
|
||||
elif status == "offline":
|
||||
self.write_system_message(msg=f'((#000000 | ◌)) {self.cfg["status_leave"]}')
|
||||
self.write_system_message(msg=f'◌ {self.cfg["status_leave"]}')
|
||||
elif status == "inactive":
|
||||
self.write_system_message(msg=f'((#ffaf00 | ◍)) {self.cfg["status_inactive"]}')
|
||||
self.write_system_message(msg=f'◍ {self.cfg["status_inactive"]}')
|
||||
elif status == "busy":
|
||||
self.write_system_message(msg=f'((#af0000 | ◎)) {self.cfg["status_busy"]}')
|
||||
self.write_system_message(msg=f'◎ {self.cfg["status_busy"]}')
|
||||
|
||||
self.user_data["status"] = status
|
||||
self.save_userdata(self.user_data)
|
||||
|
|
@ -251,7 +250,7 @@ class r2chat:
|
|||
def show_channels(self):
|
||||
win = tk.Toplevel(self.root)
|
||||
win.title("Channel list")
|
||||
win.geometry("600x320")
|
||||
win.geometry("200x320")
|
||||
|
||||
tree = ttk.Treeview(win, columns=("channel"), show="headings")
|
||||
tree.heading("channel", text="Channels")
|
||||
|
|
@ -276,7 +275,7 @@ class r2chat:
|
|||
tree.bind("<Double-1>", on_select)
|
||||
|
||||
def open_channel(self, channel):
|
||||
self.write_system_message(f"((#006fff | ⇄)) {username} is chatting in {channel}.")
|
||||
self.write_system_message(f"⇄ {username} is chatting in {channel}.")
|
||||
if sys.platform == "win32":
|
||||
subprocess.Popen(f'pythonw "{os.path.abspath(__file__)}" "{channel}"', shell=True)
|
||||
else:
|
||||
|
|
@ -318,7 +317,7 @@ class r2chat:
|
|||
try:
|
||||
current_size = os.path.getsize(CHAT_FILE)
|
||||
|
||||
if current_size != self.last_size:
|
||||
if current_size > self.last_size:
|
||||
with open(CHAT_FILE, "r", encoding="utf-8") as f:
|
||||
f.seek(self.last_size)
|
||||
new_data = f.read()
|
||||
|
|
|
|||
100
r2chat_LEGACY.py
100
r2chat_LEGACY.py
|
|
@ -1,100 +0,0 @@
|
|||
import tkinter as tk
|
||||
from tkinter import scrolledtext
|
||||
import os
|
||||
import time
|
||||
import getpass
|
||||
from json import loads
|
||||
|
||||
CHAT_FILE = "C:/Users/Public/r2chat/chat.txt"
|
||||
REFRESH_INTERVAL = 1000
|
||||
|
||||
BORDER_WIDTH = 3
|
||||
THEMES = [['white','white','white','black','Basic'],['#000707','#002727','#001717','white','Aqua']]
|
||||
|
||||
username = getpass.getuser()
|
||||
CONFIG_FILE = f'C:/r2chat/legacy_config/{username}.r2cc'
|
||||
|
||||
if not os.path.exists(CONFIG_FILE):
|
||||
CFILE_C=open(CONFIG_FILE, "a")
|
||||
CFILE_C.write('0\n is now online.\n is now offline.')
|
||||
CFILE_C.close()
|
||||
|
||||
def conf_line(n):
|
||||
return((open(CONFIG_FILE).read()).split('\n')[n])
|
||||
|
||||
THEME = int(conf_line(0))
|
||||
JOIN_MESSAGE = conf_line(1)
|
||||
LEAVE_MESSAGE = conf_line(2)
|
||||
|
||||
class r2chat:
|
||||
def __init__(self, root):
|
||||
self.root = root
|
||||
self.root.title(f"r2chat Legacy :: {username}")
|
||||
|
||||
self.last_size = 0
|
||||
|
||||
self.chat_area = scrolledtext.ScrolledText(root, wrap='word', font=("Lucida Console", 11), bg=THEMES[THEME][1], fg=THEMES[THEME][3], relief='groove', borderwidth=BORDER_WIDTH)
|
||||
self.chat_area.pack(padx=10, pady=10, fill=tk.BOTH, expand=True)
|
||||
self.chat_area.bind("<Key>", lambda e: "break")
|
||||
|
||||
self.entry = tk.Entry(root, font=("Lucida Console", 11), bg=THEMES[THEME][2], fg=THEMES[THEME][3], relief='groove', borderwidth=BORDER_WIDTH)
|
||||
self.entry.pack(padx=10, pady=(0, 10), fill=tk.X)
|
||||
self.entry.bind("<Return>", self.send_message)
|
||||
|
||||
if not os.path.exists(CHAT_FILE):
|
||||
open(CHAT_FILE, "a").close()
|
||||
|
||||
self.update_chat()
|
||||
self.write_system_message(f"{username}{JOIN_MESSAGE}")
|
||||
|
||||
def on_close(self):
|
||||
self.write_system_message(f"{username}{LEAVE_MESSAGE}")
|
||||
self.root.destroy()
|
||||
|
||||
def write_system_message(self, msg):
|
||||
line = f"---- {msg} ----\n"
|
||||
with open(CHAT_FILE, "a", encoding="utf-8") as f:
|
||||
f.write(line)
|
||||
|
||||
def send_message(self, event=None):
|
||||
msg = self.entry.get().strip()
|
||||
if msg:
|
||||
timestamp = time.strftime("%y/%m/%d %H:%M")
|
||||
line = f"[{timestamp}] {username} (legacy): {msg}\n"
|
||||
try:
|
||||
with open(CHAT_FILE, "a", encoding="utf-8") as f:
|
||||
f.write(line)
|
||||
except Exception as e:
|
||||
print("oh noes! ", e)
|
||||
|
||||
self.entry.delete(0, tk.END)
|
||||
|
||||
def update_chat(self):
|
||||
try:
|
||||
current_size = os.path.getsize(CHAT_FILE)
|
||||
|
||||
if current_size > self.last_size:
|
||||
with open(CHAT_FILE, "r", encoding="utf-8") as f:
|
||||
f.seek(self.last_size)
|
||||
new_data = f.read()
|
||||
self.last_size = current_size
|
||||
self.chat_area.config(state='normal')
|
||||
self.chat_area.insert(tk.END, new_data)
|
||||
self.chat_area.config(state='disabled')
|
||||
self.chat_area.yview(tk.END)
|
||||
|
||||
except Exception as e:
|
||||
print("oh noes! ", e)
|
||||
|
||||
self.root.after(REFRESH_INTERVAL, self.update_chat)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
root = tk.Tk()
|
||||
app = r2chat(root)
|
||||
root.geometry("500x520")
|
||||
root.minsize(360, 520)
|
||||
root.attributes('-topmost', True)
|
||||
root.protocol("WM_DELETE_WINDOW", app.on_close)
|
||||
root.configure(bg=THEMES[THEME][0])
|
||||
root.mainloop()
|
||||
Loading…
Add table
Add a link
Reference in a new issue