本文介绍了Python IRC僵尸程序将无法加入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误消息

:irc.evilzone.org注意事项: * 找到您的主机名(已缓存)

:irc.evilzone.org NOTICE AUTH :* Found your hostname (cached)

PING:7091A8FB

PING :7091A8FB

:irc.evilzone.org 451 JOIN:您有 未注册

:irc.evilzone.org 451 JOIN :You have not registered

:irc.evilzone.org 451 PRIVMSG:您 还没有注册

:irc.evilzone.org 451 PRIVMSG :You have not registered

server = "irc.evilzone.org" # Server 
port = 6667 #port connect through IRC standard is :(6667 or 9999)
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect ( ( server, port ) )
print irc.recv ( 4096 )
nick = 'Piebot' #bots name
chan = 'test' #channel
version= "1.0" #current version
irc.send ( 'NICK Pizebot\r\n' ) 
irc.send ( 'USER Pizebot Pibot Pibot :Python IRC\r\n' )
irc.send ( 'JOIN #test\r\n' ) # YOU MUST CHANGE THE CHANNEL HERE AND BELOW!!
irc.send ( 'PRIVMSG #test :Hello World.\r\n' )

while True:
    readbuffer= irc.recv(4096)

    temp=string.split(readbuffer, "\n")
    Check = readbuffer.split(':')
    print readbuffer

请记住,我使用的某些命令需要代码的temp = string.split(readbuffer,"\ n")部分.但是使用这样的代码

Keeping in mind that some of the commands I use need the temp= string.split(readbuffer,"\n") portion of the code.But with code like this

network = 'irc.evilzone.org'
port = 6667
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect ( ( network, port ) )
print irc.recv ( 4096 )
irc.send ( 'NICK ipbot\r\n' )
irc.send ( 'USER ipbot completely real :Jxxx\r\n' )
irc.send ( 'JOIN #test\r\n' )
irc.send ( 'PRIVMSG #test:Oh Hai.\r\n' )
while True:
   data = irc.recv ( 4096 )

我可以成功连接到频道等.有什么想法吗?

I can successfully connect to the channel etc. Any idea?

推荐答案

我注意到您不处理PING请求,某些服务器直到您回复了PING请求(因此未注册)才接受任何其他命令.您需要先连接,然后单击NICK,先检查PING,然后再检查USER,然后再检查USER是否没有PING.

I noticed that you do not handle PING requests, some servers do not accept any other commands until you have replied to the PING request (hence not registered).You would want to connect, then NICK, check for a PING, then USER, check for PING again if there was none before USER.

某些服务器喜欢在NICK之后发送,其他服务器喜欢在USER之后发送.

Some servers like to send it after NICK, others after USER.

PING :7091A8FB\r\n

要响应此PING,只需发送:

To respond to this PING, simply send:

PONG :7091A8FB\r\n

:'\r\n之间将是一个随机字符串,您需要将其与PONG一起发回,如上所示.

Between the : and '\r\n will be a random string that you need to send back with your PONG as shown above.

这篇关于Python IRC僵尸程序将无法加入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 00:23