]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/opertype.cpp
Move lots of spanningtree items to commands
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / opertype.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "commands.h"
16 #include "treeserver.h"
17 #include "utils.h"
18
19 /** Because the core won't let users or even SERVERS set +o,
20  * we use the OPERTYPE command to do this.
21  */
22 CmdResult CommandOpertype::Handle(const std::vector<std::string>& params, User *u)
23 {
24         SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils;
25         std::string opertype = params[0];
26         if (!IS_OPER(u))
27                 ServerInstance->Users->all_opers.push_back(u);
28         u->modes[UM_OPERATOR] = 1;
29         OperIndex::iterator iter = ServerInstance->Config->oper_blocks.find(" " + opertype);
30         if (iter != ServerInstance->Config->oper_blocks.end())
31                 u->oper = iter->second;
32         else
33         {
34                 u->oper = new OperInfo;
35                 u->oper->name = opertype;
36         }
37
38         TreeServer* remoteserver = Utils->FindServer(u->server);
39         bool dosend = true;
40
41         if (Utils->quiet_bursts)
42         {
43                 /*
44                  * If quiet bursts are enabled, and server is bursting or silent uline (i.e. services),
45                  * then do nothing. -- w00t
46                  */
47                 if (remoteserver->bursting || ServerInstance->SilentULine(u->server))
48                 {
49                         dosend = false;
50                 }
51         }
52
53         if (dosend)
54                 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()));
55         return CMD_SUCCESS;
56 }
57