9 void handle_helpop(char**, int, userrec*);
10 bool do_helpop(char**, int, userrec*);
11 void sendtohelpop(userrec*, int, char**);
14 /* $ModDesc: /helpop Command, Works like Unreal helpop */
16 void handle_helpop(char **parameters, int pcnt, userrec *user)
19 std::string output = " ";
21 if (parameters[0] == "") { do_helpop(NULL,pcnt,user); }
23 if (parameters[0][0] == '!')
25 // Force send to all +h users
26 sendtohelpop(user, pcnt, parameters);
27 } else if (parameters[0][0] == '?') {
28 // Force to the helpop system with no forward if not found.
29 if (do_helpop(parameters, pcnt, user) == false) {
30 // Not handled by the Database, Tell the user, and forward.
31 for (int i = 1; output != ""; i++)
33 snprintf(a,MAXBUF,"line%d",i);
34 output = helpop->ReadValue("nohelp", std::string(a), 0);
35 // Send line to client..
36 Srv->SendTo(NULL,user,"290 "+std::string(user->nick)+" :"+output);
39 } else if (strchr(user->modes,'o')) {
40 // Its an oper whos not using ?, send to all +h
41 sendtohelpop(user, pcnt, parameters);
43 // Check with the helpop database, if not found send to +h
44 if (do_helpop(parameters, pcnt, user) == false) {
45 // Not handled by the Database, Tell the user, and forward.
46 for (int i = 1; output != ""; i++)
48 snprintf(a,MAXBUF,"line%d",i);
49 output = helpop->ReadValue("nohelpo", std::string(a), 0);
50 // Send line to client..
51 Srv->SendTo(NULL,user,"290 "+std::string(user->nick)+" :"+output);
54 sendtohelpop(user, pcnt, parameters);
59 bool do_helpop(char **parameters, int pcnt, userrec *src)
62 std::string output = " "; // a fix bought to you by brain :p
65 if (!parameters) { strcpy(search, "start"); }
66 else { search = parameters[0]; }
68 if (search[0] == '?') { search++; }
70 // Make sure it exists.
71 if (helpop->ReadValue(std::string(search), "line1", 0) == "")
77 // Somethings there.. tell the person who wants to know :p
79 for (int i = 1; output != ""; i++)
81 snprintf(a,MAXBUF,"line%d",i);
82 output = helpop->ReadValue(std::string(search), std::string(a), 0);
83 // Send line to client..
84 Srv->SendTo(NULL,src,"290 "+std::string(src->nick)+" :"+output);
91 void sendtohelpop(userrec *src, int pcnt, char **params)
93 char* first = params[0];
94 if (first[0] == '!') { first++; }
95 std::string line = "*** HELPOPS - From "+std::string(src->nick)+": "+std::string(first)+" ";
96 for (int i = 1; i < pcnt; i++)
98 line = line + std::string(params[i]) + " ";
100 Srv->SendToModeMask("oh",WM_AND,line);
103 class ModuleHelpop : public Module
113 conf = new ConfigReader;
115 h_file = conf->ReadValue("helpop", "file", 0);
118 printf("WE ARE AAAAALL GONNA DIEEEEEEEEEEEE!!");
122 helpop = new ConfigReader(h_file);
123 if (!helpop->Verify())
125 printf("Thats it.. were all dead.");
129 if ((helpop->ReadValue("nohelp", "line1", 0) == "") ||
130 (helpop->ReadValue("nohelpo", "line1", 0) == "") ||
131 (helpop->ReadValue("start", "line1", 0) == ""))
133 printf("m_helpop: Important Shit Missing. Please check your file.");
137 if (!Srv->AddExtendedMode('h',MT_CLIENT,true,0,0))
139 Srv->Log(DEFAULT,"pr0n Found. Send it to Craig@chatspike.net for investigation.");
140 printf("Could not claim usermode +h for this module!");
144 /*if (!*/Srv->AddCommand("HELPOP",handle_helpop,0,1);/*)
146 Srv->Log(DEFAULT,"Someone br0ked it.. not me");
147 printf("B0RKED! JUMP SHIP.. AAAAAAAAAAAAAAAAAHHHHHH!");
153 virtual bool OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
155 if ((modechar == 'h') && (type == MT_CLIENT))
162 virtual void OnWhois(userrec* src, userrec* dst) {
163 if (strchr(src->modes,'h'))
165 Srv->SendTo(NULL,src,"310 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is available for help.");
169 virtual void OnOper(userrec* user)
171 char* modes[2]; // only two parameters
172 modes[0] = user->nick; // first parameter is the nick
173 modes[1] = "+h"; // second parameter is the mode
174 Srv->SendMode(modes,2,user); // send these, forming the command "MODE <nick> +h"
177 virtual ~ModuleHelpop()
184 virtual Version GetVersion()
186 return Version(0,0,0,1);
190 class ModuleHelpopFactory : public ModuleFactory
193 ModuleHelpopFactory()
197 ~ModuleHelpopFactory()
201 virtual Module * CreateModule()
203 return new ModuleHelpop;
208 extern "C" void * init_module( void )
210 return new ModuleHelpopFactory;