1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 class FilterResult : public classbase
23 FilterResult(const std::string &rea, const std::string &act) : reason(rea), action(act)
31 virtual ~FilterResult()
36 class FilterBase : public Module
39 FilterBase(InspIRCd* Me)
48 virtual void Implements(char* List)
50 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1;
53 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
55 return OnUserPreNotice(user,dest,target_type,text,status);
58 /* This must be implemented by the module which uses the header */
59 virtual FilterResult* FilterMatch(const std::string &text) = 0;
61 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
63 FilterResult* f = this->FilterMatch(text);
66 std::string target = "";
67 if (target_type == TYPE_USER)
69 userrec* t = (userrec*)dest;
70 target = std::string(t->nick);
72 else if (target_type == TYPE_CHANNEL)
74 chanrec* t = (chanrec*)dest;
75 target = std::string(t->name);
77 if (f->action == "block")
79 ServerInstance->WriteOpers(std::string("FILTER: ")+user->nick+" had their notice filtered, target was "+target+": "+f->reason);
80 user->WriteServ("NOTICE "+std::string(user->nick)+" :Your notice has been filtered and opers notified: "+f->reason);
82 ServerInstance->Log(DEFAULT,"FILTER: "+std::string(user->nick)+std::string(" had their notice filtered, target was ")+target+": "+f->reason+" Action: "+f->action);
84 if (f->action == "kill")
86 userrec::QuitUser(ServerInstance,user,f->reason);
93 virtual void OnRehash(const std::string ¶meter)
97 virtual Version GetVersion()
99 // This is version 2 because version 1.x is the unreleased unrealircd module
100 return Version(1,1,0,2,VF_VENDOR,API_VERSION);