From 04a26f18dd9841c07aeb0fbbb1b30e71308ba068 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 20 Apr 2017 17:02:28 +0100 Subject: Add ability to /part channels --- IrcHandler.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'IrcHandler.py') diff --git a/IrcHandler.py b/IrcHandler.py index 589087f..9fd8b39 100644 --- a/IrcHandler.py +++ b/IrcHandler.py @@ -26,6 +26,9 @@ class IrcHandler(QObject): def add_channel(self, channel): self.channels[channel.get_name()] = channel + def remove_channel(self, channel_name): + del self.channels[channel_name] + def get_server(): return self.server @@ -53,15 +56,29 @@ class IrcHandler(QObject): input_field.send_to_irc.connect(self.handle_input) channel.set_view(channel_view) + def part_channel(self, channelStr): + if (channelStr in self.channels): + res = self.irc.part_channel(channelStr) + if (res): + self.remove_channel(channelStr) + self.window.channel_tabs.remove_channel(channelStr) + def handle_input(self): current_channel = self.window.channel_tabs.property('currentItem').property('text') text = self.window.get_input(current_channel) if (text.startswith("/")): - command = text.split(" ")[0][1:] + params = text.split(" ") + command = params[0][1:] if (command == "join"): - channel = text.split(" ")[1] + channel = params[1] self.join_channel(channel) + elif (command == "part"): + if (len(params) > 1 and params[1].strip() != ""): + channel = params[1] + else: + channel = current_channel + self.part_channel(channel) else: self.sig.emit(current_channel, text) self.window.update_chat(current_channel, "<" + self.nick + "> " + text) -- cgit v1.2.3