public:
- ModuleChanFilter()
+ ModuleChanFilter(Server* Me)
+ : Module::Module(Me)
{
- Srv = new Server;
+ Srv = Me;
Conf = new ConfigReader;
Srv->AddExtendedListMode('g');
MaxEntries = Conf->ReadInteger("chanfilter","maxsize",0,true);
+ if (MaxEntries == 0)
+ MaxEntries = 32;
}
virtual void On005Numeric(std::string &output)
}
}
- virtual void OnRehash()
+ virtual void OnRehash(std::string parameter)
{
delete Conf;
Conf = new ConfigReader;
{
char buffer[MAXBUF];
strlcpy(buffer,text.c_str(),MAXBUF);
- for (int j = 0; j < strlen(buffer); j++)
+ for (unsigned int j = 0; j < strlen(buffer); j++)
buffer[j] = tolower(buffer[j]);
SpamList* spamlist = (SpamList*)chan->GetExt("spam_list");
if (spamlist)
{
for (SpamList::iterator i = spamlist->begin(); i != spamlist->end(); i++)
{
- if (strstr(text.c_str(),i->c_str()))
+ if (strstr(buffer,i->c_str()))
{
WriteServ(user->fd,"936 %s %s :Your message contained a censored word, and was blocked",user->nick, chan->name);
return 1;
{
chanrec* chan = (chanrec*)target;
- for (int j = 0; j < params[0].length(); j++)
+ for (unsigned int j = 0; j < params[0].length(); j++)
params[0][j] = tolower(params[0][j]);
std::string param = params[0];
spamlist = new SpamList;
chan->Extend("spam_list",(char*)spamlist);
}
- if (spamlist->size() < MaxEntries)
+ if (spamlist->size() < (unsigned)MaxEntries)
{
for (SpamList::iterator i = spamlist->begin(); i != spamlist->end(); i++)
{
virtual ~ModuleChanFilter()
{
delete Conf;
- delete Srv;
}
virtual Version GetVersion()
return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
}
- virtual string_list OnChannelSync(chanrec* chan)
+ virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
{
SpamList* spamlist = (SpamList*)chan->GetExt("spam_list");
string_list commands;
{
for (SpamList::iterator i = spamlist->begin(); i != spamlist->end(); i++)
{
- commands.push_back("M "+std::string(chan->name)+" +g "+*i);
+ proto->ProtoSendMode(opaque,TYPE_CHANNEL,chan,"+g "+*i);
}
}
- return commands;
}
};
{
}
- virtual Module * CreateModule()
+ virtual Module * CreateModule(Server* Me)
{
- return new ModuleChanFilter;
+ return new ModuleChanFilter(Me);
}
};