]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/opertype.cpp
m_spanningtree Remove duplicate code for sending channel messages from RouteCommand()
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / opertype.cpp
index 97a4de8c20ee5fc53f6534c691dd0c8ced78eaa7..c3f9b633cf33da570d5b5491781d9794f4acb41e 100644 (file)
 /** Because the core won't let users or even SERVERS set +o,
  * we use the OPERTYPE command to do this.
  */
-CmdResult CommandOpertype::Handle(const std::vector<std::string>& params, User *u)
+CmdResult CommandOpertype::Handle(User* u, std::vector<std::string>& params)
 {
-       SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils;
-       std::string opertype = params[0];
-       if (!IS_OPER(u))
+       const std::string& opertype = params[0];
+       if (!u->IsOper())
                ServerInstance->Users->all_opers.push_back(u);
-       u->modes[UM_OPERATOR] = 1;
-       OperIndex::iterator iter = ServerInstance->Config->oper_blocks.find(" " + opertype);
-       if (iter != ServerInstance->Config->oper_blocks.end())
+
+       ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
+       u->SetMode(opermh, true);
+
+       OperIndex::iterator iter = ServerInstance->Config->OperTypes.find(opertype);
+       if (iter != ServerInstance->Config->OperTypes.end())
                u->oper = iter->second;
        else
        {
@@ -53,7 +55,7 @@ CmdResult CommandOpertype::Handle(const std::vector<std::string>& params, User *
                        return CMD_SUCCESS;
        }
 
-       ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server.c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), irc::Spacify(opertype.c_str()));
+       ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server.c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), opertype.c_str());
        return CMD_SUCCESS;
 }