2013-11-02 39 views
1

我已經在Python中完成了一個IRC-Bot。 我想創建一個關機命令。 它看起來像這樣:從套接字上的客戶端關閉和關閉的Python Irc-Bot EOF

self.SendMessage("Bye!", self.connectedchannel) # Send bye to the connected channel 
self.connection.shutdown(socket.SHUT_RDWR) # Shutdown the socket 
self.connection.close() # Close the socket 
sys.exit() # Exit the program 

但在IRC與「從客戶EOF」機器人斷開,它不正確斷開。 如何更改我的代碼呢?

+0

您必須發送QUIT信息,然後關閉連接。 (不是'PRIVMSG',我的意思是'QUIT:Bye!') –

+0

謝謝,這個工作!你能補充一點嗎? – Thor77

回答

1

之前關閉套接字,併發送QUIT消息:

QUIT :Bye! 

這應該修復它。

相關問題