sockets and classes
TheDustbustr
thedustbustr at aol.com
Tue Jul 31 16:11:48 EDT 2001
Having quite a bit of trouble with sockets and classes lately. I am writing an
IRC bot, heres the trouble code:
#BEGIN CODE BLOCK
import socket, string, sys, errno, thread
HOST = 'liberty.nj.us.dal.net'
PORT = 7000
NICK='Dustin2'
REAL='Ima Bot'
QUITMSG='Bye'
IDENT='hacker'
class Irc:
def __init__(self, host, port):
self.host = host
self.port = port
def connect(self):
print 'Connecting to %s:%s' % (self.host, self.port)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.host, self.port))
def sendcmd(self, cmd):
self.sock.send(cmd)
irc=Irc(HOST, PORT)
irc.connect()
print "Sending USER"
irc.sendcmd('USER %s localhost localhost :%s\n' % (IDENT, REAL))
print "Sending NICK"
irc.sendcmd('NICK %s\n' % NICK)
print "Sending JOIN"
irc.sendcmd('JOIN #Dustin1')
#END CODE BLOCK
I don't get error messages while executing irc.sendcmd(), but it doesnt work.
I should recieve a response fromt he server after sending USER and NICK, then
another response after sending JOIN. But, I get nothing. Whats up!?
PS: This is my first attempt to program using classes, and perhaps I'm not
doing it right?
Thanks, Dustin
More information about the Python-list
mailing list