X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_helpop.cpp;h=bae4e73aefd1085cf1bea1e66bd7821419949c91;hb=eb4229deed0281ae566ef7e55a144e5d3183a4b2;hp=d6ebb6f92ad30dcc875db9155f6a529282fa74b1;hpb=e8b5c0d9f9103f84384fe9b0d89301ecbf16c3e6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index d6ebb6f92..bae4e73ae 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -1,6 +1,23 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. + * E-mail: + * + * + * + * Written by Craig Edwards, Craig McLure, and others. + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + #include "users.h" #include "channels.h" #include "modules.h" +#include "helperfuncs.h" // Global Vars ConfigReader *helpop; @@ -23,12 +40,6 @@ void handle_helpop(char **parameters, int pcnt, userrec *user) return; } - // FIX by brain: make the string lowercase, ConfigReader is - // case sensitive - char* lower = parameters[0]; - for (int t = 0; t < strlen(lower); t++) - lower[t] = tolower(lower[t]); - if (parameters[0][0] == '!') { // Force send to all +h users @@ -46,9 +57,6 @@ void handle_helpop(char **parameters, int pcnt, userrec *user) } } } - } else if (strchr(user->modes,'o')) { - // Its an oper whos not using ?, send to all +h - sendtohelpop(user, pcnt, parameters); } else { // Check with the helpop database, if not found send to +h if (do_helpop(parameters, pcnt, user) == false) { @@ -84,11 +92,19 @@ bool do_helpop(char **parameters, int pcnt, userrec *src) search++; } + // FIX by brain: make the string lowercase, ConfigReader is + // case sensitive + char lower[MAXBUF]; + strlcpy(lower,search,MAXBUF); + for (int t = 0; t < strlen(lower); t++) + lower[t] = tolower(lower[t]); + + int nlines = 0; for (int i = 1; output != ""; i++) { snprintf(a,MAXBUF,"line%d",i); - output = helpop->ReadValue(search, a, 0); + output = helpop->ReadValue(lower, a, 0); if (output != "") { Srv->SendTo(NULL,src,"290 "+std::string(src->nick)+" :"+output); nlines++; @@ -126,34 +142,28 @@ class ModuleHelpop : public Module h_file = conf->ReadValue("helpop", "file", 0); if (h_file == "") { - printf("m_helpop: Helpop file not Specified."); - exit(0); + log(DEFAULT,"m_helpop: Helpop file not Specified."); + return; } helpop = new ConfigReader(h_file); - if (!helpop->Verify()) - { - printf("m_helpop: Invalid Helpop File. Please Ensure it exists and is error free."); - exit(0); - } - /*if ((helpop->ReadValue("nohelp", "line1", 0) == "") || + if ((helpop->ReadValue("nohelp", "line1", 0) == "") || (helpop->ReadValue("nohelpo", "line1", 0) == "") || (helpop->ReadValue("start", "line1", 0) == "")) { - printf("m_helpop: Helpop file is missing important entries. Please check the example conf."); - exit(0); - }*/ + log(DEFAULT,"m_helpop: Helpop file is missing important entries. Please check the example conf."); + return; + } if (!Srv->AddExtendedMode('h',MT_CLIENT,true,0,0)) { Srv->Log(DEFAULT,"Unable to claim the +h usermode."); - printf("m_helpop: Unable to claim the +h usermode!"); - exit(0); + return; } // Loads of comments, untill supported properly. - Srv->AddCommand("HELPOP",handle_helpop,0,0); + Srv->AddCommand("HELPOP",handle_helpop,0,0,"m_helpop.so"); } @@ -191,7 +201,7 @@ class ModuleHelpop : public Module virtual Version GetVersion() { - return Version(0,0,0,1); + return Version(1,0,0,1,VF_STATIC|VF_VENDOR); } };