Skip to content

Commit

Permalink
added sending from the mini-irc client.
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Oct 29, 2010
1 parent 95e8a38 commit 4c49d21
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions ghtTests/ircClient.py
Expand Up @@ -14,28 +14,28 @@
class IRCCore(irc.IRCClient):
nickname = 'dosdsdssd'
def connectionMade(self):
self.nickname = self.factory.nickname
self.nickname = self.factory.window.nickName.text().encode('ascii')
self.factory.window.protocol = self
irc.IRCClient.connectionMade(self)
self.log('connected!!')
def connectionLost(self, reason):
self.log('disconnected... :( %s'%reason)
def signedOn(self):
self.join(self.factory.channel)
chanName = self.factory.window.channelName.text().encode('ascii')
self.join(chanName)
def joined(self, channel):
self.log('joined %s'%channel)
def privmsg(self, user, channel, msg):
self.log('%s %s %s'%(user, channel, msg))
def action(self, user, channel, msg):
self.log('action: %s %s %s'%(user, channel, msg))
def log(self, str):
self.factory.view.addItem(str)
self.factory.window.view.addItem(str)

class IRCCoreFactory(protocol.ClientFactory):
protocol = IRCCore
def __init__(self, channel, nickname, view):
self.channel = channel
self.nickname = nickname
self.view = view
def __init__(self, window):
self.window = window
def clientConnectionLost(self, connector, reason):
# reconnect to server if lose connection
connector.connect()
Expand Down Expand Up @@ -73,22 +73,34 @@ def __init__(self):
self.setWindowTitle('IRC')
self.setUnifiedTitleAndToolBarOnMac(True)
self.showMaximized()

self.protocol = None
def connectIRC(self):
self.connectButton.setDisabled(True)
chanName = self.channelName.text().encode('ascii')
nickName = self.nickName.text().encode('ascii')
ircCoreFactory = IRCCoreFactory(chanName, nickName, self.view)
self.channelName.setDisabled(True)
self.nickName.setDisabled(True)
self.serverName.setDisabled(True)
ircCoreFactory = IRCCoreFactory(self)
serverName = self.serverName.text().encode('ascii')
reactor.connectTCP(serverName, 6667, ircCoreFactory)
#reactor.run()
#reactor.runReturn()
#app.exit()
#app.exit()
reactor.run()
def sendMessage(self):
print(self.entry.text())
if self.protocol:
chanName = self.channelName.text().encode('ascii')
message = self.entry.text().encode('ascii')
self.protocol.msg(chanName, message)
self.view.addItem('%s <%s> %s'%(chanName, self.protocol.nickname, message))
else:
self.view.addItem('Not connected.')
self.entry.setText('')
def closeEvent(self, event):
print('Attempting to close the main window!')
reactor.stop()
event.accept()

if __name__ == '__main__':
mainWin = MainWindow()
reactor.runReturn()
sys.exit(app.exec_())

0 comments on commit 4c49d21

Please sign in to comment.