|
|||
|
|||
|


Public Member Functions | |
| ModuleFilter (InspIRCd *Me) | |
| virtual | ~ModuleFilter () |
| virtual FilterResult * | FilterMatch (userrec *user, const std::string &text, int flags) |
| virtual bool | DeleteFilter (const std::string &freeform) |
| virtual std::pair< bool, std::string > | AddFilter (const std::string &freeform, const std::string &type, const std::string &reason, long duration, const std::string &flags) |
| virtual void | SyncFilters (Module *proto, void *opaque) |
| virtual void | OnRehash (userrec *user, const std::string ¶meter) |
| Called on rehash. | |
| virtual int | OnStats (char symbol, userrec *user, string_list &results) |
| Called on all /STATS commands This method is triggered for all /STATS use, including stats symbols handled by the core. | |
Private Attributes | |
| filter_t | filters |
Definition at line 25 of file m_filter.cpp.
|
|
Definition at line 31 of file m_filter.cpp. References OnRehash(). 00032 : FilterBase(Me, "m_filter.so") 00033 { 00034 OnRehash(NULL,""); 00035 }
|
|
|
Definition at line 37 of file m_filter.cpp.
|
|
||||||||||||||||||||||||
|
Implements FilterBase. Definition at line 76 of file m_filter.cpp. References filters. 00077 { 00078 if (filters.find(freeform) != filters.end()) 00079 { 00080 return std::make_pair(false, "Filter already exists"); 00081 } 00082 00083 FilterResult* x = new FilterResult(freeform, reason, type, duration, flags); 00084 filters[freeform] = x; 00085 00086 return std::make_pair(true, ""); 00087 }
|
|
|
Implements FilterBase. Definition at line 65 of file m_filter.cpp. References filters. Referenced by OnRehash(). 00066 { 00067 if (filters.find(freeform) != filters.end()) 00068 { 00069 delete (filters.find(freeform))->second; 00070 filters.erase(filters.find(freeform)); 00071 return true; 00072 } 00073 return false; 00074 }
|
|
||||||||||||||||
|
Implements FilterBase. Definition at line 41 of file m_filter.cpp. References FilterBase::AppliesToMe(), filters, InspIRCd::MatchText(), and Module::ServerInstance. 00042 { 00043 for (filter_t::iterator index = filters.begin(); index != filters.end(); index++) 00044 { 00045 00046 /* Skip ones that dont apply to us */ 00047 if (!FilterBase::AppliesToMe(user, index->second, flags)) 00048 continue; 00049 00050 if (ServerInstance->MatchText(text,index->first)) 00051 { 00052 FilterResult* fr = index->second; 00053 if (index != filters.begin()) 00054 { 00055 std::string pat = index->first; 00056 filters.erase(index); 00057 filters.insert(filters.begin(), std::make_pair(pat,fr)); 00058 } 00059 return fr; 00060 } 00061 } 00062 return NULL; 00063 }
|
|
||||||||||||
|
Called on rehash. This method is called prior to a /REHASH or when a SIGHUP is received from the operating system. You should use it to reload any files so that your module keeps in step with the rest of the application. If a parameter is given, the core has done nothing. The module receiving the event can decide if this parameter has any relevence to it.
Reimplemented from FilterBase. Definition at line 97 of file m_filter.cpp. References DELETE(), DeleteFilter(), InspIRCd::Duration(), filters, FilterBase::flags, ConfigReader::ReadValue(), and Module::ServerInstance. Referenced by ModuleFilter(). 00098 { 00099 ConfigReader* MyConf = new ConfigReader(ServerInstance); 00100 00101 for (int index = 0; index < MyConf->Enumerate("keyword"); index++) 00102 { 00103 this->DeleteFilter(MyConf->ReadValue("keyword","pattern",index)); 00104 00105 std::string pattern = MyConf->ReadValue("keyword","pattern",index); 00106 std::string reason = MyConf->ReadValue("keyword","reason",index); 00107 std::string do_action = MyConf->ReadValue("keyword","action",index); 00108 std::string flags = MyConf->ReadValue("keyword","flags",index); 00109 long gline_time = ServerInstance->Duration(MyConf->ReadValue("keyword","duration",index)); 00110 if (do_action.empty()) 00111 do_action = "none"; 00112 if (flags.empty()) 00113 flags = "*"; 00114 FilterResult* x = new FilterResult(pattern, reason, do_action, gline_time, flags); 00115 filters[pattern] = x; 00116 } 00117 DELETE(MyConf); 00118 }
|
|
||||||||||||||||
|
Called on all /STATS commands This method is triggered for all /STATS use, including stats symbols handled by the core.
Implements FilterBase. Definition at line 120 of file m_filter.cpp. References InspIRCd::Config, ConvToStr(), filters, userrec::nick, Module::ServerInstance, and ServerConfig::ServerName. 00121 { 00122 if (symbol == 's') 00123 { 00124 std::string sn = ServerInstance->Config->ServerName; 00125 for (filter_t::iterator n = filters.begin(); n != filters.end(); n++) 00126 { 00127 results.push_back(sn+" 223 "+user->nick+" :GLOB:"+n->second->freeform+" "+n->second->flags+" "+n->second->action+" "+ConvToStr(n->second->gline_time)+" :"+n->second->reason); 00128 } 00129 } 00130 return 0; 00131 }
|
|
||||||||||||
|
Implements FilterBase. Definition at line 89 of file m_filter.cpp. References filters, and FilterBase::SendFilter(). 00090 { 00091 for (filter_t::iterator n = filters.begin(); n != filters.end(); n++) 00092 { 00093 this->SendFilter(proto, opaque, n->second); 00094 } 00095 }
|
|
|
Definition at line 28 of file m_filter.cpp. Referenced by AddFilter(), DeleteFilter(), FilterMatch(), OnRehash(), OnStats(), and SyncFilters(). |