Merge pull request #6 from AlignPixel/master

迁移数据
This commit is contained in:
Frederick Chen 2024-07-31 23:58:01 +08:00 committed by GitHub
commit 71634853f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 12 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -1,7 +1,14 @@
![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)
### 🤩 功能亮点
- 开箱即用,无需部署
@ -16,12 +23,12 @@
###### 在服务器上运行服务端
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! 现在是聊天时间
@ -37,8 +44,8 @@
| AVATAR | NAME | WORK |
| ------------------------------------------------------------ | ------------------------------------------------------- | --------------- |
| <img src="https://avatars.githubusercontent.com/u/120368045?s=400&u=ac60326a41a0d41faaf82ad25bcd143d85224791&v=4" alt="BunDragon's Github AVATAR" width="50px" /> | [磅豆龙(FrederickBun)](https://github.com/FrederickBun) | AUTHOR(Creator) |
| <img src="https://avatars.githubusercontent.com/u/98998872" alt="Rayminn's Github AVATAR" width="50px"/> | [Yiming Lei(Rayminn)](https://github.com/Rayminn) | AUTHOR(Editor) |
| <img src="https://avatars.githubusercontent.com/u/120368045?s=400&u=ac60326a41a0d41faaf82ad25bcd143d85224791&v=4" alt="BunDragon's Github AVATAR" width="50px" /> | [磅豆龙(FrederickBun)](https://github.com/FrederickBun) | Author(Creator) |
| <img src="https://avatars.githubusercontent.com/u/98998872" alt="Rayminn's Github AVATAR" width="50px"/> | [Yiming Lei(Rayminn)](https://github.com/Rayminn) | Author(Editor) |
### 📦特供版本与特殊版本使用者

View File

@ -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("不存在的命令!")