Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. import os, sys, time
  2. import Queue
  3. from PyQt4.QtCore import *
  4. from PyQt4.QtGui import *
  5.  
  6. import qt4reactor
  7. qt4reactor.install()
  8.  
  9.  
  10. #from twistedclient import SocketClientFactory
  11. from twisted.words.protocols import irc
  12. from twisted.internet import protocol
  13.  
  14. class qttmwirc_conn(irc.IRCClient):
  15.   nickname = "qttmwirc"
  16.   def signedOn(self):
  17.     print "signed on"
  18.   def privmsg(self, user, channel, msg):
  19.     print "privmsg:", [user, channel, msg]
  20.    
  21. class qttmwirc_factory(protocol.ClientFactory):
  22.   def __init__(self):
  23.       pass
  24.   def buildProtocol(self, addr):
  25.       p = qttmwirc_conn()
  26.       p.factory = self
  27.       return p
  28.  
  29.   def clientConnectionLost(self, connector, reason):
  30.       """If we get disconnected, reconnect to server."""
  31.       connector.connect()
  32.  
  33.   def clientConnectionFailed(self, connector, reason):
  34.       print "connection failed:", reason
  35.       reactor.stop()
  36.      
  37. instance = qttmwirc_factory()
  38.  
  39. class qttmwirc_gui(QMainWindow):
  40.     def __init__(self, reactor, parent=None):
  41.         super(qttmwirc_gui, self).__init__(parent)
  42.         self.reactor = reactor
  43.        
  44.     def closeEvent(self, event):
  45.       reactor.stop()
  46.      
  47.     def lastWindowClosed(self, *args):
  48.       print "last windo closed"
  49.      
  50.        
  51. app = QApplication(sys.argv)
  52.  
  53.  
  54. from twisted.internet import reactor
  55. mainwindow = qttmwirc_gui(reactor)
  56. mainwindow.showMaximized()
  57.  
  58. reactor.connectTCP("irc.freenode.net", 6667, instance)
  59.  
  60. reactor.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement