bool RemoveAccept(User* user, User* whotoremove) { // Remove them from my list, so look up my list.. callerid_data* dat = extInfo.get(user, false); if (!dat) { user->WriteNumeric(ERR_ACCEPTNOT, "%s :is not on your accept list", whotoremove->nick.c_str()); return false; } if (!dat->accepting.erase(whotoremove)) { user->WriteNumeric(ERR_ACCEPTNOT, "%s :is not on your accept list", whotoremove->nick.c_str()); return false; } // Look up their list to remove me. callerid_data *dat2 = extInfo.get(whotoremove, false); if (!dat2) { // How the f**k is this possible. ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "ERROR: Inconsistency detected in callerid state, please report (3)"); return false; } if (!stdalgo::vector::swaperase(dat2->wholistsme, dat)) ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "ERROR: Inconsistency detected in callerid state, please report (4)"); user->WriteNotice(whotoremove->nick + " is no longer on your accept list"); return true; }
void ListAccept(User* user) { callerid_data* dat = extInfo.get(user, false); if (dat) { for (callerid_data::UserSet::iterator i = dat->accepting.begin(); i != dat->accepting.end(); ++i) user->WriteNumeric(RPL_ACCEPTLIST, (*i)->nick); } user->WriteNumeric(RPL_ENDOFACCEPT, ":End of ACCEPT list"); }
void ListAccept(User* user) { callerid_data* dat = extInfo.get(user, false); if (dat) { for (std::set<User*>::iterator i = dat->accepting.begin(); i != dat->accepting.end(); ++i) user->WriteNumeric(281, "%s %s", user->nick.c_str(), (*i)->nick.c_str()); } user->WriteNumeric(282, "%s :End of ACCEPT list", user->nick.c_str()); }
bool AddAccept(User* user, User* whotoadd) { // Add this user to my accept list first, so look me up.. callerid_data* dat = extInfo.get(user, true); if (dat->accepting.size() >= maxaccepts) { user->WriteNumeric(ERR_ACCEPTFULL, ":Accept list is full (limit is %d)", maxaccepts); return false; } if (!dat->accepting.insert(whotoadd).second) { user->WriteNumeric(ERR_ACCEPTEXIST, "%s :is already on your accept list", whotoadd->nick.c_str()); return false; } // Now, look them up, and add me to their list callerid_data *targ = extInfo.get(whotoadd, true); targ->wholistsme.push_back(dat); user->WriteNotice(whotoadd->nick + " is now on your accept list"); return true; }
bool RemoveAccept(User* user, User* whotoremove) { // Remove them from my list, so look up my list.. callerid_data* dat = extInfo.get(user, false); if (!dat) { user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str()); return false; } std::set<User*>::iterator i = dat->accepting.find(whotoremove); if (i == dat->accepting.end()) { user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str()); return false; } dat->accepting.erase(i); // Look up their list to remove me. callerid_data *dat2 = extInfo.get(whotoremove, false); if (!dat2) { // How the f**k is this possible. ServerInstance->Logs->Log("m_callerid", LOG_DEFAULT, "ERROR: Inconsistency detected in callerid state, please report (3)"); return false; } std::list<callerid_data*>::iterator it = std::find(dat2->wholistsme.begin(), dat2->wholistsme.end(), dat); if (it != dat2->wholistsme.end()) // Found me! dat2->wholistsme.erase(it); else ServerInstance->Logs->Log("m_callerid", LOG_DEFAULT, "ERROR: Inconsistency detected in callerid state, please report (4)"); user->WriteNotice(whotoremove->nick + " is no longer on your accept list"); return true; }