summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-10 14:11:17 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-10 14:11:17 +0000
commit6ea84e21f87606058bc88a6083932f4876ef07e1 (patch)
tree1a8ae25efb9ead40eedaa4412314fc16ce1a8353 /src
parentab9d28a14772e60109aa0bd834d7dcbbe7b9302d (diff)
Finally make this module work at all on 1.1
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6558 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_antibottler.cpp77
1 files changed, 41 insertions, 36 deletions
diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp
index 0e80809d7..27225edac 100644
--- a/src/modules/m_antibottler.cpp
+++ b/src/modules/m_antibottler.cpp
@@ -14,6 +14,7 @@
#include "users.h"
#include "channels.h"
#include "modules.h"
+#include "inspircd.h"
/* $ModDesc: Changes the ident of connecting bottler clients to 'bottler' */
@@ -28,7 +29,7 @@ class ModuleAntiBottler : public Module
void Implements(char* List)
{
- List[I_OnServerRaw] = 1;
+ List[I_OnPreCommand] = 1;
}
@@ -41,54 +42,58 @@ class ModuleAntiBottler : public Module
return Version(1,1,0,1,VF_VENDOR,API_VERSION);
}
- virtual void OnServerRaw(std::string &raw, bool inbound, userrec* user)
+ virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
{
- if (inbound)
+ char data[MAXBUF];
+ strlcpy(data,original_line.c_str(),MAXBUF);
+ bool not_bottler = false;
+ if (!strncmp(data,"user ",5))
{
- char data[MAXBUF];
- strlcpy(data,raw.c_str(),MAXBUF);
- bool not_bottler = false;
- if (!strncmp(data,"user ",5))
+ for (char* j = data; *j; j++)
{
- for (char* j = data; *j; j++)
+ if (*j == ':')
+ break;
+
+ if (*j == '"')
{
- if (*j == ':')
- break;
-
- if (*j == '"')
- {
- not_bottler = true;
- }
+ not_bottler = true;
}
- // Bug Fix (#14) -- FCS
-
- if (!(data) || !(*data))
- return;
+ }
+ // Bug Fix (#14) -- FCS
+ if (!(data) || !(*data))
+ return 0;
- strtok(data," ");
- char *ident = strtok(NULL," ");
- char *local = strtok(NULL," ");
- char *remote = strtok(NULL," :");
- char *gecos = strtok(NULL,"\r\n");
+ strtok(data," ");
+ char *ident = strtok(NULL," ");
+ char *local = strtok(NULL," ");
+ char *remote = strtok(NULL," :");
+ char *gecos = strtok(NULL,"\r\n");
- if (!ident || !local || !remote || !gecos)
- return;
+ if (!ident || !local || !remote || !gecos)
+ return 0;
- for (char* j = remote; *j; j++)
+ for (char* j = remote; *j; j++)
+ {
+ if (((*j < '0') || (*j > '9')) && (*j != '.'))
{
- if (((*j < '0') || (*j > '9')) && (*j != '.'))
- {
- not_bottler = true;
- }
+ not_bottler = true;
}
+ }
- if (!not_bottler)
- {
- raw = "USER bottler "+std::string(local)+" "+std::string(remote)+" "+std::string(gecos)+" [Possible bottler, ident: "+std::string(ident)+"]";
- }
+ if (!not_bottler)
+ {
+ std::string strgecos = std::string(gecos) + "[Possible bottler, ident: " + std::string(ident) + "]";
+ const char* modified[3];
+ modified[0] = "bottler";
+ modified[1] = local;
+ modified[2] = remote;
+ modified[3] = strgecos.c_str();
+ ServerInstance->Parser->CallHandler("USER", modified, 4, user);
+ return 1;
}
}
- }
+ return 0;
+ }
};