【发布时间】:2013-11-02 12:34:56
【问题描述】:
我用 Python 做了一个 IRC-Bot。 我想创建一个关机命令。 它看起来像这样:
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”断开连接,但无法正确断开连接。 如何更改我的代码呢?
【问题讨论】:
-
您必须发送
QUIT消息,然后关闭连接。 (不是通过PRIVMSG,我的意思是QUIT :Bye!) -
谢谢,这成功了!你能把这个添加为答案吗?
标签: python sockets irc shutdown