diff options
Diffstat (limited to 'bouncer/window.cpp')
-rw-r--r-- | bouncer/window.cpp | 122 |
1 files changed, 118 insertions, 4 deletions
diff --git a/bouncer/window.cpp b/bouncer/window.cpp index 01849e2..dd22e7e 100644 --- a/bouncer/window.cpp +++ b/bouncer/window.cpp @@ -374,10 +374,16 @@ void Channel::handleNick(const UserRef &user, const char *newNick) { Packet::B2C_CHANNEL_USER_RENAME, packet); char buf[1024]; - snprintf(buf, 1024, - "%s is now known as %s", - user.nick.c_str(), - newNick); + if (user.isSelf) { + snprintf(buf, 1024, + "You are now known as %s", + newNick); + } else { + snprintf(buf, 1024, + "%s is now known as %s", + user.nick.c_str(), + newNick); + } pushMessage(buf); } @@ -539,3 +545,111 @@ void Channel::disconnected() { pushMessage("You have been disconnected."); } } + + + + + + +Query::Query(IRCServer *_server, const char *_partner) : + Window(_server->bouncer), + server(_server), + partner(_partner) +{ + server->bouncer->registerWindow(this); +} + +const char *Query::getTitle() const { + return partner.c_str(); +} + +int Query::getType() const { + return 3; +} + +void Query::handleUserInput(const char *str) { + char msgBuf[16384]; + + if (str[0] == '/') { + if (strncmp(str, "/me ", 4) == 0) { + // The duplication of code between here and + // handlePrivmsg is ugly. TODO: fixme. + + snprintf(msgBuf, sizeof(msgBuf), + "* %s %s", + server->currentNick, + &str[4]); + pushMessage(msgBuf); + + snprintf(msgBuf, sizeof(msgBuf), + "PRIVMSG %s :\x01" "ACTION %s\x01", + partner.c_str(), + &str[4]); + server->sendLine(msgBuf); + } + } else { + // Aaaand this is also pretty ugly ><;; + // TODO: fixme. + + snprintf(msgBuf, sizeof(msgBuf), + "<%s> %s", + server->currentNick, + str); + pushMessage(msgBuf); + + snprintf(msgBuf, sizeof(msgBuf), + "PRIVMSG %s :%s", + partner.c_str(), + str); + server->sendLine(msgBuf); + } +} + +void Query::handleQuit(const char *message) { + char buf[1024]; + + snprintf(buf, 1024, + "%s has quit (%s)", + partner.c_str(), + message); + + pushMessage(buf); +} + +void Query::showNickChange(const UserRef &user, const char *newNick) { + char buf[1024]; + + if (user.isSelf) { + snprintf(buf, 1024, + "You are now known as %s", + newNick); + } else { + snprintf(buf, 1024, + "%s is now known as %s", + user.nick.c_str(), + newNick); + } + + pushMessage(buf); +} + +void Query::handlePrivmsg(const char *str) { + char buf[15000]; + snprintf(buf, 15000, + "<%s> %s", + partner.c_str(), + str); + + pushMessage(buf); +} + +void Query::renamePartner(const char *_partner) { + Buffer packet; + packet.writeU32(id); + packet.writeStr(_partner); + + server->bouncer->sendToClients( + Packet::B2C_WINDOW_RENAME, packet); + + partner = _partner; +} |