#include "helperfuncs.h"
#include "hashcomp.h"
#include "u_listmode.h"
+#include "inspircd.h"
/* $ModDesc: Provides channel-specific censor lists (like mode +G but varies from channel to channel) */
+extern InspIRCd* ServerInstance;
+
class ChanFilter : public ListModeBase
{
public:
- ChanFilter(Server* serv) : ListModeBase(serv, 'g', "End of channel spamfilter list", "941", "940", "chanfilter") { }
+ ChanFilter(InspIRCd* Instance) : ListModeBase(Instance, 'g', "End of channel spamfilter list", "941", "940", false, "chanfilter") { }
virtual bool ValidateParam(userrec* user, chanrec* chan, std::string &word)
{
if (word.length() > 35)
{
- WriteServ(user->fd, "935 %s %s %s :word is too long for censor list",user->nick, chan->name,word.c_str());
+ user->WriteServ( "935 %s %s %s :word is too long for censor list",user->nick, chan->name,word.c_str());
return false;
}
virtual bool TellListTooLong(userrec* user, chanrec* chan, std::string &word)
{
- WriteServ(user->fd,"939 %s %s %s :Channel spamfilter list is full",user->nick, chan->name, word.c_str());
+ user->WriteServ("939 %s %s %s :Channel spamfilter list is full",user->nick, chan->name, word.c_str());
return true;
}
virtual void TellAlreadyOnList(userrec* user, chanrec* chan, std::string &word)
{
- WriteServ(user->fd,"937 %s %s :The word %s is already on the spamfilter list",user->nick, chan->name,word.c_str());
+ user->WriteServ("937 %s %s :The word %s is already on the spamfilter list",user->nick, chan->name,word.c_str());
}
virtual void TellNotSet(userrec* user, chanrec* chan, std::string &word)
{
- WriteServ(user->fd,"938 %s %s :No such spamfilter word is set",user->nick, chan->name);
+ user->WriteServ("938 %s %s :No such spamfilter word is set",user->nick, chan->name);
}
};
public:
- ModuleChanFilter(Server* Me)
- : Module::Module(Me), Srv(Me)
+ ModuleChanFilter(InspIRCd* Me)
+ : Module::Module(Me)
{
- cf = new ChanFilter(Srv);
+ cf = new ChanFilter(ServerInstance);
Srv->AddMode(cf, 'g');
}
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"g",1);
+ ServerInstance->ModeGrok->InsertMode(output,"g",1);
}
virtual void OnChannelDelete(chanrec* chan)
// Create a copy of the string in irc::string
irc::string line = text.c_str();
- modelist* list = (modelist*)chan->GetExt(cf->GetInfoKey());
+ modelist* list;
+ chan->GetExt(cf->GetInfoKey(), list);
if (list)
{
{
if (line.find(i->mask.c_str()) != std::string::npos)
{
- WriteServ(user->fd,"936 %s %s %s :Your message contained a censored word, and was blocked",user->nick, chan->name, i->mask.c_str());
+ user->WriteServ("936 %s %s %s :Your message contained a censored word, and was blocked",user->nick, chan->name, i->mask.c_str());
return 1;
}
}
{
}
- virtual Module * CreateModule(Server* Me)
+ virtual Module * CreateModule(InspIRCd* Me)
{
return new ModuleChanFilter(Me);
}