IRC bot cannot join the channel

import socket

irc = 'irc.hack3r.com'
port = 6667
channel = '#chat'
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sck.connect((irc, port))
sck.send('NICK supaBOT\r\n')
sck.send('USER supaBOT supaBOT supaBOT :supaBOT Script\r\n')
sck.send('JOIN #chat' + '\r\n')
data = ''
while True:
     data = sck.recv(4096)
     if data.find('PING') != -1:
        sck.send('PONG ' + data.split() [1] + '\r\n')
        print data

print sck.recv(4096)

When I connect to the server, I can’t connect to the channel, I get this error:

"451 JOIN: you are not registered"

+3
source share
4 answers

It seems that you are not registered, and this is a requirement to join this channel. You will need to register your nickname and then identify it before joining.

, irc . RFC 1459 , . ( Twisted. twisted.words IRC) , . (, .)

+2

. JOIN . , NICK USER, " ". . : IRC Python .

IRC, . , RFC 1459. , 100% . , !

, Daenyth sais, - IRC-. RFC !

+11

, , , nickserv . IRC- , .

0

Python twisted irc client

sudo yum install python-twisted-words

sudo apt-get install python-twisted-words

API

http://twistedmatrix.com/documents/8.2.0/api/twisted.words.protocols.irc.IRCClient.html

#!/usr/bin/env python2.7

from twisted.internet import reactor, protocol
from twisted.words.protocols import irc

class IRCLogger(irc.IRCClient):
    logfile = file('/tmp/freenode.txt', 'a+')

    nick = 'davey_jones_logger'

    def signedOn(self):
        self.join('#scala')

    def privmsg(self, user, channel, message):
        print "Got msg %s " % message
        self.logfile.write(" %s said %s \n" % ( user.split('!')[0], message ))
        self.logfile.flush()

def main():
    f = protocol.ReconnectingClientFactory()
    f.protocol = IRCLogger
    reactor.connectTCP('irc.freenode.net', 6667, f)
    reactor.run()

if __name__ == '__main__':
    main()
0

Source: https://habr.com/ru/post/1733589/


All Articles