+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * 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;
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
}
}
}
- } 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) {
std::string output = " "; // a fix bought to you by brain :p
char a[MAXBUF];
- if (!parameters) { strcpy(search, "start"); }
- else { search = parameters[0]; }
+ if (!parameters) {
+ search = "start";
+ }
+ else {
+ search = parameters[0];
+ }
- if (search[0] == '?') { search++; }
+ if (search[0] == '?') {
+ search++;
+ }
- // Make sure it exists.
- if (helpop->ReadValue(std::string(search), "line1", 0) == "")
- {
- // Tell caller..
- return false;
- }
+ // 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]);
- // Somethings there.. tell the person who wants to know :p
+ int nlines = 0;
for (int i = 1; output != ""; i++)
{
snprintf(a,MAXBUF,"line%d",i);
- output = helpop->ReadValue(std::string(search), std::string(a), 0);
+ output = helpop->ReadValue(lower, a, 0);
if (output != "") {
Srv->SendTo(NULL,src,"290 "+std::string(src->nick)+" :"+output);
+ nlines++;
}
}
- return true;
+ return (nlines>0);
}
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) == "") ||
(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 clame the +h usermode.");
- printf("m_helpop: Unable to claim the +h usermode!");
- exit(0);
+ Srv->Log(DEFAULT,"Unable to claim the +h usermode.");
+ return;
}
// Loads of comments, untill supported properly.
- /*if (!*/Srv->AddCommand("HELPOP",handle_helpop,0,0);/*)
- {
- Srv->Log(DEFAULT,"Unable to claim the HELPOP command.");
- printf("m_helpop: Unable to claim the HELPOP command.");
- exit(0);
- }*/
+ Srv->AddCommand("HELPOP",handle_helpop,0,0,"m_helpop.so");
}
- virtual bool OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
+ virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
{
if ((modechar == 'h') && (type == MT_CLIENT))
{
return 0;
}
- virtual void OnWhois(userrec* src, userrec* dst) {
- if (strchr(src->modes,'h'))
+ virtual void OnWhois(userrec* src, userrec* dst)
+ {
+ if (strchr(dst->modes,'h'))
{
Srv->SendTo(NULL,src,"310 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is available for help.");
}
virtual Version GetVersion()
{
- return Version(0,0,0,1);
+ return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
}
};