]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added <oper:swhois> to m_swhois, which will override <type:swhois> if specified
authorspecial <special@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 15 Nov 2006 00:10:46 +0000 (00:10 +0000)
committerspecial <special@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 15 Nov 2006 00:10:46 +0000 (00:10 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5747 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_swhois.cpp

index 4cf2bcd50451644df8e58005969cbba3f53fbd1b..7c244834e499a3448da591b31d635b80881260a0 100644 (file)
@@ -100,7 +100,7 @@ class ModuleSWhois : public Module
 
        void Implements(char* List)
        {
-               List[I_OnWhois] = List[I_OnSyncUserMetaData] = List[I_OnUserQuit] = List[I_OnCleanup] = List[I_OnRehash] = List[I_OnOper] = 1;
+               List[I_OnWhois] = List[I_OnSyncUserMetaData] = List[I_OnUserQuit] = List[I_OnCleanup] = List[I_OnRehash] = List[I_OnPostCommand] = 1;
        }
 
        // :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games.
@@ -187,32 +187,50 @@ class ModuleSWhois : public Module
                }
        }
        
-       virtual void OnOper(userrec* user, const std::string &opertype)
+       virtual void OnPostCommand(const std::string &command, const char **params, int pcnt, userrec *user, CmdResult result, const std::string &original_line)
        {
-               for(int i =0; i < Conf->Enumerate("type"); i++)
+               if ((command != "OPER") || (result != CMD_SUCCESS))
+                       return;
+               
+               std::string swhois;
+               
+               for (int i = 0; i < Conf->Enumerate("oper"); i++)
                {
-                       std::string type = Conf->ReadValue("type", "name", i);
+                       std::string name = Conf->ReadValue("oper", "name", i);
                        
-                       if(strcmp(type.c_str(), user->oper) == 0)
+                       if (name == params[0])
+                       {
+                               swhois = Conf->ReadValue("oper", "swhois", i);
+                               break;
+                       }
+               }
+               
+               if (!swhois.length())
+               {
+                       for (int i = 0; i < Conf->Enumerate("type"); i++)
                        {
-                               std::string swhois = Conf->ReadValue("type", "swhois", i);
+                               std::string type = Conf->ReadValue("type", "name", i);
                                
-                               if(swhois.length())
+                               if (type == user->oper)
                                {
-                                       std::string* old;
-                                       if(user->GetExt("swhois", old))
-                                       {
-                                               user->Shrink("swhois");
-                                               DELETE(old);
-                                       }
-                       
-                                       std::string* text = new std::string(swhois);
-                                       user->Extend("swhois", text);
-                                       
+                                       swhois = Conf->ReadValue("type", "swhois", i);
                                        break;
                                }
                        }
-               }               
+               }
+
+               std::string *old;
+               if (user->GetExt("swhois", old))
+               {
+                       user->Shrink("swhois");
+                       DELETE(old);
+               }
+               
+               if (!swhois.length())
+                       return;
+               
+               std::string *text = new std::string(swhois);
+               user->Extend("swhois", text);
        }
        
        virtual ~ModuleSWhois()