【发布时间】:2016-10-04 19:48:47
【问题描述】:
我没有得到这个 IRC 连接的“Ident”响应
import sys
import time
import socket
server="irc.freenode.net"
botnick="Hidden"
channel="Hidden"
#Establish connection
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
irc.connect((server,6667))
irc.setblocking(False)
time.sleep(1)
time.sleep(1)
irc.send(("/NICK "+botnick+"\r\n").encode('UTF-8'))
time.sleep(1)
irc.send(("/JOIN "+channel+"\r\n").encode('UTF-8'))
while 1:
time.sleep(0.1)
try:
text=irc.recv(2040)
print(text)
except Exception:
pass
if text.find("PING")!=-1:
irc.send(("Test").encode('UTF-8'))
input()
这是控制台输出
b':wilhelm.freenode.net NOTICE * :*** Looking up your
hostname...\r\n:
wilhelm.freenode.net NOTICE * :*** Checking Ident\r\n:
wilhelm.freenode.net NOTICE * :*** Found your hostname\r\n'
b':wilhelm.freenode.net NOTICE * :*** No Ident response\r\n'
它只挂了大约 5-10 秒,然后说关闭到 127.0.0.1 的链接 然后说 b'' 多次
代码灵感来自 http://agzuniverse.blogspot.ca/2016/05/irc-bot-in-python-tutorial.html
【问题讨论】: