我想使用以下代码在 python 中托管一个简单的 irc 机器人:
#!/usr/bin/python
import sys
import os
import socket
HOST = 'irc.gamesurge.net'
PORT = 6667
NICK = 'test_bot'
IDENT = 'testbot'
REALNAME = 'TestBot'
OWNER = 'Test'
CHANNELINIT = '#test_channel'
readbuffer = ''
sock = socket.socket()
sock.connect((HOST, PORT))
sock.send('NICK %sn' % NICK)
sock.send('USER %s %s bla :%sn' % (IDENT, HOST, REALNAME))
while True:
line = sock.recv(500)
if line:
print line
if line.find('GameSurge') != -1:
print "joining..."
print"current line: "+line
sock.send('JOIN %sn' % CHANNELINIT)
但无论我选择连接哪个游戏服务器,它总是给我这个错误:
ERROR :Closing Link: by NuclearFallout.WA.US.GameSurge.net (Registration Timeout)
这是服务器返回的内容:
NOTICE AUTH :*** Looking up your hostname
NOTICE AUTH :*** Checking Ident
NOTICE AUTH :*** Found your hostname
NOTICE AUTH :*** No ident response
ERROR :Closing Link: by NuclearFallout.WA.US.GameSurge.net (Registration Timeout)
有谁知道如何解决这个问题?谢谢。