]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_check.cpp
Remove some pointless code:
[user/henk/code/inspircd.git] / src / modules / m_check.cpp
index 734089c5b5bb29e0b2e0140db90dc60de84c09a0..84e147f7b88979ddf630edbd332d75245c31806f 100644 (file)
@@ -20,8 +20,6 @@
  */
 
 
-/* $ModDesc: Provides the /CHECK command to retrieve information on a user, channel, hostname or IP address */
-
 #include "inspircd.h"
 #include "listmode.h"
 
  */
 class CommandCheck : public Command
 {
-       ModeReference ban;
+       UserModeReference snomaskmode;
+
+       std::string GetSnomasks(User* user)
+       {
+               std::string ret;
+               if (snomaskmode)
+                       ret = snomaskmode->GetUserParameter(user);
+
+               if (ret.empty())
+                       ret = "+";
+               return ret;
+       }
+
+       static void dumpListMode(User* user, const std::string& checkstr, const ListModeBase::ModeList* list)
+       {
+               if (!list)
+                       return;
+
+               std::string buf = checkstr + " modelist";
+               const std::string::size_type headlen = buf.length();
+               const size_t maxline = ServerInstance->Config->Limits.MaxLine;
+               for (ListModeBase::ModeList::const_iterator i = list->begin(); i != list->end(); ++i)
+               {
+                       if (buf.size() + i->mask.size() + 1 > maxline)
+                       {
+                               user->SendText(buf);
+                               buf.erase(headlen);
+                       }
+                       buf.append(" ").append(i->mask);
+               }
+               if (buf.length() > headlen)
+                       user->SendText(buf);
+       }
+
  public:
        CommandCheck(Module* parent)
                : Command(parent,"CHECK", 1)
-               , ban(parent, "ban")
+               , snomaskmode(parent, "snomask")
        {
                flags_needed = 'o'; syntax = "<nickname>|<ip>|<hostmask>|<channel> <server>";
        }
@@ -94,7 +125,7 @@ class CommandCheck : public Command
                        user->SendText(checkstr + " realnuh " + targuser->GetFullRealHost());
                        user->SendText(checkstr + " realname " + targuser->fullname);
                        user->SendText(checkstr + " modes +" + targuser->FormatModes());
-                       user->SendText(checkstr + " snomasks +" + targuser->FormatNoticeMasks());
+                       user->SendText(checkstr + " snomasks " + GetSnomasks(targuser));
                        user->SendText(checkstr + " server " + targuser->server);
                        user->SendText(checkstr + " uid " + targuser->uuid);
                        user->SendText(checkstr + " signon " + timestring(targuser->signon));
@@ -149,8 +180,8 @@ class CommandCheck : public Command
 
                        if (loctarg)
                        {
-                               user->SendText(checkstr + " clientaddr " + irc::sockets::satouser(loctarg->client_sa));
-                               user->SendText(checkstr + " serveraddr " + irc::sockets::satouser(loctarg->server_sa));
+                               user->SendText(checkstr + " clientaddr " + loctarg->client_sa.str());
+                               user->SendText(checkstr + " serveraddr " + loctarg->server_sa.str());
 
                                std::string classname = loctarg->GetClass()->name;
                                if (!classname.empty())
@@ -203,12 +234,10 @@ class CommandCheck : public Command
                                        i->first->ident.c_str(), i->first->dhost.c_str(), i->first->fullname.c_str());
                        }
 
-                       // We know that the mode handler for bans is in the core and is derived from ListModeBase
-                       ListModeBase* banlm = static_cast<ListModeBase*>(*ban);
-                       banlm->DoSyncChannel(targchan, creator, user);
+                       const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes();
+                       for (ModeParser::ListModeList::const_iterator i = listmodes.begin(); i != listmodes.end(); ++i)
+                               dumpListMode(user, checkstr, (*i)->GetList(targchan));
 
-                       // Show other listmodes as well
-                       FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(targchan,creator,user));
                        dumpExt(user, checkstr, targchan);
                }
                else
@@ -256,27 +285,6 @@ class ModuleCheck : public Module
        {
        }
 
-       void init() CXX11_OVERRIDE
-       {
-               ServerInstance->Modules->AddService(mycommand);
-       }
-
-       void ProtoSendMode(void* uv, TargetTypeFlags, void*, const std::vector<std::string>& result, const std::vector<TranslateType>&)
-       {
-               User* user = (User*)uv;
-               std::string checkstr(":");
-               checkstr.append(ServerInstance->Config->ServerName);
-               checkstr.append(" 304 ");
-               checkstr.append(user->nick);
-               checkstr.append(" :CHECK modelist");
-               for(unsigned int i=0; i < result.size(); i++)
-               {
-                       checkstr.append(" ");
-                       checkstr.append(result[i]);
-               }
-               user->SendText(checkstr);
-       }
-
        Version GetVersion() CXX11_OVERRIDE
        {
                return Version("CHECK command, view user, channel, IP address or hostname information", VF_VENDOR|VF_OPTCOMMON);