-
- censor_t censors;
- CensorUser *cu;
- CensorChannel *cc;
-
- public:
- ModuleCensor(InspIRCd* Me)
- : Module::Module(Me)
- {
- /*
- * read the configuration file on startup.
- * it is perfectly valid to set <censor file> to the value of the
- * main config file, then append your <badword> tags to the bottom
- * of the main config... but rather messy. That's why the capability
- * of using a seperate config file is provided.
- *
- * XXX - Really, it'd be nice to scraip this kind of thing, and have something like
- * an include directive to include additional configuration files. Might make our lives easier. --w00t
- *
- * XXX - These module pre-date the include directive which exists since beta 5 -- Brain
- */
-
- OnRehash("");
- cu = new CensorUser(ServerInstance);
- cc = new CensorChannel(ServerInstance);
- ServerInstance->AddMode(cu, 'G');
- ServerInstance->AddMode(cc, 'G');
- }
-
- void Implements(char* List)
- {
- List[I_OnRehash] = List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
- }
-
-
- virtual void On005Numeric(std::string &output)
- {
- ServerInstance->Modes->InsertMode(output,"G",4);
- }
-
- virtual ~ModuleCensor()
- {
- DELETE(cu);
- DELETE(cc);
- }
-
- virtual void ReplaceLine(irc::string &text, irc::string pattern, irc::string replace)
- {
- if ((pattern != "") && (text != ""))
- {
- while (text.find(pattern) != irc::string::npos)
- {
- int pos = text.find(pattern);
- text.erase(pos,pattern.length());
- text.insert(pos,replace);
- }