mirror of
https://github.com/AlignPixel-Dev/Pixel-Chat-App.git
synced 2025-07-07 08:37:00 +08:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
ff2de739d2 | |||
9440dc95f6 | |||
93c6eb1c74 | |||
4f79018752 | |||
8bbc40cc3c | |||
c4c7f7257a | |||
a9653d23e2 | |||
95b287a85c | |||
537525cf19 | |||
96cda61dbd | |||
a569a9d3f2 | |||
71634853f8 | |||
19d37e4aea | |||
8d9085683a | |||
a0e1f1d22e | |||
73127e5b15 | |||
7c5894519a | |||
4b2435f5e5 |
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
59
.idea/workspace.xml
generated
Normal file
59
.idea/workspace.xml
generated
Normal file
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="7e072936-42bd-40bd-986b-5e8a7b6b42ab" name="更改" comment="更新了安全命令,修复了一个服务端交互问题" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="GitHubPullRequestSearchHistory"><![CDATA[{
|
||||
"lastFilter": {
|
||||
"state": "OPEN",
|
||||
"assignee": "FrederickBun"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="GithubPullRequestsUISettings"><![CDATA[{
|
||||
"selectedUrlAndAccountId": {
|
||||
"url": "https://github.com/AlignPixel/Pixel-Chat-App.git",
|
||||
"accountId": "0284ff40-abc5-4cf0-9b08-d15211eef50e"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 0
|
||||
}</component>
|
||||
<component name="ProjectId" id="2kHhADg8uMNyRHttZUg04VcxrPn" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"git-widget-placeholder": "dev"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-python-sdk-975db3bf15a3-31b6be0877a2-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-241.18034.82" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="默认任务">
|
||||
<changelist id="7e072936-42bd-40bd-986b-5e8a7b6b42ab" name="更改" comment="更新了安全命令,修复了一个服务端交互问题" />
|
||||
<created>1722946264814</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1722946264814</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
</project>
|
128
CODE_OF_CONDUCT.md
Normal file
128
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,128 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
seventeen@ohdragonboi.cn.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
19
README.md
19
README.md
@ -1,8 +1,17 @@
|
||||
# 💬Pixel-Chat App
|
||||

|
||||
|
||||
<img src="/assets/logo-final-@1x.png" align="right" width="50px" />
|
||||
|
||||
# 💬 Pixel-Chat App
|
||||
|
||||
一个简单、快速、开源的Python即时聊天系统,涵盖了多种聊天操作需求
|
||||
|
||||
### 🤩功能亮点
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
### 🤩 功能亮点
|
||||
|
||||
- 开箱即用,无需部署
|
||||
- 可将任意计算机、服务器上用作服务端使用,仅需一个 `Pixel Chat Desktop` 输入IP地址即可访问所有使用 `Pixel-Chat Server` 的聊天服务器
|
||||
@ -11,7 +20,7 @@
|
||||
- 简单方便的服务端命令,只需一个服务端即可掌控整个聊天服务器
|
||||
- 无需手动重置,因为不使用缓存,所以关闭重新打开自动清除数据
|
||||
|
||||
### ℹ️使用方法
|
||||
### ℹ️ 使用方法
|
||||
|
||||
###### 在服务器上运行服务端
|
||||
|
||||
@ -29,7 +38,7 @@
|
||||
|
||||
请邮件联系[seventeen@ohdragonboi.cn](mailto:seventeen@ohdragonboi.cn)探讨您需要的内容,也许会需要您支付额外费用🤔
|
||||
|
||||
### 🎈贡献者列表
|
||||
### 🎈 贡献者列表
|
||||
|
||||
欢迎为本项目贡献一份你的力量,请参考Wiki中《贡献手册》章节为本项目提交PR或Issues
|
||||
|
||||
@ -48,7 +57,7 @@
|
||||
| ------------------------ | ------------------------------------------------------------ | ---------------------------------------------------------- |
|
||||
| 西南大学附中信息学竞赛生 | 本程序最初设计目的是为了此需求,后来开源,诞生了此项目。本文本中提到的 `Pixel-Chat Client` 就是最初由同学们编写的初代客户端,而 `Pixel-Chat Desktop` 是由[AlignPixel](https://github.com/AlignPixel)所改进的开源版本 | 用于刷题目时共享思路,一位同学运行服务端,全班同学可以使用 |
|
||||
|
||||
### 🖼️屏幕截图
|
||||
### 🖼️ 屏幕截图
|
||||
|
||||

|
||||
|
||||
|
BIN
assets/logo-final-@1x.png
Normal file
BIN
assets/logo-final-@1x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 119 KiB |
@ -14,7 +14,7 @@ class PyChattingServer:
|
||||
self.__msg_handler = ChattingHandler()
|
||||
|
||||
def start_session(self):
|
||||
print('已经上线,用户可通过IP进入\r\n')
|
||||
print('已经上线,用户可通过客户端输入IP进入,输入.help可以调出命令列表\r\n')
|
||||
input_thread_handler = threading.Thread(target=self.input_thread)
|
||||
input_thread_handler.daemon = True
|
||||
input_thread_handler.start()
|
||||
@ -44,7 +44,7 @@ class ChattingThread(threading.Thread):
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
print('连接来自于:', self.__caddr)
|
||||
print('-> 连接来自于:', self.__caddr)
|
||||
if self.__msg_handler.is_blacklisted(self.__caddr[0]):
|
||||
self.__handle_blacklisted()
|
||||
return
|
||||
@ -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)
|
||||
@ -145,7 +146,7 @@ class ChattingHandler:
|
||||
'success': True,
|
||||
'msg': '昵称建立成功,输入/checkol可查看所有在线的人,输入/help可以查看帮助(所有首字符为/的消息都不会发送)'
|
||||
}), cs)
|
||||
self.broadcast_系统消息_msg(js['msg'] + "加入了聊天")
|
||||
self.broadcast_system_msg(js['msg'] + "加入了聊天")
|
||||
else:
|
||||
self.send_to(json.dumps({
|
||||
'type': 'login',
|
||||
@ -225,7 +226,7 @@ class ChattingHandler:
|
||||
self.__socket_list.append(cs)
|
||||
cs.sendall(bytes(msg, 'utf-8'))
|
||||
|
||||
def broadcast_系统消息_msg(self, msg):
|
||||
def broadcast_system_msg(self, msg):
|
||||
data = '[ %s ]\r\n[ 系统消息 ] : %s' % (ctime(), msg)
|
||||
js = json.dumps({
|
||||
'type': '系统消息_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
|
||||
@ -269,19 +272,23 @@ class ChattingHandler:
|
||||
print(f"IP {ip} 已经被手动移除")
|
||||
elif ip == '.banlist':
|
||||
print(self.__blacklist)
|
||||
elif ip == '.help':
|
||||
print("BAN: 封禁某个IP\r\n"\
|
||||
"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"\
|
||||
@ -289,6 +296,7 @@ class ChattingHandler:
|
||||
"KICK: 踢出某个用户\r\n"\
|
||||
"AN: 以系统身份发布消息\r\n"\
|
||||
"ONELINE: 查看在线用户\r\n"\
|
||||
"SETVISIT: 对用户访问进行操作\r\n"\
|
||||
"HELP: 查看操作帮助")
|
||||
else:
|
||||
print("不存在的命令!")
|
||||
|
Reference in New Issue
Block a user