]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_opermotd.cpp
Added proper administrativia notices to CONNECT and inbound connections
[user/henk/code/inspircd.git] / src / modules / m_opermotd.cpp
1 // opermotd module by typobox43
2
3 using namespace std;
4
5 #include <stdio.h>
6 #include "users.h"
7 #include "channels.h"
8 #include "modules.h"
9 #include "helperfuncs.h"
10
11 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
12
13 FileReader* opermotd;
14 Server* Srv;
15
16 void do_opermotd(char** parameters, int pcnt, userrec* user);
17
18 void LoadOperMOTD() {
19
20         ConfigReader* conf = new ConfigReader;
21         std::string filename;
22
23         filename = conf->ReadValue("opermotd","file",0);
24
25         opermotd->LoadFile(filename);
26         
27 }
28
29 void ShowOperMOTD(userrec* user) {
30
31         if(!opermotd->FileSize()) {
32
33                 Srv->SendServ(user->fd,std::string("425 ") + user->nick + std::string(" :OPERMOTD file is missing"));
34                 return;
35
36         }
37
38         Srv->SendServ(user->fd,std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
39
40         for(int i=0; i != opermotd->FileSize(); i++) {
41
42                 Srv->SendServ(user->fd,std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
43
44         }
45
46         Srv->SendServ(user->fd,std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
47
48 }
49
50 void do_opermotd(char** parameters, int pcnt, userrec* user) {
51
52         ShowOperMOTD(user);
53
54 }
55
56 class ModuleOpermotd : public Module {
57
58         public:
59
60                 ModuleOpermotd() {
61
62                         Srv = new Server;
63                         
64                         Srv->AddCommand("OPERMOTD",do_opermotd,'o',0,"m_opermotd.so");
65
66                         opermotd = new FileReader();
67                         LoadOperMOTD();
68
69                 }
70
71                 virtual ~ModuleOpermotd() {
72
73                         delete Srv;
74
75                 }
76
77                 virtual Version GetVersion() {
78
79                         return Version(1,0,0,1,VF_VENDOR);
80
81                 }
82
83                 virtual void OnOper(userrec* user) {
84
85                         ShowOperMOTD(user);
86
87                 }
88
89                 virtual void OnRehash() {
90
91                         LoadOperMOTD();
92
93                 }
94
95 };
96
97 class ModuleOpermotdFactory : public ModuleFactory {
98
99         public:
100
101                 ModuleOpermotdFactory() {
102
103                 }
104
105                 ~ModuleOpermotdFactory() {
106
107                 }
108
109                 virtual Module* CreateModule() {
110
111                         return new ModuleOpermotd;
112
113                 }
114
115 };
116
117 extern "C" void* init_module(void) {
118
119         return new ModuleOpermotdFactory;
120
121 }