Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://archive.oreilly.com/pub/h/1968
- import errno
- import socket
- import sys
- nick = sys.argv[1]
- def send(*args):
- line = ' '.join(args) + '\r\n'
- conn.sendall(line.encode('utf-8'))
- conn = socket.create_connection(('localhost', 6667))
- send('NICK', nick)
- send('USER', nick, nick, nick, nick)
- send('JOIN', '#c1')
- while True:
- #import readline; print readline.redisplay
- msg = input('> ')
- try:
- buf = conn.recv(1024, socket.MSG_DONTWAIT)
- except socket.error as e:
- if e.errno != errno.EAGAIN:
- raise
- else:
- print(buf.decode('utf-8'))
- if msg:
- send('PRIVMSG', '#c1', ':' + msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement