+ if (filters.find(freeform) != filters.end())
+ {
+ return std::make_pair(false, "Filter already exists");
+ }
+
+ FilterResult* x = new FilterResult;
+ x->reason = reason;
+ x->action = type;
+ x->gline_time = duration;
+ x->freeform = freeform;
+ filters[freeform] = x;
+
+ return std::make_pair(true, "");
+ }
+
+ virtual void SyncFilters(Module* proto, void* opaque)
+ {
+ for (filter_t::iterator n = filters.begin(); n != filters.end(); n++)
+ {
+ this->SendFilter(proto, opaque, n->second);
+ }
+ }
+
+ virtual void OnRehash(userrec* user, const std::string ¶meter)
+ {
+ ConfigReader* MyConf = new ConfigReader(ServerInstance);
+
+ for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
+ {
+ this->DeleteFilter(MyConf->ReadValue("keyword","pattern",index));
+
+ std::string pattern = MyConf->ReadValue("keyword","pattern",index);
+ std::string reason = MyConf->ReadValue("keyword","reason",index);
+ std::string do_action = MyConf->ReadValue("keyword","action",index);
+ long gline_time = ServerInstance->Duration(MyConf->ReadValue("keyword","duration",index).c_str());
+ if (do_action == "")
+ do_action = "none";
+ FilterResult* x = new FilterResult;
+ x->reason = reason;
+ x->action = do_action;
+ x->gline_time = gline_time;
+ x->freeform = pattern;
+ filters[pattern] = x;
+ }
+ DELETE(MyConf);
+ }
+
+ virtual int OnStats(char symbol, userrec* user, string_list &results)
+ {
+ if (symbol == 's')
+ {
+ std::string sn = ServerInstance->Config->ServerName;
+ for (filter_t::iterator n = filters.begin(); n != filters.end(); n++)
+ {
+ results.push_back(sn+" 223 "+user->nick+" :GLOB:"+n->second->freeform+" "+n->second->action+" "+ConvToStr(n->second->gline_time)+" :"+n->second->reason);
+ }
+ }
+ return 0;