summaryrefslogtreecommitdiff
path: root/IrcHandler.py
diff options
context:
space:
mode:
authorJoe Robinson <joe@grabyo.com>2017-08-14 14:40:32 +0100
committerJoe Robinson <joe@grabyo.com>2017-08-14 14:40:32 +0100
commit01b801e747793bf708a8284e37f13469d2c9a960 (patch)
tree92ffee0ba8cc35cb8e4d4e0133c40f7fa78b9f6a /IrcHandler.py
parent04a26f18dd9841c07aeb0fbbb1b30e71308ba068 (diff)
Handle nick already been taken, add some output for connection and status messagesHEADmaster
Diffstat (limited to 'IrcHandler.py')
-rw-r--r--IrcHandler.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/IrcHandler.py b/IrcHandler.py
index 9fd8b39..8d0c47f 100644
--- a/IrcHandler.py
+++ b/IrcHandler.py
@@ -41,6 +41,9 @@ class IrcHandler(QObject):
def set_nick(self, nick):
self.nick = nick
+ def change_nick(self, new_nick):
+ self.irc.change_nick(new_nick)
+
@pyqtSlot(str)
def join_channel(self, channelStr):
res = self.irc.join_channel(channelStr)
@@ -79,6 +82,9 @@ class IrcHandler(QObject):
else:
channel = current_channel
self.part_channel(channel)
+ elif (command == "nick"):
+ new_nick = params[1]
+ self.change_nick(new_nick)
else:
self.sig.emit(current_channel, text)
self.window.update_chat(current_channel, "<b>&lt;" + self.nick + "&gt;</b> " + text)
@@ -91,6 +97,10 @@ class IrcHandler(QObject):
channel = self.channels[channelStr]
self.window.update_chat(channelStr, "<b>&lt;" + nick + "&gt;</b> " + msg)
+ @pyqtSlot(str)
+ def handle_status_msg(self, msg):
+ self.window.update_chat("status", msg)
+
@pyqtSlot(str, str)
def handle_nicks(self, channelStr, nicks):
nick_listStr = nicks.split(" ")[0:-1]
@@ -208,6 +218,23 @@ class IrcHandler(QObject):
channel.get_users()[target_user].set_mode(mode)
chat_area.append(source_user + mode_chat_str + target_user)
+ def handle_error(self, error_msg, target):
+ #Output the error in the relevant channel if one is provided
+ if(target != ""):
+ channel_view = self.channels.get(target).get_view();
+ #Otherwise use the currently selected channel
+ else:
+ current_channel = self.window.channel_tabs.property('currentItem').property('text')
+ channel = self.channels.get(current_channel)
+ #Default to the status channel if there's an issue (probably because status is the currently selected channel)
+ if (channel == None):
+ target = "status"
+ else:
+ target = current_channel
+
+ self.window.update_chat(target, error_msg)
+
+
def connect_to_irc(self, view):
self.irc.sig.connect(self.handle_msg)
self.irc.namreply_sig.connect(self.handle_nicks)
@@ -218,6 +245,8 @@ class IrcHandler(QObject):
self.irc.kick_sig.connect(self.handle_kick)
self.irc.topic_sig.connect(self.handle_topic)
self.irc.user_mode_sig.connect(self.handle_user_mode)
+ self.irc.error_sig.connect(self.handle_error)
+ self.irc.status_sig.connect(self.handle_status_msg)
# self.irc.join_sig.connect(self.join_channel)
self.irc.start()
self.sig.connect(self.irc.send_msg)