summaryrefslogtreecommitdiff
path: root/bouncer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bouncer/richtext.cpp17
-rw-r--r--bouncer/richtext.h6
-rw-r--r--bouncer/window.cpp27
3 files changed, 40 insertions, 10 deletions
diff --git a/bouncer/richtext.cpp b/bouncer/richtext.cpp
index 22c6330..2deebda 100644
--- a/bouncer/richtext.cpp
+++ b/bouncer/richtext.cpp
@@ -174,3 +174,20 @@ const char *RichTextBuilder::c_str() {
return data();
}
+
+
+
+void RichTextBuilder::appendNick(const char *nick) {
+ uint32_t hash = 0;
+ const char *c = nick;
+ while (*c)
+ hash = (hash * 17) + *(c++);
+
+ int r = ((hash & 0xFF0000) >> 16);
+ int g = ((hash & 0xFF00) >> 8);
+ int b = (hash & 0xFF);
+
+ foreground(COL_LEVEL_NICK, r, g, b);
+ append(nick);
+ endForeground(COL_LEVEL_NICK);
+}
diff --git a/bouncer/richtext.h b/bouncer/richtext.h
index 608a1d6..c2f8d01 100644
--- a/bouncer/richtext.h
+++ b/bouncer/richtext.h
@@ -48,6 +48,11 @@ public:
void colour(bool background, int layer, int r, int g, int b) {
writeU8(0x10 + (background ? 4 : 0) + layer);
+
+ r >>= 1;
+ g >>= 1;
+ b >>= 1;
+
writeU8((r==0)?2:(r&254));
writeU8((g==0)?1:g);
writeU8((b==0)?1:b);
@@ -86,6 +91,7 @@ public:
}
void appendIRC(const char *str);
+ void appendNick(const char *nick);
const char *c_str();
};
diff --git a/bouncer/window.cpp b/bouncer/window.cpp
index 04689f5..a8a7bb2 100644
--- a/bouncer/window.cpp
+++ b/bouncer/window.cpp
@@ -171,6 +171,13 @@ void StatusWindow::handleUserInput(const char *str) {
pushMessage("Server password changed.");
else
pushMessage("Server password cleared.");
+
+ } else if (strcmp(str, "/c") == 0) {
+ RichTextBuilder rt;
+ rt.foreground(2, 100, 0, 255);
+ rt.append("boooooop");
+ rt.endForeground(2);
+ pushMessage(rt.c_str());
}
} else {
server->sendLine(str);
@@ -303,7 +310,7 @@ void Channel::outputUserAction(int colour, const UserRef &user, const char *pref
rt.append("You have ");
} else {
rt.bold();
- rt.append(user.nick.c_str());
+ rt.appendNick(user.nick.c_str());
rt.endBold();
rt.append(" (");
@@ -428,14 +435,14 @@ void Channel::handleKick(const UserRef &user, const char *target, const char *me
inChannel = false;
rt.append("You have been kicked by ");
- rt.append(user.nick.c_str());
+ rt.appendNick(user.nick.c_str());
} else {
if (user.isSelf) {
rt.append("You have kicked ");
} else {
rt.bold();
- rt.append(user.nick.c_str());
+ rt.appendNick(user.nick.c_str());
rt.endBold();
rt.append(" has kicked ");
}
@@ -476,13 +483,13 @@ void Channel::handleNick(const UserRef &user, const char *newNick) {
rt.append("You are now known as ");
} else {
rt.bold();
- rt.append(user.nick.c_str());
+ rt.appendNick(user.nick.c_str());
rt.endBold();
rt.append(" is now known as ");
}
rt.bold();
- rt.append(newNick);
+ rt.appendNick(newNick);
rt.endBold();
pushMessage(rt.c_str());
@@ -544,7 +551,7 @@ void Channel::handleMode(const UserRef &user, const char *str) {
rt.append("-- ");
rt.bold();
- rt.append(user.nick.c_str());
+ rt.appendNick(user.nick.c_str());
rt.endBold();
rt.append(addFlag ? " set mode " : " cleared mode ");
@@ -582,7 +589,7 @@ void Channel::handleMode(const UserRef &user, const char *str) {
rt.append("-- ");
rt.bold();
- rt.append(user.nick.c_str());
+ rt.appendNick(user.nick.c_str());
rt.endBold();
rt.append(addFlag ? " set channel mode " : " cleared channel mode ");
@@ -616,7 +623,7 @@ void Channel::outputUserMessage(const char *nick, const char *str, bool isAction
rt.writeS8(prefix);
rt.bold();
- rt.append(nick);
+ rt.appendNick(nick);
rt.endBold();
rt.append(isAction ? " " : "> ");
@@ -635,7 +642,7 @@ void Channel::handleCtcp(const UserRef &user, const char *type, const char *para
rt.append("*** CTCP from ");
rt.bold();
- rt.append(user.nick.c_str());
+ rt.appendNick(user.nick.c_str());
rt.endBold();
rt.append(": ");
@@ -655,7 +662,7 @@ void Channel::handleTopic(const UserRef &user, const char *message) {
if (user.isValid) {
rt.append("*** ");
rt.bold();
- rt.append(user.nick.c_str());
+ rt.appendNick(user.nick.c_str());
rt.endBold();
rt.append(" changed the topic to: ");
} else {