summaryrefslogtreecommitdiff
path: root/IrcConnection.py
diff options
context:
space:
mode:
Diffstat (limited to 'IrcConnection.py')
-rw-r--r--IrcConnection.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/IrcConnection.py b/IrcConnection.py
index 4a1d9ed..51a39be 100644
--- a/IrcConnection.py
+++ b/IrcConnection.py
@@ -6,20 +6,21 @@ import IrcHandler
class ircConnectThread(QThread):
sig = pyqtSignal(str, str, str)
nick_sig = pyqtSignal(str, str)
+ part_sig = pyqtSignal(str, str)
join_sig = pyqtSignal(str)
namreply_sig = pyqtSignal(str, str)
- def __init__(self):
+ def __init__(self, handler):
QThread.__init__(self)
self.reactor = irc.client.Reactor()
self.server = self.reactor.server()
- self.handler = IrcHandler.IrcHandler
+ self.handler = handler
def __del__(self):
self.wait()
def run(self):
try:
- self.c = self.server.connect("irc.blatech.net", 6667, "wtest")
+ self.c = self.server.connect("irc.blatech.net", 6667, self.handler.get_nick())
except irc.client.ServerConnectionError:
print(sys.exc_info()[1])
raise SystemExit(1)
@@ -31,6 +32,7 @@ class ircConnectThread(QThread):
self.c.add_global_handler("privmsg", self.on_privmsg)
self.c.add_global_handler("join", self.on_join)
self.c.add_global_handler("namreply", self.on_names)
+ self.c.add_global_handler("part", self.on_part)
self.reactor.process_forever()
def on_connect(self, connection, event):
@@ -39,7 +41,7 @@ class ircConnectThread(QThread):
return
def on_pubmsg(self, connection, event):
print(event)
- self.sig.emit(event.target, event.source, event.arguments[0])
+ self.sig.emit(event.target, event.source.split("!")[0], event.arguments[0])
def on_privmsg(self, connection, event):
self.sig.emit(event.source, "", event.arguments[0])
@@ -48,7 +50,10 @@ class ircConnectThread(QThread):
print(event)
nick = event.source.split("!")[0]
self.nick_sig.emit(event.target, event.source.split("!")[0])
- self.sig.emit(event.target, "", event.source + " joined " + event.target)
+
+ def on_part(self, connection, event):
+ nick = event.source.split("!")[0]
+ self.part_sig.emit(event.target, event.source.split("!")[0])
def on_names(self, connection, event):
print(event)