summaryrefslogtreecommitdiff
path: root/Applications/IRCClient/IRCChannel.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-18 20:56:45 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-18 20:56:45 +0100
commit55aa8190773721f1dc0a3f49bedea6ed8524b318 (patch)
treed3d7b893ca2d52bacd52fd7f4c8700eb299710e9 /Applications/IRCClient/IRCChannel.cpp
parent794c81626e548311e31ff28871c3482a873ff566 (diff)
downloadserenity-55aa8190773721f1dc0a3f49bedea6ed8524b318.zip
IRCClient: Colorize some channel messages (joins, parts, topics)
Diffstat (limited to 'Applications/IRCClient/IRCChannel.cpp')
-rw-r--r--Applications/IRCClient/IRCChannel.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/Applications/IRCClient/IRCChannel.cpp b/Applications/IRCClient/IRCChannel.cpp
index 6e2a01b64c..381f461ffe 100644
--- a/Applications/IRCClient/IRCChannel.cpp
+++ b/Applications/IRCClient/IRCChannel.cpp
@@ -32,14 +32,24 @@ void IRCChannel::add_member(const String& name, char prefix)
}
}
m_members.append({ name, prefix });
- dump();
+ m_member_model->update();
}
-void IRCChannel::add_message(char prefix, const String& name, const String& text)
+void IRCChannel::remove_member(const String& name)
{
+ m_members.remove_first_matching([&] (auto& member) { return name == member.name; });
+}
+
+void IRCChannel::add_message(char prefix, const String& name, const String& text, Color color)
+{
+ log().add_message(prefix, name, text, color);
+ window().did_add_message();
+}
+
+void IRCChannel::add_message(const String& text, Color color)
+{
+ log().add_message(text, color);
window().did_add_message();
- log().add_message(prefix, name, text);
- dump();
}
void IRCChannel::dump() const
@@ -60,19 +70,25 @@ void IRCChannel::handle_join(const String& nick, const String& hostmask)
{
if (nick == m_client.nickname())
m_open = true;
- add_message(' ', "", String::format("*** %s [%s] has joined %s", nick.characters(), hostmask.characters(), m_name.characters()));
+ add_message(String::format("*** %s [%s] has joined %s", nick.characters(), hostmask.characters(), m_name.characters()), Color::DarkGreen);
}
void IRCChannel::handle_part(const String& nick, const String& hostmask)
{
- if (nick == m_client.nickname())
+ if (nick == m_client.nickname()) {
m_open = false;
- add_message(' ', "", String::format("*** %s [%s] has parted from %s", nick.characters(), hostmask.characters(), m_name.characters()));
+ m_members.clear();
+ } else {
+ remove_member(nick);
+ }
+ m_member_model->update();
+ add_message(String::format("*** %s [%s] has parted from %s", nick.characters(), hostmask.characters(), m_name.characters()), Color::DarkGreen);
}
void IRCChannel::handle_topic(const String& nick, const String& topic)
{
- if (nick == m_client.nickname())
- m_open = false;
- add_message(' ', "", String::format("*** %s set topic to \"%s\"", nick.characters(), topic.characters()));
+ if (nick.is_null())
+ add_message(String::format("*** Topic is \"%s\"", topic.characters()), Color::DarkBlue);
+ else
+ add_message(String::format("*** %s set topic to \"%s\"", nick.characters(), topic.characters()), Color::DarkBlue);
}