]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_callerid.cpp
Weed out a few leftover server instances from before modules had ServerInstance....
[user/henk/code/inspircd.git] / src / modules / m_callerid.cpp
index 52828fdca6796c35c3cd05bfdf2ada58c713268f..3592767682b49a481e4d2de80980deb77954d2fd 100644 (file)
@@ -1,12 +1,19 @@
-#include "inspircd.h"
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
 
+#include "inspircd.h"
 #include <set>
-
 #include <sstream>
-
 #include <algorithm>
 
 /* $ModDesc: Implementation of callerid (umode +g & /accept, ala hybrid etc) */
@@ -49,7 +56,7 @@ class callerid_data : public classbase
        {
                std::ostringstream oss;
                oss << lastnotify;
-               for (std::set<User*>::iterator i = accepting.begin(); i != accepting.end(); ++i)
+               for (std::set<User*>::const_iterator i = accepting.begin(); i != accepting.end(); ++i)
                {
                        // Encode UIDs.
                        oss << "," << (displayable ? (*i)->nick : (*i)->uuid);
@@ -174,7 +181,8 @@ public:
                        return CMD_SUCCESS;
                /* Even if callerid mode is not set, we let them manage their ACCEPT list so that if they go +g they can
                 * have a list already setup. */
-               bool atleastonechange = false;
+
+               std::string tok = parameters[0];
 
                if (tok == "*")
                {
@@ -187,6 +195,8 @@ public:
                        User* whotoremove = ServerInstance->FindNick(tok.substr(1));
                        if (whotoremove)
                                return (RemoveAccept(user, whotoremove, false) ? CMD_SUCCESS : CMD_FAILURE);
+                       else
+                               return CMD_FAILURE;
                }
                else
                {
@@ -229,6 +239,8 @@ public:
 
                        return false;
                }
+
+               user->WriteServ("NOTICE %s :%s is now on your accept list", user->nick.c_str(), whotoadd->nick.c_str());
                return true;
        }
 
@@ -250,6 +262,8 @@ public:
 
                        return false;
                }
+
+               user->WriteServ("NOTICE %s :%s is no longer on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
                dat->accepting.erase(i);
                return true;
        }
@@ -303,7 +317,7 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
        }
 
        virtual void On005Numeric(std::string& output)
@@ -320,17 +334,20 @@ public:
                        return 0;
 
                callerid_data* dat = GetData(dest, true);
-               std::set<User*>::iterator i = dat->accepting.find(dest);
+               std::set<User*>::iterator i = dat->accepting.find(user);
 
                if (i == dat->accepting.end())
                {
-                       time_t now = time(NULL);
+                       time_t now = ServerInstance->Time();
                        /* +g and *not* accepted */
-                       user->WriteNumeric(716, "%s %s :is in +g mode (server-side ignore).", user->nick.c_str(), dest->nick.c_str());
+                       if (IS_LOCAL(user))
+                               user->WriteNumeric(716, "%s %s :is in +g mode (server-side ignore).", user->nick.c_str(), dest->nick.c_str());
+                       else
+                               ServerInstance->PI->PushToClient(user, std::string("::") + ServerInstance->Config->ServerName + " 716 " + user->nick + dest->nick + " :is in +g mode (server-side ignore).");
                        if (now > (dat->lastnotify + (time_t)notify_cooldown))
                        {
                                user->WriteNumeric(717, "%s %s :has been informed that you messaged them.", user->nick.c_str(), dest->nick.c_str());
-                               dest->WriteNumeric(718, "%s %s %s@%s :is messaging you, and you have umode +g", dest->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str());
+                               dest->WriteNumeric(718, "%s %s %s@%s :is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.", dest->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), user->nick.c_str());
                                dat->lastnotify = now;
                        }
                        return 1;