CmdResult HandleLocal(LocalUser* user, const Params& parameters) override { char subcmd = toupper(parameters[0][0]); if (subcmd == '+') { if (parameters.size() > 1) HandlePlus(user, parameters[1]); } else if (subcmd == '-') { if (parameters.size() > 1) HandleMinus(user, parameters[1]); } else if (subcmd == 'C') { manager.UnwatchAll(user); } else if (subcmd == 'L') { user->CommandFloodPenalty += ListPenalty; const IRCv3::Monitor::WatchedList& list = manager.GetWatched(user); ReplyBuilder out(user, RPL_MONLIST); for (IRCv3::Monitor::WatchedList::const_iterator i = list.begin(); i != list.end(); ++i) { IRCv3::Monitor::Entry* entry = *i; out.Add(entry->GetNick()); } out.Flush(); user->WriteNumeric(RPL_ENDOFMONLIST, "End of MONITOR list"); } else if (subcmd == 'S') { user->CommandFloodPenalty += ListPenalty; ReplyBuilder online(user, RPL_MONONLINE); ReplyBuilder offline(user, RPL_MONOFFLINE); const IRCv3::Monitor::WatchedList& list = manager.GetWatched(user); for (IRCv3::Monitor::WatchedList::const_iterator i = list.begin(); i != list.end(); ++i) { IRCv3::Monitor::Entry* entry = *i; ReplyBuilder& out = (IRCv3::Monitor::Manager::FindNick(entry->GetNick()) ? online : offline); out.Add(entry->GetNick()); } online.Flush(); offline.Flush(); } else return CMD_FAILURE; return CMD_SUCCESS; }
void DisplayMeter::TriggerMsg(HOBJECT hSender, const char *szMsg) { ILTCommon* pCommon = g_pLTServer->Common(); if (!pCommon) return; // ConParse does not destroy szMsg, so this is safe ConParse parse; parse.Init((char*)szMsg); while (pCommon->Parse(&parse) == LT_OK) { if (parse.m_nArgs > 0 && parse.m_Args[0]) { if ((_stricmp(parse.m_Args[0], "show") == 0)) { if (parse.m_nArgs > 1) { HandleShow((uint8)atoi(parse.m_Args[1])); } else HandleShow(100); } else if (_stricmp(parse.m_Args[0], "plus") == 0) { if (parse.m_nArgs > 1) { HandlePlus((uint8)atoi(parse.m_Args[1])); } } else if (_stricmp(parse.m_Args[0], "minus") == 0) { if (parse.m_nArgs > 1) { HandleMinus((uint8)atoi(parse.m_Args[1])); } } else if (_stricmp(parse.m_Args[0], "set") == 0) { if (parse.m_nArgs > 1) { HandleSet((uint8)atoi(parse.m_Args[1])); } } else if (_stricmp(parse.m_Args[0], "hide") == 0) { HandleEnd(); } } } }
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override { if (parameters.empty()) { HandleList(user, false); return CMD_SUCCESS; } bool watch_l_done = false; bool watch_s_done = false; for (std::vector<std::string>::const_iterator i = parameters.begin(); i != parameters.end(); ++i) { const std::string& token = *i; char subcmd = toupper(token[0]); if (subcmd == '+') { HandlePlus(user, token.substr(1)); } else if (subcmd == '-') { HandleMinus(user, token.substr(1)); } else if (subcmd == 'C') { manager.UnwatchAll(user); } else if ((subcmd == 'L') && (!watch_l_done)) { watch_l_done = true; // WATCH L requests a full list with online and offline nicks // WATCH l requests a list with only online nicks HandleList(user, (token[0] == 'L')); } else if ((subcmd == 'S') && (!watch_s_done)) { watch_s_done = true; HandleStats(user); } } return CMD_SUCCESS; }