- QString sender = e->network()->isMyNick(oldnick) ? newnick : e->prefix();
- foreach(const QString &channel, ircuser->channels())
- displayMsg(e, Message::Nick, newnick, sender, channel);
+ QString sender;
+ Message::Flag msgFlags = Message::Flag::None;
+ if (e->testFlag(EventManager::Self)) {
+ // Treat the sender as the new nickname, mark the message as Self
+ sender = newnick;
+ msgFlags = Message::Self;
+ } else {
+ // Take the sender from the event prefix, don't mark the message
+ sender = e->prefix();
+ }
+
+ // Announce to all channels the IrcUser is in
+ foreach(const QString &channel, ircuser->channels()) {
+ displayMsg(e, Message::Nick, newnick, sender, channel, msgFlags);
+ }