summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-09 14:44:51 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-09 14:44:51 +0000
commit7b4b3f5d11fbfa272f58021df0094586c0fa4b09 (patch)
treedc8280cd4ca0f9ca8888cf353f768c101f6f86a8 /src
parent5bfd172ec5225e9af1ebb273158993dd589b1cc0 (diff)
Fixed for new api
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4221 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_joinflood.cpp126
1 files changed, 64 insertions, 62 deletions
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp
index ae31ab67c..6cc54db68 100644
--- a/src/modules/m_joinflood.cpp
+++ b/src/modules/m_joinflood.cpp
@@ -92,88 +92,89 @@ class joinfloodsettings
unlocktime = time(NULL) + 60;
}
-
};
-class ModuleJoinFlood : public Module
+class JoinFlood : public ModeHandler
{
- Server *Srv;
-
public:
-
- ModuleJoinFlood(Server* Me)
- : Module::Module(Me)
- {
- Srv = Me;
- Srv->AddExtendedMode('j',MT_CHANNEL,false,1,0);
- }
-
- virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
+ JoinFlood() : ModeHandler('j', 1, 0, false, MODETYPE_CHANNEL, false) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
- if ((modechar == 'j') && (type == MT_CHANNEL))
+ if (adding)
{
- if (mode_on)
+ char ndata[MAXBUF];
+ char* data = ndata;
+ strlcpy(ndata,parameter.c_str(),MAXBUF);
+ char* joins = data;
+ char* secs = NULL;
+ while (*data)
{
- std::string FloodParams = params[0];
- chanrec* c = (chanrec*)target;
- char ndata[MAXBUF];
- char* data = ndata;
- strlcpy(ndata,FloodParams.c_str(),MAXBUF);
- char* joins = data;
- char* secs = NULL;
- while (*data)
+ if (*data == ':')
{
- if (*data == ':')
- {
- *data = 0;
- data++;
- secs = data;
- break;
- }
- else data++;
+ *data = 0;
+ data++;
+ secs = data;
+ break;
}
- if (secs)
+ else data++;
+ }
+ if (secs)
+ {
+ /* Set up the flood parameters for this channel */
+ int njoins = atoi(joins);
+ int nsecs = atoi(secs);
+ if ((njoins<1) || (nsecs<1))
{
- /* Set up the flood parameters for this channel */
- int njoins = atoi(joins);
- int nsecs = atoi(secs);
- if ((njoins<1) || (nsecs<1))
- {
- WriteServ(user->fd,"608 %s %s :Invalid flood parameter",user->nick,c->name);
- return 0;
- }
- else
- {
- if (!c->GetExt("joinflood"))
- {
- joinfloodsettings *f = new joinfloodsettings(nsecs,njoins);
- c->Extend("joinflood",(char*)f);
- }
- }
- return 1;
+ WriteServ(source->fd,"608 %s %s :Invalid flood parameter",source->nick,channel->name);
+ parameter = "";
+ return MODEACTION_DENY;
}
else
{
- WriteServ(user->fd,"608 %s %s :Invalid flood parameter",user->nick,c->name);
- return 0;
+ if (!channel->GetExt("joinflood"))
+ {
+ joinfloodsettings *f = new joinfloodsettings(nsecs,njoins);
+ channel->Extend("joinflood",(char*)f);
+ return MODEACTION_ALLOW;
+ }
}
-
}
else
{
- chanrec* c = (chanrec*)target;
- if (c->GetExt("joinflood"))
- {
- joinfloodsettings *f = (joinfloodsettings*)c->GetExt("joinflood");
- DELETE(f);
- c->Shrink("joinflood");
- }
+ WriteServ(source->fd,"608 %s %s :Invalid flood parameter",source->nick,channel->name);
+ return MODEACTION_DENY;
}
- return 1;
}
- return 0;
+ else
+ {
+ if (channel->GetExt("joinflood"))
+ {
+ joinfloodsettings *f = (joinfloodsettings*)channel->GetExt("joinflood");
+ DELETE(f);
+ channel->Shrink("joinflood");
+ return MODEACTION_ALLOW;
+ }
+ }
+ return MODEACTION_DENY;
}
+};
+class ModuleJoinFlood : public Module
+{
+ Server *Srv;
+ JoinFlood* jf;
+
+ public:
+
+ ModuleJoinFlood(Server* Me)
+ : Module::Module(Me)
+ {
+ Srv = Me;
+ jf = new JoinFlood();
+ Srv->AddMode(jf, 'j');
+ }
+
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
{
if (chan)
@@ -218,7 +219,7 @@ class ModuleJoinFlood : public Module
void Implements(char* List)
{
- List[I_On005Numeric] = List[I_OnExtendedMode] = List[I_OnChannelDelete] = List[I_OnUserPreJoin] = List[I_OnUserJoin] = 1;
+ List[I_On005Numeric] = List[I_OnChannelDelete] = List[I_OnUserPreJoin] = List[I_OnUserJoin] = 1;
}
virtual void On005Numeric(std::string &output)
@@ -228,6 +229,7 @@ class ModuleJoinFlood : public Module
virtual ~ModuleJoinFlood()
{
+ DELETE(jf);
}
virtual Version GetVersion()