diff options
Diffstat (limited to 'src/users.cpp')
-rw-r--r-- | src/users.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/users.cpp b/src/users.cpp index 7aa9fdc22..b6556175e 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -11,7 +11,6 @@ #include "services.h" #include "modules.h" -#include "language.h" /* Hash maps used for users. Note UserListByUID will not be used on non-TS6 IRCds, and should never * be assumed to have users @@ -244,6 +243,33 @@ void User::SendMessage(const Anope::string &source, const Anope::string &msg) co ircdproto->SendNotice(findbot(source), this->nick, "%s", msg.c_str()); } +void User::SendMessage(BotInfo *source, LanguageString message, ...) const +{ + Anope::string m = GetString(this, message); + + if (Config->UseStrictPrivMsg) + m = m.replace_all_cs("%R", "/"); + else + m = m.replace_all_cs("%R", "/msg "); + + m = m.replace_all_cs("%S", source->nick); + + if (m.length() >= 4096) + Log() << "Warning, language string " << message << " is longer than 4096 bytes"; + + va_list args; + char buf[4096]; + va_start(args, message); + vsnprintf(buf, sizeof(buf) - 1, m.c_str(), args); + va_end(args); + + sepstream sep(buf, '\n'); + Anope::string line; + + while (sep.GetToken(line)) + this->SendMessage(source->nick, line.empty() ? " " : line); +} + /** Collides a nick. * * First, it marks the nick (if the user is on a registered nick, we don't use it without but it could be) @@ -314,7 +340,7 @@ void User::Collide(NickAlias *na) guestnick = Config->NSGuestNickPrefix + stringify(getrandom16()); } while (finduser(guestnick)); - notice_lang(Config->s_NickServ, this, FORCENICKCHANGE_CHANGING, guestnick.c_str()); + this->SendMessage(NickServ, FORCENICKCHANGE_CHANGING, guestnick.c_str()); ircdproto->SendForceNickChange(this, guestnick, Anope::CurTime); } else |