summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-04 13:09:18 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-04 13:09:18 +0000
commit235a0a2035bda6dd214719107083266207f39883 (patch)
treeffb6b257f722b9b1e3532d3edaf933e0fdf8f372 /src
parent416cc382022d9c41670e7b53390a900ef0ec8c89 (diff)
Added "char status" parameter to OnUserPreNotice and OnUserPreMessage for NOTICE @#chan etc.
Tidied up craq++ in modules (copy and pasting OnUserPreNotice into OnUserPreMessage?! why not just call one from the other!) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3072 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/cmd_notice.cpp4
-rw-r--r--src/cmd_privmsg.cpp4
-rw-r--r--src/modules.cpp4
-rw-r--r--src/modules/extra/m_filter_pcre.cpp48
-rw-r--r--src/modules/m_blockcolor.cpp34
-rw-r--r--src/modules/m_censor.cpp31
-rw-r--r--src/modules/m_chanfilter.cpp10
-rw-r--r--src/modules/m_filter.cpp50
-rw-r--r--src/modules/m_noctcp.cpp21
-rw-r--r--src/modules/m_park.cpp2
-rw-r--r--src/modules/m_restrictmsg.cpp4
-rw-r--r--src/modules/m_services.cpp36
-rw-r--r--src/modules/m_silence.cpp23
-rw-r--r--src/modules/m_stripcolor.cpp21
14 files changed, 36 insertions, 256 deletions
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index cc23a19e1..fe7fea5ca 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -110,7 +110,7 @@ void cmd_notice::Handle (char **parameters, int pcnt, userrec *user)
int MOD_RESULT = 0;
std::string temp = parameters[1];
- FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,chan,TYPE_CHANNEL,temp));
+ FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,chan,TYPE_CHANNEL,temp,status));
if (MOD_RESULT) {
return;
}
@@ -140,7 +140,7 @@ void cmd_notice::Handle (char **parameters, int pcnt, userrec *user)
int MOD_RESULT = 0;
std::string temp = parameters[1];
- FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,dest,TYPE_USER,temp));
+ FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,dest,TYPE_USER,temp,0));
if (MOD_RESULT) {
return;
}
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index 2d14ddf89..883a75d47 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -109,7 +109,7 @@ void cmd_privmsg::Handle (char **parameters, int pcnt, userrec *user)
int MOD_RESULT = 0;
std::string temp = parameters[1];
- FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,chan,TYPE_CHANNEL,temp));
+ FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,chan,TYPE_CHANNEL,temp,status));
if (MOD_RESULT) {
return;
}
@@ -144,7 +144,7 @@ void cmd_privmsg::Handle (char **parameters, int pcnt, userrec *user)
int MOD_RESULT = 0;
std::string temp = parameters[1];
- FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,dest,TYPE_USER,temp));
+ FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,dest,TYPE_USER,temp,0));
if (MOD_RESULT) {
return;
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 22433b8ac..4749bcd3f 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -235,8 +235,8 @@ void Module::OnPostOper(userrec* user, std::string opertype) { };
void Module::OnInfo(userrec* user) { };
void Module::OnWhois(userrec* source, userrec* dest) { };
int Module::OnUserPreInvite(userrec* source,userrec* dest,chanrec* channel) { return 0; };
-int Module::OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text) { return 0; };
-int Module::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text) { return 0; };
+int Module::OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text,char status) { return 0; };
+int Module::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text,char status) { return 0; };
int Module::OnUserPreNick(userrec* user, std::string newnick) { return 0; };
void Module::OnUserPostNick(userrec* user, std::string oldnick) { };
int Module::OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) { return ACR_DEFAULT; };
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp
index ca002f578..f6ec64d6c 100644
--- a/src/modules/extra/m_filter_pcre.cpp
+++ b/src/modules/extra/m_filter_pcre.cpp
@@ -94,54 +94,12 @@ class ModuleFilterPCRE : public Module
// format of a config entry is <keyword pattern="^regexp$" reason="Some reason here" action="kill/block">
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- for (unsigned int index = 0; index < filters.size(); index++)
- {
- if (pcre_exec(filters[index],NULL,text.c_str(),text.length(),0,0,NULL,0) > -1)
- {
- std::string target = "";
- std::string reason = MyConf->ReadValue("keyword","reason",index);
- std::string do_action = MyConf->ReadValue("keyword","action",index);
-
- if (do_action == "")
- do_action = "none";
-
- if (target_type == TYPE_USER)
- {
- userrec* t = (userrec*)dest;
- target = std::string(t->nick);
- }
- else if (target_type == TYPE_CHANNEL)
- {
- chanrec* t = (chanrec*)dest;
- target = std::string(t->name);
- }
- if (do_action == "block")
- {
- Srv->SendOpers(std::string("FilterPCRE: ")+std::string(user->nick)+
- std::string(" had their message filtered, target was ")+
- target+": "+reason);
- // this form of SendTo (with the source as NuLL) sends a server notice
- Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+
- " :Your message has been filtered and opers notified: "+reason);
- }
-
- Srv->Log(DEFAULT,std::string("Filter: ")+std::string(user->nick)+
- std::string(" had their message filtered, target was ")+
- target+": "+reason+" Action: "+do_action);
-
- if (do_action == "kill")
- {
- Srv->QuitUser(user,reason);
- }
- return 1;
- }
- }
- return 0;
+ return OnUserPreNotice(user,dest,target_type,text,status);
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
for (unsigned int index = 0; index < filters.size(); index++)
{
diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp
index 461a05de4..c53520adb 100644
--- a/src/modules/m_blockcolor.cpp
+++ b/src/modules/m_blockcolor.cpp
@@ -47,7 +47,7 @@ class ModuleBlockColor : public Module
InsertMode(output,"c",4);
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
if (target_type == TYPE_CHANNEL)
{
@@ -80,37 +80,9 @@ class ModuleBlockColor : public Module
return 0;
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- if (target_type == TYPE_CHANNEL)
- {
- chanrec* c = (chanrec*)dest;
- char ctext[MAXBUF];
- char *ctptr = ctext;
- strlcpy(ctext,text.c_str(),MAXBUF);
-
-
- if (c->IsCustomModeSet('c'))
- {
- /* Instead of using strchr() here, do our own loop. Hopefully faster. --w00t */
- while (ctptr && *ctptr)
- {
- switch (*ctptr++)
- {
- case 2:
- case 3:
- case 15:
- case 21:
- case 22:
- case 31:
- WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
- return 1;
- break;
- }
- }
- }
- }
- return 0;
+ return OnUserPreMessage(user,dest,target_type,text,status);
}
virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index 45f5af551..f455cef53 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -107,7 +107,7 @@ class ModuleCensor : public Module
// format of a config entry is <badword text="shit" replace="poo">
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
bool active = false;
for (int index = 0; index < MyConf->Enumerate("badword"); index++)
@@ -137,34 +137,9 @@ class ModuleCensor : public Module
return 0;
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- bool active = false;
- for (int index = 0; index < MyConf->Enumerate("badword"); index++)
- {
- std::string pattern = MyConf->ReadValue("badword","text",index);
- if (text.find(pattern) != std::string::npos)
- {
- std::string replace = MyConf->ReadValue("badword","replace",index);
-
- if (target_type == TYPE_USER)
- {
- userrec* t = (userrec*)dest;
- active = (strchr(t->modes,'G') > 0);
- }
- else if (target_type == TYPE_CHANNEL)
- {
- chanrec* t = (chanrec*)dest;
- active = (t->IsCustomModeSet('G'));
- }
-
- if (active)
- {
- this->ReplaceLine(text,pattern,replace);
- }
- }
- }
- return 0;
+ return OnUserPreMessage(user,dest,target_type,text,status);
}
virtual void OnRehash(std::string parameter)
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index ab7339d7e..953e3c28a 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -101,7 +101,7 @@ class ModuleChanFilter : public Module
return 0;
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
if (target_type == TYPE_CHANNEL)
{
@@ -110,13 +110,9 @@ class ModuleChanFilter : public Module
else return 0;
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- if (target_type == TYPE_CHANNEL)
- {
- return ProcessMessages(user,(chanrec*)dest,text);
- }
- else return 0;
+ return OnUserPreMessage(user,dest,target_type,text,status);
}
virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 1fa212999..5b2826f5a 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -69,56 +69,12 @@ class ModuleFilter : public Module
// format of a config entry is <keyword pattern="*glob*" reason="Some reason here" action="kill/block">
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- 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)) || (Srv->MatchText(text,pattern)))
- {
- std::string target = "";
- std::string reason = MyConf->ReadValue("keyword","reason",index);
- std::string do_action = MyConf->ReadValue("keyword","action",index);
-
- if (do_action == "")
- do_action = "none";
-
- if (target_type == TYPE_USER)
- {
- userrec* t = (userrec*)dest;
- target = std::string(t->nick);
- }
- else if (target_type == TYPE_CHANNEL)
- {
- chanrec* t = (chanrec*)dest;
- target = std::string(t->name);
- }
- if (do_action == "block")
- {
- Srv->SendOpers(std::string("FILTER: ")+std::string(user->nick)+
- std::string(" had their message filtered, target was ")+
- target+": "+reason);
- // this form of SendTo (with the source as NuLL) sends a server notice
- Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+
- " :Your message has been filtered and opers notified: "+reason);
- }
-
- Srv->Log(DEFAULT,std::string("FILTER: ")+std::string(user->nick)+
- std::string(" had their message filtered, target was ")+
- target+": "+reason+" Action: "+do_action);
-
- if (do_action == "kill")
- {
- Srv->QuitUser(user,reason);
- }
- return 1;
- }
- }
- return 0;
+ return OnUserPreNotice(user,dest,target_type,text,status);
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
std::string text2 = text+" ";
for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index ad6c74e84..ab0808aa2 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -47,27 +47,12 @@ class ModuleNoCTCP : public Module
InsertMode(output,"C",4);
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- if (target_type == TYPE_CHANNEL)
- {
- chanrec* c = (chanrec*)dest;
- if (c->IsCustomModeSet('C'))
- {
- if ((text.length()) && (text[0] == '\1'))
- {
- if (strncmp(text.c_str(),"\1ACTION ",8))
- {
- WriteServ(user->fd,"492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
- return 1;
- }
- }
- }
- }
- return 0;
+ return OnUserPreNotice(user,dest,target_type,text,status);
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
if (target_type == TYPE_CHANNEL)
{
diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp
index 1d7167274..5ac07839e 100644
--- a/src/modules/m_park.cpp
+++ b/src/modules/m_park.cpp
@@ -322,7 +322,7 @@ class ModulePark : public Module
}
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
if (target_type == TYPE_USER)
{
diff --git a/src/modules/m_restrictmsg.cpp b/src/modules/m_restrictmsg.cpp
index b2e2e60ce..0bc03fab1 100644
--- a/src/modules/m_restrictmsg.cpp
+++ b/src/modules/m_restrictmsg.cpp
@@ -43,7 +43,7 @@ class ModuleRestrictMsg : public Module
List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
if (target_type == TYPE_USER)
{
@@ -64,7 +64,7 @@ class ModuleRestrictMsg : public Module
return 0;
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
return this->OnUserPreMessage(user,dest,target_type,text);
}
diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp
index c4f867ac3..89074ff7f 100644
--- a/src/modules/m_services.cpp
+++ b/src/modules/m_services.cpp
@@ -118,7 +118,7 @@ class ModuleServices : public Module
return 0;
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
if (target_type == TYPE_CHANNEL)
{
@@ -153,39 +153,9 @@ class ModuleServices : public Module
return 0;
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- if (target_type == TYPE_CHANNEL)
- {
- chanrec* c = (chanrec*)dest;
- if ((c->IsCustomModeSet('M')) && (!strchr(user->modes,'r')))
- {
- if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
- {
- // user is ulined, can speak regardless
- return 0;
- }
- // user noticing a +M channel and is not registered
- Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(c->name)+" :You need a registered nickname to speak on this channel");
- return 1;
- }
- }
- if (target_type == TYPE_USER)
- {
- userrec* u = (userrec*)dest;
- if ((strchr(u->modes,'R')) && (!strchr(user->modes,'r')))
- {
- if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
- {
- // user is ulined, can speak regardless
- return 0;
- }
- // user noticing a +R user and is not registered
- Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(u->nick)+" :You need a registered nickname to message this user");
- return 1;
- }
- }
- return 0;
+ return OnUserPreMessage(user,dest,target_type,text,status);
}
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index a0207344c..e785265ac 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -164,7 +164,7 @@ class ModuleSilence : public Module
output = output + " SILENCE=999";
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
// im not sure how unreal's silence operates but ours is sensible. It blocks notices and
// privmsgs from people on the silence list, directed privately at the user.
@@ -190,26 +190,9 @@ class ModuleSilence : public Module
return 0;
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- if (target_type == TYPE_USER)
- {
- userrec* u = (userrec*)dest;
- silencelist* sl = (silencelist*)u->GetExt("silence_list");
- if (sl)
- {
- for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
- {
- irc::string listitem = c->c_str();
- irc::string target = user->nick;
- if (listitem == target)
- {
- return 1;
- }
- }
- }
- }
- return 0;
+ return OnUserPreNotice(user,dest,target_type,text,status);
}
virtual ~ModuleSilence()
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index 2b931daec..19c69ec4b 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -122,7 +122,7 @@ class ModuleStripColor : public Module
text = sentence;
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
bool active = false;
if (target_type == TYPE_USER)
@@ -142,24 +142,9 @@ class ModuleStripColor : public Module
return 0;
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
{
- bool active = false;
- if (target_type == TYPE_USER)
- {
- userrec* t = (userrec*)dest;
- active = (strchr(t->modes,'S') > 0);
- }
- else if (target_type == TYPE_CHANNEL)
- {
- chanrec* t = (chanrec*)dest;
- active = (t->IsCustomModeSet('S'));
- }
- if (active)
- {
- this->ReplaceLine(text);
- }
- return 0;
+ return OnUserPreMessage(user,dest,target_type,text,status);
}
virtual Version GetVersion()