]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_operlog.cpp
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / src / modules / m_operlog.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 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
16 /* $ModDesc: A module which logs all oper commands to the ircd log at default loglevel. */
17
18 class ModuleOperLog : public Module
19 {
20  private:
21
22  public:
23         ModuleOperLog()         {
24
25                 Implementation eventlist[] = { I_OnPreCommand, I_On005Numeric };
26                 ServerInstance->Modules->Attach(eventlist, this, 2);
27         }
28
29         virtual ~ModuleOperLog()
30         {
31         }
32
33         virtual Version GetVersion()
34         {
35                 return Version("A module which logs all oper commands to the ircd log at default loglevel.", VF_VENDOR, API_VERSION);
36         }
37
38
39         virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
40         {
41                 /* If the command doesnt appear to be valid, we dont want to mess with it. */
42                 if (!validated)
43                         return MOD_RES_PASSTHRU;
44
45                 if ((IS_OPER(user)) && (IS_LOCAL(user)) && (user->HasPermission(command)))
46                 {
47                         Command* thiscommand = ServerInstance->Parser->GetHandler(command);
48                         if ((thiscommand) && (thiscommand->flags_needed == 'o'))
49                                 ServerInstance->Logs->Log("m_operlog",DEFAULT,"OPERLOG: [%s!%s@%s] %s %s",user->nick.c_str(), user->ident.c_str(), user->host.c_str(), command.c_str(), parameters.empty() ? "" : irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined().c_str());
50                 }
51
52                 return MOD_RES_PASSTHRU;
53         }
54
55         virtual void On005Numeric(std::string &output)
56         {
57                 output.append(" OPERLOG");
58         }
59
60 };
61
62
63 MODULE_INIT(ModuleOperLog)