summaryrefslogtreecommitdiff
path: root/IrcHandler.py
diff options
context:
space:
mode:
authorJoe Robinson <joe@grabyo.com>2017-04-20 17:02:28 +0100
committerJoe Robinson <joe@grabyo.com>2017-04-20 17:02:28 +0100
commit04a26f18dd9841c07aeb0fbbb1b30e71308ba068 (patch)
treeaf74cea19af4cff73bb48a790a003584d8557bfe /IrcHandler.py
parent4e172068e8e817d80d2e9575289feb8a4314be49 (diff)
Add ability to /part channels
Diffstat (limited to 'IrcHandler.py')
-rw-r--r--IrcHandler.py21
1 files changed, 19 insertions, 2 deletions
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, "<b>&lt;" + self.nick + "&gt;</b> " + text)