summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_deaf.cpp61
-rw-r--r--src/modules/m_silence_ext.cpp33
-rw-r--r--src/modules/m_spanningtree.cpp35
3 files changed, 92 insertions, 37 deletions
diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp
index 67c2b7210..6ec65437c 100644
--- a/src/modules/m_deaf.cpp
+++ b/src/modules/m_deaf.cpp
@@ -65,7 +65,7 @@ class ModuleDeaf : public Module
void Implements(char* List)
{
- List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
+ List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnBuildExemptList] = 1;
}
virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
@@ -78,6 +78,37 @@ class ModuleDeaf : public Module
return PreText(user, dest, target_type, text, status, exempt_list);
}
+ virtual void OnBuildExemptList(MessageType message_type, chanrec* chan, userrec* sender, char status, CUList &exempt_list)
+ {
+ CUList *ulist;
+ switch (status)
+ {
+ case '@':
+ ulist = chan->GetOppedUsers();
+ break;
+ case '%':
+ ulist = chan->GetHalfoppedUsers();
+ break;
+ case '+':
+ ulist = chan->GetVoicedUsers();
+ break;
+ default:
+ ulist = chan->GetUsers();
+ break;
+ }
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if (IS_LOCAL(i->second))
+ {
+ if (i->second->IsModeSet('d'))
+ {
+ exempt_list[i->second] = i->second;
+ }
+ }
+ }
+ }
+
virtual int PreText(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if (target_type == TYPE_CHANNEL)
@@ -85,33 +116,7 @@ class ModuleDeaf : public Module
chanrec* chan = (chanrec*)dest;
if (chan)
{
- CUList *ulist;
- switch (status)
- {
- case '@':
- ulist = chan->GetOppedUsers();
- break;
- case '%':
- ulist = chan->GetHalfoppedUsers();
- break;
- case '+':
- ulist = chan->GetVoicedUsers();
- break;
- default:
- ulist = chan->GetUsers();
- break;
- }
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if ((IS_LOCAL(i->second)) && (user != i->second))
- {
- if (i->second->IsModeSet('d'))
- {
- exempt_list[i->second] = i->second;
- }
- }
- }
+ this->OnBuildExemptList(chan, status, exempt_list);
}
}
return 0;
diff --git a/src/modules/m_silence_ext.cpp b/src/modules/m_silence_ext.cpp
index a6a7f60ca..19abc679f 100644
--- a/src/modules/m_silence_ext.cpp
+++ b/src/modules/m_silence_ext.cpp
@@ -255,7 +255,7 @@ class ModuleSilence : public Module
void Implements(char* List)
{
- List[I_OnUserQuit] = List[I_On005Numeric] = List[I_OnUserPreNotice] = List[I_OnUserPreMessage] = List[I_OnUserPreInvite] = 1;
+ List[I_OnBuildExemptList] = List[I_OnUserQuit] = List[I_On005Numeric] = List[I_OnUserPreNotice] = List[I_OnUserPreMessage] = List[I_OnUserPreInvite] = 1;
}
virtual void OnUserQuit(userrec* user, const std::string &reason)
@@ -276,6 +276,37 @@ class ModuleSilence : public Module
output = output + " ESILENCE SILENCE=999";
}
+ virtual void OnBuildExemptList(MessageType message_type, chanrec* chan, userrec* sender, char status, CUList &exempt_list)
+ {
+ int public_silence = (message_type == MSG_PRIVMSG ? SILENCE_CHANNEL : SILENCE_CNOTICE);
+ CUList *ulist;
+ switch (status)
+ {
+ case '@':
+ ulist = chan->GetOppedUsers();
+ break;
+ case '%':
+ ulist = chan->GetHalfoppedUsers();
+ break;
+ case '+':
+ ulist = chan->GetVoicedUsers();
+ break;
+ default:
+ ulist = chan->GetUsers();
+ break;
+ }
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if (IS_LOCAL(i->second))
+ {
+ if (MatchPattern(i->second, sender, public_silence) == 1)
+ {
+ exempt_list[i->second] = i->second;
+ }
+ }
+ }
+ }
virtual int PreText(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list, int silence_type)
{
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 42a939a7d..f3c312b50 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -182,7 +182,7 @@ class SpanningTreeUtilities
void AddThisServer(TreeServer* server, std::deque<TreeServer*> &list);
/** Compile a list of servers which contain members of channel c
*/
- void GetListOfServersForChannel(chanrec* c, std::deque<TreeServer*> &list, const CUList &exempt_list);
+ void GetListOfServersForChannel(chanrec* c, std::deque<TreeServer*> &list, char status, const CUList &exempt_list);
/** Find a server by name
*/
TreeServer* FindServer(const std::string &ServerName);
@@ -3789,9 +3789,24 @@ void SpanningTreeUtilities::AddThisServer(TreeServer* server, std::deque<TreeSer
}
/** returns a list of DIRECT servernames for a specific channel */
-void SpanningTreeUtilities::GetListOfServersForChannel(chanrec* c, std::deque<TreeServer*> &list, const CUList &exempt_list)
+void SpanningTreeUtilities::GetListOfServersForChannel(chanrec* c, std::deque<TreeServer*> &list, char status, const CUList &exempt_list)
{
- CUList *ulist = c->GetUsers();
+ CUList *ulist;
+ switch (status)
+ {
+ case '@':
+ ulist = c->GetOppedUsers();
+ break;
+ case '%':
+ ulist = c->GetHalfoppedUsers();
+ break;
+ case '+':
+ ulist = c->GetVoicedUsers();
+ break;
+ default:
+ ulist = c->GetUsers();
+ break;
+ }
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
if ((i->second->GetFd() < 0) && (exempt_list.find(i->second) == exempt_list.end()))
@@ -3806,6 +3821,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(chanrec* c, std::deque<Tr
bool SpanningTreeUtilities::DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> &params)
{
+ char pfx = 0;
TreeServer* omitroute = this->BestRouteTo(omit);
if ((command == "NOTICE") || (command == "PRIVMSG"))
{
@@ -3814,6 +3830,7 @@ bool SpanningTreeUtilities::DoOneToAllButSenderRaw(const std::string &data, cons
/* Prefixes */
if ((*(params[0].c_str()) == '@') || (*(params[0].c_str()) == '%') || (*(params[0].c_str()) == '+'))
{
+ pfx = params[0][0];
params[0] = params[0].substr(1, params[0].length()-1);
}
if ((*(params[0].c_str()) != '#') && (*(params[0].c_str()) != '$'))
@@ -3840,11 +3857,13 @@ bool SpanningTreeUtilities::DoOneToAllButSenderRaw(const std::string &data, cons
else
{
chanrec* c = ServerInstance->FindChan(params[0]);
- if (c)
+ userrec* u = ServerInstance->FindNick(prefix);
+ if (c && u)
{
- CUList empty;
+ CUList elist;
std::deque<TreeServer*> list;
- GetListOfServersForChannel(c,list,empty);
+ FOREACH_MOD(I_OnBuildExemptList, OnBuildExemptList((command == "PRIVMSG" ? MSG_PRIVMSG : MSG_NOTICE), c, u, pfx, elist));
+ GetListOfServersForChannel(c,list,pfx,elist);
unsigned int lsize = list.size();
for (unsigned int i = 0; i < lsize; i++)
{
@@ -4809,7 +4828,7 @@ class ModuleSpanningTree : public Module
if (status)
cname = status + cname;
std::deque<TreeServer*> list;
- Utils->GetListOfServersForChannel(c,list,exempt_list);
+ Utils->GetListOfServersForChannel(c,list,status,exempt_list);
unsigned int ucount = list.size();
for (unsigned int i = 0; i < ucount; i++)
{
@@ -4860,7 +4879,7 @@ class ModuleSpanningTree : public Module
if (status)
cname = status + cname;
std::deque<TreeServer*> list;
- Utils->GetListOfServersForChannel(c,list,exempt_list);
+ Utils->GetListOfServersForChannel(c,list,status,exempt_list);
unsigned int ucount = list.size();
for (unsigned int i = 0; i < ucount; i++)
{