Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from ex3utils import Client
- import time
- class IRCClient(Client):
- def onMessage(self, socket, message):
- print message
- # *** process incoming messages here ***
- return True
- # Parse the IP address and port you wish to connect to.
- ip = sys.argv[1]
- port = int(sys.argv[2])
- screenName = sys.argv[3]
- # Create an IRC client.
- client = IRCClient()
- # Start server
- client.start(ip, port)
- # *** register your client here, e.g. ***
- client.send('REG %s' % screenName)
- while client.isRunning():
- try:
- typedInput = raw_input("> ").strip()
- (command, sep, parameter) = typedInput.strip().partition(' ')
- if (command == 'TO'):
- (para, sep, mess) = parameter.strip().partition(' ')
- text = para + ' ' + mess
- client.send(text)
- elif (command == 'SHOW'):
- client.send('SHOW')
- else:
- sendText = typedInput
- client.send(sendText)
- # *** process input from the user in a loop here ***
- # *** use client.send(someMessage) to send messages to the server
- except:
- client.stop();
- print 'You are exiting the chat. Goodbye!'
- client.stop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement