]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_safelist.cpp
Annotations
[user/henk/code/inspircd.git] / src / modules / m_safelist.cpp
index 89e72f6527d43adb126961c0218af7a9ff4ebc48..ac7225b5eba3f9fdea68cbc3ce26d6303eeaff51 100644 (file)
@@ -19,20 +19,22 @@ using namespace std;
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include "helperfuncs.h"
-#include <vector>
 #include "configreader.h"
 #include "inspircd.h"
+#include "wildcard.h"
 
+/** Holds a users m_safelist state
+ */
 class ListData : public classbase
 {
  public:
        long list_start;
        long list_position;
        bool list_ended;
+       const std::string glob;
 
        ListData() : list_start(0), list_position(0), list_ended(false) {};
-       ListData(long pos, time_t t) : list_start(t), list_position(pos), list_ended(false) {};
+       ListData(long pos, time_t t, const std::string &pattern) : list_start(t), list_position(pos), list_ended(false), glob(pattern) {};
 };
 
 /* $ModDesc: A module overriding /list, and making it safe - stop those sendq problems. */
@@ -52,6 +54,7 @@ class ListTimer : public InspTimer
        char buffer[MAXBUF];
        chanrec *chan;
        InspIRCd* ServerInstance;
+       const std::string glob;
 
  public:
 
@@ -101,8 +104,10 @@ class ListTimer : public InspTimer
                                        bool has_user = (chan && chan->HasUser(u));
                                        if ((chan) && (((!(chan->modes[CM_PRIVATE])) && (!(chan->modes[CM_SECRET]))) || (has_user)))
                                        {
+                                               bool display = match(chan->name, ld->glob.c_str());
+
                                                long users = chan->GetUserCounter();
-                                               if (users)
+                                               if ((users) && (display))
                                                {
                                                        int counter = snprintf(buffer,MAXBUF,"322 %s %s %ld :[+%s] %s",u->nick,chan->name,users,chan->ChanModes(has_user),chan->topic);
                                                        /* Increment total plus linefeed */
@@ -210,7 +215,7 @@ class ModuleSafeList : public Module
                /*
                 * start at channel 0! ;)
                 */
-               ld = new ListData(0,ServerInstance->Time());
+               ld = new ListData(0,ServerInstance->Time(), pcnt ? parameters[0] : "*");
                user->Extend("safelist_cache", ld);
                listusers.push_back(user);
 
@@ -263,11 +268,8 @@ class ModuleSafeList : public Module
        }
 
 };
-/******************************************************************************************************/
+
+
 class ModuleSafeListFactory : public ModuleFactory
 {
  public: