void InspIRCd::ProcessColors(file_cache& input) { /* * Replace all color codes from the special[] array to actual * color code chars using C++ style escape sequences. You * can append other chars to replace if you like -- Justasic */ static struct special_chars { std::string character; std::string replace; special_chars(const std::string& c, const std::string& r) : character(c) , replace(r) { } } special[] = { special_chars("\\b", "\x02"), // Bold special_chars("\\c", "\x03"), // Color special_chars("\\i", "\x1D"), // Italic special_chars("\\m", "\x11"), // Monospace special_chars("\\r", "\x16"), // Reverse special_chars("\\s", "\x1E"), // Strikethrough special_chars("\\u", "\x1F"), // Underline special_chars("\\x", "\x0F"), // Reset special_chars("", "") }; for(file_cache::iterator it = input.begin(), it_end = input.end(); it != it_end; it++) { std::string ret = *it; for(int i = 0; special[i].character.empty() == false; ++i) { std::string::size_type pos = ret.find(special[i].character); if(pos == std::string::npos) // Couldn't find the character, skip this line continue; if((pos > 0) && (ret[pos-1] == '\\') && (ret[pos] == '\\')) continue; // Skip double slashes. // Replace all our characters in the array while(pos != std::string::npos) { ret = ret.substr(0, pos) + special[i].replace + ret.substr(pos + special[i].character.size()); pos = ret.find(special[i].character, pos + special[i].replace.size()); } } // Replace double slashes with a single slash before we return std::string::size_type pos = ret.find("\\\\"); while(pos != std::string::npos) { ret = ret.substr(0, pos) + "\\" + ret.substr(pos + 2); pos = ret.find("\\\\", pos + 1); } *it = ret; } }
void ShowOperMOTD(User* user) { if (opermotd.empty()) { user->WriteRemoteNumeric(455, "OPERMOTD file is missing"); return; } user->WriteRemoteNumeric(375, "- IRC Operators Message of the Day"); for (file_cache::const_iterator i = opermotd.begin(); i != opermotd.end(); ++i) { user->WriteRemoteNumeric(372, InspIRCd::Format("- %s", i->c_str())); } user->WriteRemoteNumeric(376, "- End of OPERMOTD"); }
void ShowOperMOTD(User* user) { const std::string& servername = ServerInstance->Config->ServerName; if (opermotd.empty()) { user->SendText(":%s 455 %s :OPERMOTD file is missing", servername.c_str(), user->nick.c_str()); return; } user->SendText(":%s 375 %s :- IRC Operators Message of the Day", servername.c_str(), user->nick.c_str()); for (file_cache::const_iterator i = opermotd.begin(); i != opermotd.end(); ++i) { user->SendText(":%s 372 %s :- %s", servername.c_str(), user->nick.c_str(), i->c_str()); } user->SendText(":%s 376 %s :- End of OPERMOTD", servername.c_str(), user->nick.c_str()); }