#include "users.h"
#include "channels.h"
#include "modules.h"
+#include "helperfuncs.h"
/* $ModDesc: An enhanced version of the unreal m_filter.so used by chatspike.net */
-
-
class ModuleFilter : public Module
{
Server *Srv;
if ((filterfile == "") || (!MyConf->Verify()))
{
printf("Error, could not find <filter file=\"\"> definition in your config file!");
- exit(0);
+ log(DEFAULT,"Error, could not find <filter file=\"\"> definition in your config file!");
+ return;
}
Srv->Log(DEFAULT,std::string("m_filter: read configuration from ")+filterfile);
}
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
{
- std::string text2 = text + " ";
+ std::string text2 = text+" ";
for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
{
std::string pattern = MyConf->ReadValue("keyword","pattern",index);
- if (Srv->MatchText(text2,pattern))
+ if ((Srv->MatchText(text2,pattern)) || (Srv->MatchText(text,pattern)))
{
std::string target = "";
std::string reason = MyConf->ReadValue("keyword","reason",index);
virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
{
- std::string text2 = text + " ";
+ std::string text2 = text+" ";
for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
{
std::string pattern = MyConf->ReadValue("keyword","pattern",index);
- if (Srv->MatchText(text2,pattern))
+ if ((Srv->MatchText(text2,pattern)) || (Srv->MatchText(text,pattern)))
{
std::string target = "";
std::string reason = MyConf->ReadValue("keyword","reason",index);
{
// bail if the user forgot to create a config file
printf("Error, could not find <filter file=\"\"> definition in your config file!");
- exit(0);
+ log(DEFAULT,"Error, could not find <filter file=\"\"> definition in your config file!");
+ return;
}
Srv->Log(DEFAULT,std::string("m_filter: read configuration from ")+filterfile);
}