I'm making an IRC bot in python for the hackthissite challenge (prog 8). Here's an excerpt of the connection code:
def ping():
ircsock.send("PONG :Pong\n")
ircsock.connect((server,6667))
ircsock.send("USER "+botnick+" "+server+" "+botnick+" :"+version+"\n")
ircsock.send("NICK "+botnick+"\n")
while(connect):
ircmsg = ircsock.recv(2048)
ircmsg = ircmsg.strip('\n\r')
print(ircmsg)
if(ircmsg.find("PING :") != -1):
ping()
I don't think that there's anything wrong with this. All variables are defined and have a value, this code works without a problem on some servers (freenode for example). But on other servers (foonetic, hackthissite) I get the following output:
:hub.irc.hackthissite.org NOTICE AUTH :*** Looking up your hostname...
:hub.irc.hackthissite.org NOTICE AUTH :*** Found your hostname
PING :3C8E9173
:3C8E9173!nospoof@hub.irc.hackthissite.org PRIVMSG Tadbot :VERSION
I'm not sure what to do with this. I have tried sending back the version of my bot to the username between the ":" and the "!", which (as expected) didn't do anything. On servers where this happens, I never get my MOTD so I get the "You have not registered" error when I try to do anything.
Google yielded some results of people explaining similar problems, but it'd always be that they forgot to send their USER and NICK, so I'm really at a loss about what to do here.
You must send the PONG
response to the server's PING
, otherwise the server will think the connection is dead.
The correct reply in the example you posted would be
PONG :3C8E9173
3C8E9173 being the same string as the server requested.