Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

从"dev"分支拉取更新 || Pull updates from the "dev" branch #17

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions server-client/simple-verson.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self):
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()
Expand Down Expand Up @@ -44,7 +44,7 @@ def __init__(self, cs, caddr, msg_handler):

def run(self):
try:
print('连接来自于:', self.__caddr)
print('-> 连接来自于:', self.__caddr)
if self.__msg_handler.is_blacklisted(self.__caddr[0]):
self.__handle_blacklisted()
return
Expand Down Expand Up @@ -124,7 +124,7 @@ def close_conn(self, cs):
self.__socket_to_user_name.pop(cs)
self.__user_name_to_broadcast_state.pop(nickname)
nickname += " 离开了本聊天室"
if nickname != "SOMEONE": # 说明是正常退出,一个防输出卡死机制,来自 boom hack 0x3299f
if nickname != "SOMEONE": # 说明是正常退出,一个防输出卡死机制,来自 boom hack 0x3299f,除非你有更好的替代方案,请勿修改此项
self.broadcast_system_msg(nickname)

def handle_msg(self, msg, cs):
Expand All @@ -146,7 +146,7 @@ def handle_msg(self, msg, cs):
'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',
Expand Down Expand Up @@ -226,7 +226,7 @@ def send_to(self, msg, cs):
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',
Expand Down Expand Up @@ -272,11 +272,6 @@ def add_to_blacklist_manual(self, ip):
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)
Expand Down
Loading