5 Commits
lite ... dev

Author SHA1 Message Date
ff2de739d2 Jetbrains 2024-08-06 20:51:57 +08:00
9440dc95f6 Create workspace.xml 2024-08-06 20:29:12 +08:00
93c6eb1c74 更新了安全命令,修复了一个服务端交互问题 2024-08-06 19:53:48 +08:00
4f79018752 Update img 2024-08-02 14:40:25 +08:00
8bbc40cc3c Update .DS_Store 2024-08-02 14:36:53 +08:00
8 changed files with 82 additions and 10 deletions

BIN
.DS_Store vendored

Binary file not shown.

View 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
View 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
View 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
View 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">{
&quot;associatedIndex&quot;: 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>

View File

@ -1,5 +1,7 @@
![Pixel-Chat-App](https://repository-images.githubusercontent.com/832191338/b1042f2c-3c1a-4756-b061-732923b776cd) ![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 # 💬 Pixel-Chat App
一个简单、快速、开源的Python即时聊天系统涵盖了多种聊天操作需求 一个简单、快速、开源的Python即时聊天系统涵盖了多种聊天操作需求

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() self.__msg_handler = ChattingHandler()
def start_session(self): 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 = threading.Thread(target=self.input_thread)
input_thread_handler.daemon = True input_thread_handler.daemon = True
input_thread_handler.start() input_thread_handler.start()
@ -44,7 +44,7 @@ class ChattingThread(threading.Thread):
def run(self): def run(self):
try: try:
print('连接来自于:', self.__caddr) print('-> 连接来自于:', self.__caddr)
if self.__msg_handler.is_blacklisted(self.__caddr[0]): if self.__msg_handler.is_blacklisted(self.__caddr[0]):
self.__handle_blacklisted() self.__handle_blacklisted()
return return
@ -124,7 +124,7 @@ class ChattingHandler:
self.__socket_to_user_name.pop(cs) self.__socket_to_user_name.pop(cs)
self.__user_name_to_broadcast_state.pop(nickname) self.__user_name_to_broadcast_state.pop(nickname)
nickname += " 离开了本聊天室" nickname += " 离开了本聊天室"
if nickname != "SOMEONE": # 说明是正常退出,一个防输出卡死机制,来自 boom hack 0x3299f if nickname != "SOMEONE": # 说明是正常退出,一个防输出卡死机制,来自 boom hack 0x3299f,除非你有更好的替代方案,请勿修改此项
self.broadcast_system_msg(nickname) self.broadcast_system_msg(nickname)
def handle_msg(self, msg, cs): def handle_msg(self, msg, cs):
@ -146,7 +146,7 @@ class ChattingHandler:
'success': True, 'success': True,
'msg': '昵称建立成功,输入/checkol可查看所有在线的人,输入/help可以查看帮助(所有首字符为/的消息都不会发送)' 'msg': '昵称建立成功,输入/checkol可查看所有在线的人,输入/help可以查看帮助(所有首字符为/的消息都不会发送)'
}), cs) }), cs)
self.broadcast_系统消息_msg(js['msg'] + "加入了聊天") self.broadcast_system_msg(js['msg'] + "加入了聊天")
else: else:
self.send_to(json.dumps({ self.send_to(json.dumps({
'type': 'login', 'type': 'login',
@ -226,7 +226,7 @@ class ChattingHandler:
self.__socket_list.append(cs) self.__socket_list.append(cs)
cs.sendall(bytes(msg, 'utf-8')) cs.sendall(bytes(msg, 'utf-8'))
def broadcast_系统消息_msg(self, msg): def broadcast_system_msg(self, msg):
data = '[ %s ]\r\n[ 系统消息 ] : %s' % (ctime(), msg) data = '[ %s ]\r\n[ 系统消息 ] : %s' % (ctime(), msg)
js = json.dumps({ js = json.dumps({
'type': '系统消息_msg', 'type': '系统消息_msg',
@ -272,11 +272,6 @@ class ChattingHandler:
print(f"IP {ip} 已经被手动移除") print(f"IP {ip} 已经被手动移除")
elif ip == '.banlist': elif ip == '.banlist':
print(self.__blacklist) print(self.__blacklist)
elif ip == '.help':
print("BAN: 封禁某个IP\r\n"\
"UNBAN: 解除封禁某个IP\r\n"\
"BANLIST: 查看封禁IP列表\r\n"\
"HELP: 查看操作帮助")
elif ip == '.an': elif ip == '.an':
user = input("请输入要发布的内容:") user = input("请输入要发布的内容:")
self.broadcast_system_msg(user) self.broadcast_system_msg(user)