diff --git a/.DS_Store b/.DS_Store index c7941d7..80e645a 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index 9200079..447451e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,15 @@ -# 💬Pixel-Chat App +![Pixel-Chat-App](https://repository-images.githubusercontent.com/832191338/b1042f2c-3c1a-4756-b061-732923b776cd) + +# 💬 Pixel-Chat App 一个简单、快速、开源的Python即时聊天系统,涵盖了多种聊天操作需求 -### 🤩功能亮点 +![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/AlignPixel/Pixel-Chat-App/total?style=for-the-badge&logo=github) +![GitHub License](https://img.shields.io/github/license/AlignPixel/Pixel-Chat-App?style=for-the-badge) +![GitHub Discussions](https://img.shields.io/github/discussions/AlignPixel/Pixel-Chat-App?style=for-the-badge&logo=github) +![Static Badge](https://img.shields.io/badge/Python-3.x-blue?style=for-the-badge&logo=Python&logoColor=white) + +### 🤩 功能亮点 - 开箱即用,无需部署 - 可将任意计算机、服务器上用作服务端使用,仅需一个 `Pixel Chat Desktop` 输入IP地址即可访问所有使用 `Pixel-Chat Server` 的聊天服务器 @@ -11,17 +18,17 @@ - 简单方便的服务端命令,只需一个服务端即可掌控整个聊天服务器 - 无需手动重置,因为不使用缓存,所以关闭重新打开自动清除数据 -### ℹ️使用方法 +### ℹ️ 使用方法 ###### 在服务器上运行服务端 1. 在用作服务端的服务器或计算机上安装[Python环境](https://python.org) -2. 在Release页面下载 `Pixel-Chat Server`,下载完成后运行 +2. 在[Release](https://github.com/AlignPixel/Pixel-Chat-App/releases)页面下载 `Pixel-Chat Server`,下载完成后运行 3. VOILA! 现在邀请你的用户通过 `Pixel-Chat Client` 或 `Pixel-Chat Desktop` 访问服务器/计算机IP地址即可聊天 ###### 访问您喜欢的聊天服务器 -1. 在Release页面下载 `Pixel-Chat-Desktop`,下载完成后运行 +1. 在[Release](https://github.com/AlignPixel/Pixel-Chat-App/releases)页面下载 `Pixel-Chat-Desktop`,下载完成后运行 2. 输入您喜欢的聊天服务器IP 3. VOILA! 现在是聊天时间 @@ -29,7 +36,7 @@ 请邮件联系[seventeen@ohdragonboi.cn](mailto:seventeen@ohdragonboi.cn)探讨您需要的内容,也许会需要您支付额外费用🤔 -### 🎈贡献者列表 +### 🎈 贡献者列表 欢迎为本项目贡献一份你的力量,请参考Wiki中《贡献手册》章节为本项目提交PR或Issues @@ -37,8 +44,8 @@ | AVATAR | NAME | WORK | | ------------------------------------------------------------ | ------------------------------------------------------- | --------------- | -| BunDragon's Github AVATAR | [磅豆龙(FrederickBun)](https://github.com/FrederickBun) | AUTHOR(Creator) | -| Rayminn's Github AVATAR | [Yiming Lei(Rayminn)](https://github.com/Rayminn) | AUTHOR(Editor) | +| BunDragon's Github AVATAR | [磅豆龙(FrederickBun)](https://github.com/FrederickBun) | Author(Creator) | +| Rayminn's Github AVATAR | [Yiming Lei(Rayminn)](https://github.com/Rayminn) | Author(Editor) | ### 📦特供版本与特殊版本使用者 @@ -48,7 +55,7 @@ | ------------------------ | ------------------------------------------------------------ | ---------------------------------------------------------- | | 西南大学附中信息学竞赛生 | 本程序最初设计目的是为了此需求,后来开源,诞生了此项目。本文本中提到的 `Pixel-Chat Client` 就是最初由同学们编写的初代客户端,而 `Pixel-Chat Desktop` 是由[AlignPixel](https://github.com/AlignPixel)所改进的开源版本 | 用于刷题目时共享思路,一位同学运行服务端,全班同学可以使用 | -### 🖼️屏幕截图 +### 🖼️ 屏幕截图 ![总体截图](https://cdn.jsdelivr.net/gh/FrederickBun/upyun-rhimgcdn@img/upload/202407271438190.png) diff --git a/desktop/main.py b/desktop/se-verson.py similarity index 100% rename from desktop/main.py rename to desktop/se-verson.py diff --git a/server-client/main.py b/server-client/simple-verson.py similarity index 82% rename from server-client/main.py rename to server-client/simple-verson.py index ddcd555..a9f190d 100755 --- a/server-client/main.py +++ b/server-client/simple-verson.py @@ -14,7 +14,7 @@ class PyChattingServer: self.__msg_handler = ChattingHandler() def start_session(self): - print('已经上线,用户可通过IP进入\r\n') + print('已经上线,用户可通过客户端输入IP进入\r\n') input_thread_handler = threading.Thread(target=self.input_thread) input_thread_handler.daemon = True input_thread_handler.start() @@ -123,8 +123,9 @@ class ChattingHandler: self.__user_name_to_socket.pop(self.__socket_to_user_name[cs]) self.__socket_to_user_name.pop(cs) self.__user_name_to_broadcast_state.pop(nickname) - nickname += " " - self.broadcast_系统消息_msg(nickname + "离开了本聊天室") + nickname += " 离开了本聊天室" + if nickname != "SOMEONE": # 说明是正常退出,一个防输出卡死机制,来自 boom hack 0x3299f + self.broadcast_system_msg(nickname) def handle_msg(self, msg, cs): js = json.loads(msg) @@ -237,6 +238,8 @@ class ChattingHandler: def broadcast(self, msg, cs): data = '[ %s ]\r\n[%s] : %s\r\n' % (ctime(), self.__socket_to_user_name[cs], msg) + if '' in data: # 屏蔽卡死服务器的字符,所有 Contributors 请不要更改这条判断,否则 PR 将直接拒绝合并,本安全措施来自 来自 boom hack 0x3657f + data = '[ %s ]\r\n[ 系统警告 - %s ] : %s\r\n' % (ctime(), self.__socket_to_user_name[cs], '{用户发送的内容可能包含卡死服务器的内容,已经被屏蔽显示}') js = json.dumps({ 'type': 'broadcast', 'msg': data @@ -274,6 +277,32 @@ class ChattingHandler: "UNBAN: 解除封禁某个IP\r\n"\ "BANLIST: 查看封禁IP列表\r\n"\ "HELP: 查看操作帮助") + elif ip == '.an': + user = input("请输入要发布的内容:") + self.broadcast_system_msg(user) + print("发布成功") + elif ip == '.online': + login_list = "[ 输出 ] 在线用户 : " + for key in self.__socket_to_user_name: + login_list += self.__socket_to_user_name[key] + ' | ' + print(login_list) + elif ip == '.setvisit': # 一个防输出卡死的屏蔽功能,目前仅支持手动添加,来自 boom hack 0x3299f + ip = input("请输入限制访问信息的ip地址:") + if not self.is_alisted(ip): + self.__alist.add(ip) + print(f"IP {ip} 已经被手动更改访问") + else: + self.__alist.remove(ip) + print(f"IP {ip} 已经被手动更改访问") + elif ip == '.help': + print("BAN: 封禁某个IP\r\n"\ + "UNBAN: 解除封禁某个IP\r\n"\ + "BANLIST: 查看封禁IP列表\r\n"\ + "KICK: 踢出某个用户\r\n"\ + "AN: 以系统身份发布消息\r\n"\ + "ONELINE: 查看在线用户\r\n"\ + "SETVISIT: 对用户访问进行操作\r\n"\ + "HELP: 查看操作帮助") else: print("不存在的命令!")