先写一点代码。在
#!/usr/bin/env python
import sys
import socket
import string
HOST='irc.ircnetworkbotison.net' #The server we want to connect to
PORT=6666 #The connection port which is usually 6667
NICK='RandomBot' #The bot's nickname
IDENT='RandomBot'
REALNAME='Random Bot'
OWNER='RandomBot' #The bot owner's nick
CHAN='#botchannel' #The default channel for the bot
readbuffer='' #Here we store all the messages from server
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) #Create the socket
s.connect((HOST, PORT)) #Connect to server
s.send('USER '+IDENT+' 0 * :'+REALNAME+'\r\n') #Identify to server
s.send('NICK '+NICK+'\r\n') #Send the nick to server
s.send('JOIN '+CHAN+'\r\n')
s.send('PRIVMSG '+CHAN+' :The Tutor is here. Lesson\'s may begin.'+'\r\n')
我有两个函数。一个用于解析PRIVMSG,另一个用于迎接新用户。 问题在于:
^{pr2}$不管出于什么原因,在IRC中大约一个小时后,bot将停止响应或注册任何消息。到目前为止,我发现的唯一解决方法是打开一个与机器人的私人对话,给它发送一个命令,然后返回主聊天。此时,它将再次正常工作大约一个小时。在
问题:
为什么它会像这样超时?
我怎么才能让它停下来?
目前没有回答
相关问题 更多 >
编程相关推荐