Compare commits

..

31 Commits

Author SHA1 Message Date
50575c2b48
Update README.md 2024-08-20 12:06:25 +07:00
d7edb3e079
Update README.md 2024-08-20 11:59:00 +07:00
cc78d2d4d0
Update README.md 2024-08-20 11:58:06 +07:00
4eb721d5ab
Update README.md 2024-08-20 11:56:02 +07:00
49de09f23e
Update README.md 2024-08-20 11:43:04 +07:00
8530f8f95e
Update README.md 2024-08-20 11:41:58 +07:00
Yiming Lei
8a93fdc95a
Update python-app.yml 2024-08-06 20:58:22 +08:00
Yiming Lei
0ed0deb843
Create python-app.yml 2024-08-06 20:55:52 +08:00
3ad1fbf770
Create translate.yml 2024-08-06 20:01:25 +08:00
6061362cdc
Merge pull request #17 from AlignPixel/dev
从"dev"分支拉去更新
2024-08-06 19:59:48 +08:00
93c6eb1c74 更新了安全命令,修复了一个服务端交互问题 2024-08-06 19:53:48 +08:00
fce27cb97f
Merge pull request #16 from AlignPixel/dev
Update img
2024-08-02 14:40:53 +08:00
4f79018752 Update img 2024-08-02 14:40:25 +08:00
224628e821
Merge pull request #15 from AlignPixel/dev
Update .DS_Store
2024-08-02 14:37:29 +08:00
8bbc40cc3c Update .DS_Store 2024-08-02 14:36:53 +08:00
ebb8460ca3
Merge pull request #14 from AlignPixel/lite
Merge pull request #13 from AlignPixel/master
2024-08-01 10:45:26 +08:00
63aea9f91c
Merge pull request #13 from AlignPixel/master
转移内容
2024-08-01 10:45:04 +08:00
4cd862183b
Merge pull request #12 from AlignPixel/dev
Merge pull request #11 from AlignPixel/master
2024-08-01 10:44:32 +08:00
c4c7f7257a
Merge pull request #11 from AlignPixel/master
转移内容
2024-08-01 10:44:10 +08:00
a9653d23e2
Create CODE_OF_CONDUCT.md 2024-08-01 10:32:25 +08:00
95b287a85c fix: comment error 2024-08-01 10:29:24 +08:00
537525cf19
Merge pull request #9 from AlignPixel/lite
Merge pull request #7 from AlignPixel/master
2024-07-31 23:59:07 +08:00
96cda61dbd
Merge pull request #8 from AlignPixel/dev
Merge pull request #6 from AlignPixel/master
2024-07-31 23:58:48 +08:00
a569a9d3f2
Merge pull request #7 from AlignPixel/master
迁移数据
2024-07-31 23:58:27 +08:00
71634853f8
Merge pull request #6 from AlignPixel/master
迁移数据
2024-07-31 23:58:01 +08:00
19d37e4aea 修复从Boom Hack检测中找到的对服务器访问限制的安全问题 2024-07-31 23:54:58 +08:00
8d9085683a Merge branch 'master' of https://github.com/AlignPixel/Pixel-Chat-App 2024-07-31 23:45:58 +08:00
a0e1f1d22e Update .DS_Store 2024-07-31 23:45:39 +08:00
73127e5b15
Update README.md 2024-07-30 23:32:43 +08:00
7c5894519a
Update README.md 2024-07-30 23:32:01 +08:00
4b2435f5e5
Update README.md 2024-07-30 23:30:20 +08:00
7 changed files with 231 additions and 17 deletions

BIN
.DS_Store vendored

Binary file not shown.

39
.github/workflows/python-app.yml vendored Normal file
View File

@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pyinstaller
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Pyinstaller
run: |
pyinstaller -F desktop/se-verson.py
pyinstaller -F server-client/simple-verson.py

30
.github/workflows/translate.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: 'issue and discussion translator'
on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]
discussion:
types: [created, edited]
discussion_comment:
types: [created, edited]
pull_request_target:
types: [opened, edited]
pull_request_review_comment:
types: [created, edited]
jobs:
translate:
permissions:
issues: write
discussions: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: lizheming/github-translate-action@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
IS_MODIFY_TITLE: true
APPEND_TRANSLATION: true

128
CODE_OF_CONDUCT.md Normal file
View 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.

View File

@ -1,8 +1,17 @@
# 💬Pixel-Chat App
![Pixel-Chat-App](https://repository-images.githubusercontent.com/832191338/b1042f2c-3c1a-4756-b061-732923b776cd)
<img src="/assets/logo-final-@1x.png" align="right" width="50px" />
# 💬 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,7 +20,7 @@
- 简单方便的服务端命令,只需一个服务端即可掌控整个聊天服务器
- 无需手动重置,因为不使用缓存,所以关闭重新打开自动清除数据
### ℹ️使用方法
### 使用方法
###### 在服务器上运行服务端
@ -27,9 +36,9 @@
###### 需要特殊/定制版本
邮件联系[seventeen@ohdragonboi.cn](mailto:seventeen@ohdragonboi.cn)探讨您需要的内容,也许会需要您支付额外费用🤔
访问[此处](https://github.com/AlignPixel/Pixel-Chat-App/wiki/%E5%AE%9A%E5%88%B6%E6%82%A8%E7%9A%84%E7%89%88%E6%9C%AC)查看方法,并邮件探讨您需要的内容,也许会需要您支付额外费用🤔
### 🎈贡献者列表
### 🎈 贡献者列表
欢迎为本项目贡献一份你的力量请参考Wiki中《贡献手册》章节为本项目提交PR或Issues
@ -48,7 +57,7 @@
| ------------------------ | ------------------------------------------------------------ | ---------------------------------------------------------- |
| 西南大学附中信息学竞赛生 | 本程序最初设计目的是为了此需求,后来开源,诞生了此项目。本文本中提到的 `Pixel-Chat Client` 就是最初由同学们编写的初代客户端,而 `Pixel-Chat Desktop` 是由[AlignPixel](https://github.com/AlignPixel)所改进的开源版本 | 用于刷题目时共享思路,一位同学运行服务端,全班同学可以使用 |
### 🖼️屏幕截图
### 🖼️ 屏幕截图
![总体截图](https://cdn.jsdelivr.net/gh/FrederickBun/upyun-rhimgcdn@img/upload/202407271438190.png)

BIN
assets/logo-final-@1x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

View File

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