X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmode.cpp;h=8b91f7af52de55ec4bcc2d66bd182d4f20572835;hb=cd7657bddc7a6dc2e7326077d173a874bf71f6bd;hp=7a31038a64162383a9715cdf8ff25cc47da2ffef;hpb=7ad9ad1e2b6ccf03dbb5f5148cca1bbf89c2775a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/mode.cpp b/src/mode.cpp index 7a31038a6..8b91f7af5 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -246,11 +246,17 @@ void ModeParser::DisplayCurrentModes(userrec *user, userrec* targetuser, chanrec } else if (targetuser) { - if ((targetuser == user) || (*user->oper)) + if (targetuser->Visibility && !targetuser->Visibility->VisibleTo(user)) + { + user->WriteServ("401 %s %s :No such nick/channel",user->nick, text); + return; + } + + if ((targetuser == user) || (IS_OPER(user))) { /* Display user's current mode string */ user->WriteServ("221 %s :+%s",targetuser->nick,targetuser->FormatModes()); - if (*targetuser->oper) + if (IS_OPER(targetuser)) user->WriteServ("008 %s +%s :Server notice mask", targetuser->nick, targetuser->FormatNoticeMasks()); return; } @@ -490,6 +496,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) { + ServerInstance->Log(DEBUG,"Call mode watcher"); if ((*watchers)->BeforeMode(user, targetuser, targetchannel, parameter, adding, type) == false) { abort = true; @@ -506,13 +513,28 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool if (abort) continue; } + else + { + /* Fix by brain: mode watchers not being called for parameterless modes */ + for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) + { + if ((*watchers)->BeforeMode(user, targetuser, targetchannel, parameter, adding, type) == false) + { + abort = true; + break; + } + } + + if (abort) + continue; + } /* It's an oper only mode, check if theyre an oper. If they arent, * eat any parameter that came with the mode, and continue to next */ - if ((IS_LOCAL(user)) && (modehandlers[handler_id]->NeedsOper()) && (!*user->oper)) + if ((IS_LOCAL(user)) && (modehandlers[handler_id]->NeedsOper()) && (!IS_OPER(user))) { - user->WriteServ("481 %s :Permission Denied- Only IRC operators may %sset %s mode %c", user->nick, + user->WriteServ("481 %s :Permission Denied - Only IRC operators may %sset %s mode %c", user->nick, adding ? "" : "un", type == MODETYPE_CHANNEL ? "channel" : "user", modehandlers[handler_id]->GetModeChar()); continue; @@ -876,7 +898,7 @@ std::string ModeParser::ChanModes() return type1 + "," + type2 + "," + type3 + "," + type4; } -bool ModeParser::PrefixComparison(const prefixtype one, const prefixtype two) +bool ModeParser::PrefixComparison(prefixtype one, prefixtype two) { return one.second > two.second; } @@ -925,6 +947,7 @@ bool ModeParser::AddModeWatcher(ModeWatcher* mw) pos = (mw->GetModeChar()-65) | mask; modewatchers[pos].push_back(mw); + return true; }