]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_operlog.cpp
Update $ModDep lines so that these properly depend on their headers in the makefile
[user/henk/code/inspircd.git] / src / modules / m_operlog.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                     E-mail:
7  *              <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *          the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18  
19 #include "users.h"
20 #include "channels.h"
21 #include "modules.h"
22 #include "inspircd.h"
23 #include <vector>
24
25 /* $ModDesc: A module which logs all oper commands to the ircd log at default loglevel. */
26
27 class ModuleOperLog : public Module
28 {
29  private:
30          
31  public:
32         ModuleOperLog(InspIRCd* Me) : Module::Module(Me)
33         {
34                 
35         }
36  
37         virtual ~ModuleOperLog()
38         {
39         }
40  
41         virtual Version GetVersion()
42         {
43                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
44         }
45  
46         void Implements(char* List)
47         {
48                 List[I_OnPreCommand] = List[I_On005Numeric] = 1;
49         }
50
51         virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
52         {
53                 /* If the command doesnt appear to be valid, we dont want to mess with it. */
54                 if (!validated)
55                         return 0;
56  
57                 if ((*user->oper) && (IS_LOCAL(user)) && (user->HasPermission(command)))
58                 {
59                         std::string plist = "";
60                         for (int j = 0; j < pcnt; j++)
61                         {
62                                 plist.append(std::string(" ")+std::string(parameters[j]));
63                         }
64                         ServerInstance->Log(DEFAULT,"OPERLOG: [%s!%s@%s] %s%s",user->nick,user->ident,user->host,command.c_str(),plist.c_str());
65                 }
66
67                 return 0;
68         }
69
70         virtual void On005Numeric(std::string &output)
71         {
72                 output.append(" OPERLOG");
73         }
74
75 };
76  
77  
78  
79 /******************************************************************************************************/
80  
81 class ModuleOperLogFactory : public ModuleFactory
82 {
83  public:
84         ModuleOperLogFactory()
85         {
86         }
87  
88         ~ModuleOperLogFactory()
89         {
90         }
91  
92         virtual Module * CreateModule(InspIRCd* Me)
93         {
94                 return new ModuleOperLog(Me);
95         }
96  
97 };
98  
99 extern "C" void * init_module( void )
100 {
101         return new ModuleOperLogFactory;
102 }
103