public:
ModuleCensor() : cu(this), cc(this) { }
- void init()
+ void init() CXX11_OVERRIDE
{
/* Read the configuration file on startup.
*/
OnRehash(NULL);
ServerInstance->Modules->AddService(cu);
ServerInstance->Modules->AddService(cc);
- Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice };
- ServerInstance->Modules->Attach(eventlist, this, 3);
- }
-
-
- virtual ~ModuleCensor()
- {
+ Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage };
+ ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
// format of a config entry is <badword text="shit" replace="poo">
- virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+ ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
bool active = false;
if (target_type == TYPE_USER)
- active = ((User*)dest)->IsModeSet('G');
+ active = ((User*)dest)->IsModeSet(cu);
else if (target_type == TYPE_CHANNEL)
{
- active = ((Channel*)dest)->IsModeSet('G');
Channel* c = (Channel*)dest;
+ active = c->IsModeSet(cc);
ModResult res = ServerInstance->OnCheckExemption(user,c,"censor");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
}
- virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
- {
- return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
- }
-
- virtual void OnRehash(User* user)
+ void OnRehash(User* user) CXX11_OVERRIDE
{
/*
* reload our config file on rehash - we must destroy and re-allocate the classes
* to call the constructor again and re-read our data.
*/
- ConfigReader MyConf;
censors.clear();
- for (int index = 0; index < MyConf.Enumerate("badword"); index++)
+ ConfigTagList badwords = ServerInstance->Config->ConfTags("badword");
+ for (ConfigIter i = badwords.first; i != badwords.second; ++i)
{
- std::string str = MyConf.ReadValue("badword","text",index);
+ ConfigTag* tag = i->second;
+ std::string str = tag->getString("text");
irc::string pattern(str.c_str());
- str = MyConf.ReadValue("badword","replace",index);
+ str = tag->getString("replace");
censors[pattern] = irc::string(str.c_str());
}
}
- virtual Version GetVersion()
+ Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides user and channel +G mode",VF_VENDOR);
}