Skip to content

Commit

Permalink
Merge pull request #17 from AlignPixel/dev
Browse files Browse the repository at this point in the history
从"dev"分支拉去更新
  • Loading branch information
FrederickBun authored Aug 6, 2024
2 parents fce27cb + 93c6eb1 commit 6061362
Showing 1 changed file with 5 additions and 10 deletions.
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

0 comments on commit 6061362

Please sign in to comment.