]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Allow for custom prefixes as status chars in /notice @#chan etc. Up until now theyve...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 4 Apr 2008 18:50:09 +0000 (18:50 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 4 Apr 2008 18:50:09 +0000 (18:50 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9329 e03df62e-2008-0410-955e-edbf42e46eb7

src/channels.cpp
src/commands/cmd_notice.cpp
src/commands/cmd_privmsg.cpp
src/modules/m_deaf.cpp
src/modules/m_spanningtree/privmsg.cpp
src/modules/m_spanningtree/utils.cpp

index 52e8faca9006384fd925f8199bfc614b32f0f81e..c03a69ace9222a66d3a95cd8b42859069c69e21e 100644 (file)
@@ -721,25 +721,9 @@ void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList
 
 void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &text)
 {
-       CUList *ulist;
+       CUList *ulist = this->GetUsers();
        char tb[MAXBUF];
 
-       switch (status)
-       {
-               case '@':
-                       ulist = this->GetOppedUsers();
-                       break;
-               case '%':
-                       ulist = this->GetHalfoppedUsers();
-                       break;
-               case '+':
-                       ulist = this->GetVoicedUsers();
-                       break;
-               default:
-                       ulist = this->GetUsers();
-                       break;
-       }
-
        snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
        std::string out = tb;
 
@@ -747,6 +731,10 @@ void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList
        {
                if ((IS_LOCAL(i->first)) && (except_list.find(i->first) == except_list.end()))
                {
+                       /* User doesnt have the status we're after */
+                       if (status && !strchr(this->GetAllPrefixChars(i->first), status))
+                               continue;
+
                        if (serversource)
                                i->first->WriteServ(text);
                        else
index ee9868fb3f9a13b2ad21d3da60a93727ba8f3afb..1a47b56fb72f2cd9d30079f9f0e5a7d7ccaec954 100644 (file)
@@ -51,7 +51,7 @@ CmdResult CommandNotice::Handle (const char* const* parameters, int pcnt, User *
        }
        char status = 0;
        const char* target = parameters[0];
-       if ((*target == '@') || (*target == '%') || (*target == '+'))
+       if (ServerInstance->Modes->FindPrefix(*target))
        {
                status = *target;
                target++;
index c9100dcd9ed3ec8ebfd6704a3532f1523fcc08c7..9ce089dc0cd44c0129eddf6976b446575a4ca86c 100644 (file)
@@ -50,7 +50,7 @@ CmdResult CommandPrivmsg::Handle (const char* const* parameters, int pcnt, User
        }
        char status = 0;
        const char* target = parameters[0];
-       if ((*target == '@') || (*target == '%') || (*target == '+'))
+       if (ServerInstance->Modes->FindPrefix(*target))
        {
                status = *target;
                target++;
index 6431462f306c2c5ce5ab4dfaab9bc39f54e39504..179a443a7c601b939915a7a5f5b3887f8ad4197a 100644 (file)
@@ -109,7 +109,7 @@ class ModuleDeaf : public Module
 
        virtual void BuildDeafList(MessageType message_type, Channel* chan, User* sender, char status, const std::string &text, CUList &exempt_list)
        {
-               CUList *ulist;
+               CUList *ulist = chan->GetUsers();
                bool is_a_uline;
                bool is_bypasschar, is_bypasschar_avail;
                bool is_bypasschar_uline, is_bypasschar_uline_avail;
@@ -135,22 +135,6 @@ class ModuleDeaf : public Module
                if (!is_bypasschar_uline_avail && is_bypasschar)
                        return;
 
-               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++)
                {
                        /* not +d ? */
@@ -168,6 +152,9 @@ class ModuleDeaf : public Module
                        if (is_bypasschar && !is_a_uline)
                                continue; /* deliver message */
 
+                       if (status && !strchr(chan->GetAllPrefixChars(i->first), status))
+                               continue;
+
                        /* don't deliver message! */
                        exempt_list[i->first] = i->first->nick;
                }
index 4a266a465657e054ed2fcd4f2f57fa65c9c933a9..316ad2e5cd996997d5560876b9521f95f009476f 100644 (file)
@@ -32,7 +32,7 @@ bool TreeSocket::ServerMessage(const std::string &messagetype, const std::string
                const char* target = params[0].c_str();
                std::string text = params[1].c_str();
 
-               if ((*target == '@') || (*target == '%') || (*target == '+'))
+               if (Instance->Modes->FindPrefix(*target))
                {
                        status = *target;
                        target++;
index 8181969aceeae049236337c15b8a14d6494b9eb6..bc295766fca3b72a3525dff83dff42a1d6b79c15 100644 (file)
@@ -162,25 +162,17 @@ void SpanningTreeUtilities::AddThisServer(TreeServer* server, TreeServerList &li
 /* returns a list of DIRECT servernames for a specific channel */
 void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerList &list, char status, const CUList &exempt_list)
 {
-       CUList *ulist;
-       switch (status)
-       {
-               case '@':
-                       ulist = c->GetOppedUsers();
-               break;
-               case '%':
-                       ulist = c->GetHalfoppedUsers();
-               break;
-               case '+':
-                       ulist = c->GetVoicedUsers();
-               break;
-               default:
-                       ulist = c->GetUsers();
-               break;
-       }
+       CUList *ulist = c->GetUsers();
+
        for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
        {
-               if ((i->first->GetFd() < 0) && (exempt_list.find(i->first) == exempt_list.end()))
+               if (IS_LOCAL(i->first))
+                       continue;
+
+               if (status && !strchr(c->GetAllPrefixChars(i->first), status))
+                       continue;
+
+               if (exempt_list.find(i->first) == exempt_list.end())
                {
                        TreeServer* best = this->BestRouteTo(i->first->server);
                        if (best)
@@ -199,7 +191,7 @@ bool SpanningTreeUtilities::DoOneToAllButSenderRaw(const std::string &data, cons
                if (params.size() >= 2)
                {
                        /* Prefixes */
-                       if ((*(params[0].c_str()) == '@') || (*(params[0].c_str()) == '%') || (*(params[0].c_str()) == '+'))
+                       if (ServerInstance->Modes->FindPrefix(params[0][0]))
                        {
                                pfx = params[0][0];
                                params[0] = params[0].substr(1, params[0].length()-1);