forked from inspircd/inspircd-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm_autooper.cpp
51 lines (42 loc) · 1.73 KB
/
m_autooper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $ModAuthor: Sebastian Nielsen */
/* $ModAuthorMail: [email protected] */
/* $ModDesc: Adds a opertype option to connect blocks so operators can get autologged in via IP */
/* $ModDepends: core 2.0 */
/* $ModConfig: Within connect block: opertype="OPER TYPE HERE" */
#include "inspircd.h"
class ModuleAutoOper : public Module
{
public:
void init()
{
ServerInstance->Modules->Attach(I_OnUserConnect, this);
}
void OnUserConnect(LocalUser* user)
{
ConfigTag* tag = user->MyClass->config;
std::string opertype = tag->getString("opertype");
if (opertype.empty())
return;
OperIndex::iterator opit = ServerInstance->Config->oper_blocks.find(" " + opertype);
if (opit == ServerInstance->Config->oper_blocks.end())
{
ServerInstance->Logs->Log("m_autooper", DEFAULT, "m_autooper: Oper type %s in connect block %s not found", opertype.c_str(), user->MyClass->name.c_str());
return;
}
user->Oper(opit->second);
}
Version GetVersion()
{
return Version("Adds a opertype option to connect blocks so operators can get autologged in via IP");
}
};
MODULE_INIT(ModuleAutoOper)