IRC connection errors on a comedic python program

Today I started work on creating a relatively complex program using IRC journals. No matter what I did, I get:

['ERROR', ':Closting', 'Link:', *******identifying details**********,'(Connection', 'timed', 'out')'

I decided to simplify everything that would help me study down, but even with this unusually simple program, I still get this error:

import sys
import socket
import string

HOST="irc.freenode.net"
PORT=6667
NICK="nick"
IDENT="nick"
REALNAME="realname"
readbuffer=""

s=socket.socket( )
s.connect((HOST, PORT))
s.send("".join(["NICK",NICK,"\r\n"]).encode())
s.send("".join(["USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME)]).encode())

while 1:
    readbuffer=readbuffer+s.recv(1024).decode()
    temp=str.split(readbuffer, "\n")
    readbuffer=temp.pop( )

    for line in temp:
        line=str.rstrip(line)
        line=str.split(line)
        if(line[0]=="PING"):
            s.send("".join(["PONG ",line[1], "\r\n"]).encode())
        print (line)

I’m at a point, I’m sure that I’m definitely approaching what the people who posted there (and almost everywhere). What am I doing wrong?

+4
source share
1 answer

Take a close look at this line of code:

s.send("".join(["NICK",NICK,"\r\n"]).encode())

If you replaced s.sendwith print, you will realize that it sends the lines as follows:

NICKnick<CR><LF>

! . - . , :

s.send("".join(["NICK ",NICK,"\r\n"]).encode())

, .

+1

All Articles