From ac094530b318b445dceabf8a90db28831dfb05ef Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Wed, 19 Apr 2017 17:26:31 +0100 Subject: Handle other users being kicked --- IrcConnection.py | 4 +++- IrcHandler.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/IrcConnection.py b/IrcConnection.py index 1de189f..a3db084 100644 --- a/IrcConnection.py +++ b/IrcConnection.py @@ -11,6 +11,7 @@ class ircConnectThread(QThread): topic_sig = pyqtSignal(str, str) namreply_sig = pyqtSignal(str, str) quit_sig = pyqtSignal(str, str) + kick_sig = pyqtSignal(str, str, str, str) def __init__(self, handler): QThread.__init__(self) self.reactor = irc.client.Reactor() @@ -81,7 +82,8 @@ class ircConnectThread(QThread): self.quit_sig.emit(nick, event.arguments[0]) def on_kick(self, connection, event): - print(event) + source_nick = event.source.split("!")[0] + self.kick_sig.emit(event.arguments[0], event.target, source_nick, event.arguments[1]) def on_mode(self, connection, event): print(event) diff --git a/IrcHandler.py b/IrcHandler.py index 4fb494d..f0f14a9 100644 --- a/IrcHandler.py +++ b/IrcHandler.py @@ -129,6 +129,16 @@ class IrcHandler(QObject): user_list.remove_nick(nickStr) chat_area.append(nickStr + " quit (" + quit_msg + ")") + def handle_kick(self, kicked_nick, channelStr, by_nick, reason): + if (channelStr in self.channels): + channel = self.channels.get(channelStr) + user_list = channel.get_view().findChild(QQuickItem, "nick_list") + chat_area = channel.get_view().findChild(QQuickItem, "chat_area") + if (kicked_nick != self.get_nick()): + user_list.remove_nick(kicked_nick) + channel.remove_user(kicked_nick) + chat_area.append(kicked_nick + " was kicked from " + channelStr + " by " + by_nick + " (" + reason +")") + def handle_topic(self, channelStr, topic): if (channelStr in self.channels): channel = self.channels.get(channelStr) @@ -142,6 +152,7 @@ class IrcHandler(QObject): self.irc.nick_sig.connect(self.handle_join) self.irc.part_sig.connect(self.handle_part) self.irc.quit_sig.connect(self.handle_quit) + self.irc.kick_sig.connect(self.handle_kick) self.irc.topic_sig.connect(self.handle_topic) # self.irc.join_sig.connect(self.join_channel) self.irc.start() -- cgit v1.2.3