]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spy.cpp
All modules which implement simplemodes (no parameters, not a list mode) can now...
[user/henk/code/inspircd.git] / src / modules / m_spy.cpp
index faf4e431aedc12f03e8ab94c2c2edf3bacc64d0c..bcf2a25ac9b28b44deb4c28d1eceac67d325d220 100644 (file)
@@ -23,33 +23,12 @@ using namespace std;
 
 /* $ModDesc: Provides SPYLIST and SPYNAMES capability, allowing opers to see who's in +s channels */
 
-#include <stdio.h>
-#include <vector>
-#include <deque>
-#include "globals.h"
 #include "inspircd_config.h"
-#include <ext/hash_map>
 #include "users.h" 
 #include "channels.h"
 #include "modules.h"
-#include "commands.h"
-#include "socket.h"
-#include "helperfuncs.h"
 #include "inspircd.h"
-#include "inspstring.h"
-#include "hashcomp.h"
-#include "message.h"
-#include "xline.h"
-#include "typedefs.h"
-#include "cull_list.h"
-#include "aes.h"
-
-#define nspace __gnu_cxx
-
-static Server *Srv;
-
-extern InspIRCd* ServerInstance;
-extern chan_hash chanlist;
+#include "wildcard.h"
 
 void spy_userlist(userrec *user,chanrec *c)
 {
@@ -63,7 +42,7 @@ void spy_userlist(userrec *user,chanrec *c)
        CUList *ulist= c->GetUsers();
        for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
        {
-               strlcat(list,cmode(i->second,c),MAXBUF);
+               strlcat(list,c->GetPrefixChar(i->second),MAXBUF);
                strlcat(list,i->second->nick,MAXBUF);
                strlcat(list," ",MAXBUF);
                if (strlen(list)>(480-NICKMAX))
@@ -86,7 +65,7 @@ void spy_userlist(userrec *user,chanrec *c)
 class cmd_spylist : public command_t
 {
   public:
-       cmd_spylist () : command_t("SPYLIST", 'o', 0)
+       cmd_spylist (InspIRCd* Instance) : command_t(Instance,"SPYLIST", 'o', 0)
        {
                this->source = "m_spy.so";
                syntax = "";
@@ -94,11 +73,13 @@ class cmd_spylist : public command_t
 
        void Handle (const char** parameters, int pcnt, userrec *user)
        {
-               WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick);
+               ServerInstance->WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick);
                user->WriteServ("321 %s Channel :Users Name",user->nick);
-               for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++)
+               for (chan_hash::const_iterator i = ServerInstance->chanlist.begin(); i != ServerInstance->chanlist.end(); i++)
                {
-                       user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,usercount(i->second),chanmodes(i->second,true),i->second->topic);
+                       if (pcnt && !match(i->second->name, parameters[0]))
+                               continue;
+                       user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,i->second->GetUserCounter(),i->second->ChanModes(true),i->second->topic);
                }
                user->WriteServ("323 %s :End of channel list.",user->nick);
        }
@@ -107,7 +88,7 @@ class cmd_spylist : public command_t
 class cmd_spynames : public command_t
 {
   public:
-       cmd_spynames () : command_t("SPYNAMES", 'o', 0)
+       cmd_spynames (InspIRCd* Instance) : command_t(Instance,"SPYNAMES", 'o', 0)
        {
                this->source = "m_spy.so";
                syntax = "{<channel>{,<channel>}}";
@@ -126,9 +107,9 @@ class cmd_spynames : public command_t
                if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 1))
                        return;
 
-               WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]);
+               ServerInstance->WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]);
 
-               c = FindChan(parameters[0]);
+               c = ServerInstance->FindChan(parameters[0]);
                if (c)
                {
                        spy_userlist(user,c);
@@ -146,13 +127,13 @@ class ModuleSpy : public Module
        cmd_spylist *mycommand;
        cmd_spynames *mycommand2;
  public:
-       ModuleSpy(Server* Me) : Module::Module(Me)
+       ModuleSpy(InspIRCd* Me) : Module::Module(Me)
        {
-               Srv = Me;
-               mycommand = new cmd_spylist();
-               mycommand2 = new cmd_spynames();
-               Srv->AddCommand(mycommand);
-               Srv->AddCommand(mycommand2);
+               
+               mycommand = new cmd_spylist(ServerInstance);
+               mycommand2 = new cmd_spynames(ServerInstance);
+               ServerInstance->AddCommand(mycommand);
+               ServerInstance->AddCommand(mycommand2);
        }
        
        virtual ~ModuleSpy()
@@ -177,7 +158,7 @@ class ModuleSpyFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule(Server* Me)
+       virtual Module * CreateModule(InspIRCd* Me)
        {
                return new ModuleSpy(Me);
        }