- ModuleCensor(InspIRCd* Me)
- : Module(Me)
- {
- /* Read the configuration file on startup.
- */
- OnRehash(NULL,"");
- cu = new CensorUser(ServerInstance);
- cc = new CensorChannel(ServerInstance);
- if (!ServerInstance->Modes->AddMode(cu) || !ServerInstance->Modes->AddMode(cc))
- {
- delete cu;
- delete cc;
- throw ModuleException("Could not add new modes!");
- }
- Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice };
- ServerInstance->Modules->Attach(eventlist, this, 3);
- }
-
-
- virtual ~ModuleCensor()
- {
- ServerInstance->Modes->DelMode(cu);
- ServerInstance->Modes->DelMode(cc);
- delete cu;
- delete cc;
- }
-
- virtual void ReplaceLine(irc::string &text, irc::string pattern, irc::string replace)
- {
- if ((!pattern.empty()) && (!text.empty()))
- {
- std::string::size_type pos;
- while ((pos = text.find(pattern)) != irc::string::npos)
- {
- text.erase(pos,pattern.length());
- text.insert(pos,replace);
- }
- }
- }