diff options
-rw-r--r-- | IrcChannelForm.ui.qml | 14 | ||||
-rw-r--r-- | IrcConnection.py | 3 | ||||
-rw-r--r-- | IrcHandler.py | 35 | ||||
-rw-r--r-- | User.py | 2 |
4 files changed, 50 insertions, 4 deletions
diff --git a/IrcChannelForm.ui.qml b/IrcChannelForm.ui.qml index 053b04a..a3158d0 100644 --- a/IrcChannelForm.ui.qml +++ b/IrcChannelForm.ui.qml @@ -74,8 +74,8 @@ Item { width: 146 height: 20 Text { - text: name - property string nick + text: mode + nick + anchors.verticalCenter: parent.verticalCenter font.bold: false font.family: "Source Code Pro" @@ -88,7 +88,7 @@ Item { } function add_nick(nick, mode){ - nickListModel.append({name: '<b>'+mode+'</b>'+nick, nick: nick}) + nickListModel.append({mode: mode, nick: nick}) } function remove_nick(nick){ @@ -98,6 +98,14 @@ Item { } } } + + function update_mode(nick, mode){ + for (var i = 0; i < nickListModel.count; ++i) { + if (nickListModel.get(i).nick === nick) { + nickListModel.setProperty(i, "mode", mode) + } + } + } } Button { diff --git a/IrcConnection.py b/IrcConnection.py index a3db084..2df5913 100644 --- a/IrcConnection.py +++ b/IrcConnection.py @@ -12,6 +12,7 @@ class ircConnectThread(QThread): namreply_sig = pyqtSignal(str, str) quit_sig = pyqtSignal(str, str) kick_sig = pyqtSignal(str, str, str, str) + user_mode_sig = pyqtSignal(str, str, str, str) def __init__(self, handler): QThread.__init__(self) self.reactor = irc.client.Reactor() @@ -87,6 +88,8 @@ class ircConnectThread(QThread): def on_mode(self, connection, event): print(event) + source_nick = event.source.split("!")[0] + self.user_mode_sig.emit(event.target, event.arguments[1], event.arguments[0], source_nick) def on_cur_topic(self, connection, event): self.topic_sig.emit(event.arguments[0], event.arguments[1]) diff --git a/IrcHandler.py b/IrcHandler.py index f0f14a9..7d87ac5 100644 --- a/IrcHandler.py +++ b/IrcHandler.py @@ -145,6 +145,40 @@ class IrcHandler(QObject): channel.set_topic(topic) self.window.update_topic(channel, topic) + def handle_user_mode(self, channelStr, target_user, mode, source_user): + 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 (mode == "+v"): + mode_char = "+" + mode_chat_str = " gave voice to " + elif (mode == "+h"): + mode_char = "%" + mode_chat_str = " gave half-ops to " + elif (mode == "+o"): + mode_char = "@" + mode_chat_str = " gave ops to " + elif (mode == "+a"): + mode_char = "&" + mode_chat_str = " gave owner status to " + elif (mode == "-v"): + mode_char = "" + mode_chat_str = " removed voice from " + elif (mode == "-h"): + mode_char = "" + mode_chat_str = " removed half-ops from " + elif (mode == "-o"): + mode_char = "" + mode_chat_str = " removed ops from " + elif (mode == "-a"): + mode_char = "" + mode_chat_str = " removed owner status from " + + user_list.update_mode(target_user, mode_char) + channel.get_users()[target_user].set_mode(mode) + chat_area.append(source_user + mode_chat_str + target_user) + def connect_to_irc(self, view): self.irc.sig.connect(self.handle_msg) self.irc.join_sig.connect(self.join_channel) @@ -154,6 +188,7 @@ class IrcHandler(QObject): 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.user_mode_sig.connect(self.handle_user_mode) # self.irc.join_sig.connect(self.join_channel) self.irc.start() self.sig.connect(self.irc.send_msg) @@ -27,7 +27,7 @@ class User(): def get_mode(self): return self.mode - def set_host(self, mode): + def set_mode(self, mode): self.mode = mode def get_host(self): |