]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spy.cpp
Annotations
[user/henk/code/inspircd.git] / src / modules / m_spy.cpp
index 55b3a650c83d537a2ac73d8cf8018174cc5f3f7e..6e1897aa27efe1820d48c5f3829708d15647bfc4 100644 (file)
@@ -23,33 +23,18 @@ 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 "inspircd.h"
-#include "inspstring.h"
-#include "hashcomp.h"
-#include "xline.h"
-#include "typedefs.h"
-#include "cull_list.h"
-#include "aes.h"
-
-#define nspace __gnu_cxx
+#include "wildcard.h"
 
-void spy_userlist(userrec *user,chanrec *c)
+void spy_userlist(userrec *user, chanrec *c)
 {
        static char list[MAXBUF];
 
-       if ((!c) || (!user))
+       if (!c || !user)
                return;
 
        snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
@@ -57,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,c->GetStatusChar(i->second),MAXBUF);
+               strlcat(list,c->GetPrefixChar(i->second),MAXBUF);
                strlcat(list,i->second->nick,MAXBUF);
                strlcat(list," ",MAXBUF);
                if (strlen(list)>(480-NICKMAX))
@@ -80,51 +65,55 @@ void spy_userlist(userrec *user,chanrec *c)
 class cmd_spylist : public command_t
 {
   public:
- cmd_spylist (InspIRCd* Instance) : command_t(Instance,"SPYLIST", 'o', 0)
      cmd_spylist (InspIRCd* Instance) : command_t(Instance,"SPYLIST", 'o', 0)
        {
                this->source = "m_spy.so";
                syntax = "";
        }
 
-       void Handle (const char** parameters, int pcnt, userrec *user)
+       CmdResult Handle (const char** parameters, int pcnt, userrec *user)
        {
                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 = ServerInstance->chanlist.begin(); i != ServerInstance->chanlist.end(); i++)
                {
+                       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);
+
+               /* Dont send out across the network */
+               return CMD_FAILURE;
        }
 };
 
 class cmd_spynames : public command_t
 {
   public:
- cmd_spynames (InspIRCd* Instance) : command_t(Instance,"SPYNAMES", 'o', 0)
      cmd_spynames (InspIRCd* Instance) : command_t(Instance,"SPYNAMES", 'o', 0)
        {
                this->source = "m_spy.so";
                syntax = "{<channel>{,<channel>}}";
        }
 
-       void Handle (const char** parameters, int pcnt, userrec *user)
+       CmdResult Handle (const char** parameters, int pcnt, userrec *user)
        {
-               chanrec* c;
+               chanrec* c = NULL;
 
                if (!pcnt)
                {
                        user->WriteServ("366 %s * :End of /NAMES list.",user->nick);
-                       return;
+                       return CMD_FAILURE;
                }
 
                if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 1))
-                       return;
-
-               ServerInstance->WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]);
+                       return CMD_FAILURE;
 
                c = ServerInstance->FindChan(parameters[0]);
                if (c)
                {
+                       ServerInstance->WriteOpers("*** Oper %s used SPYNAMES to view the users on %s", user->nick, parameters[0]);
                        spy_userlist(user,c);
                        user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, c->name);
                }
@@ -132,6 +121,8 @@ class cmd_spynames : public command_t
                {
                        user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
                }
+
+               return CMD_FAILURE;
        }
 };