X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcmd_ison.cpp;h=d050af9827c8312e61ad1c7ae1426313cccee13e;hb=bb35a0fa9cbebe51fa636f707c12ca4a7033dd9a;hp=ed385f9d9f4537957e3643005988a77fa8b8a0cc;hpb=bac9db911c54713f6b431821a86021cb2ae1b818;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/cmd_ison.cpp b/src/cmd_ison.cpp index ed385f9d9..d050af982 100644 --- a/src/cmd_ison.cpp +++ b/src/cmd_ison.cpp @@ -2,53 +2,88 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * Inspire is copyright (C) 2002-2005 ChatSpike-Dev. - * E-mail: - * - * + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits * - * Written by Craig Edwards, Craig McLure, and others. * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ -using namespace std; - -#include "inspircd_config.h" #include "inspircd.h" -#include "inspircd_io.h" -#include #include "users.h" -#include "ctables.h" -#include "globals.h" -#include "modules.h" -#include "dynamic.h" -#include "wildcard.h" -#include "message.h" -#include "commands.h" -#include "inspstring.h" -#include "helperfuncs.h" -#include "hashcomp.h" -#include "typedefs.h" -#include "cmd_ison.h" - -void cmd_ison::Handle (char **parameters, int pcnt, userrec *user) +#include "commands/cmd_ison.h" + +extern "C" DllExport command_t* init_command(InspIRCd* Instance) +{ + return new cmd_ison(Instance); +} + +/** Handle /ISON + */ +CmdResult cmd_ison::Handle (const char** parameters, int pcnt, userrec *user) { - char Return[MAXBUF]; - snprintf(Return,MAXBUF,"303 %s :",user->nick); + std::map ison_already; + userrec *u; + std::string reply = std::string("303 ") + user->nick + " :"; + for (int i = 0; i < pcnt; i++) { - userrec *u = Find(parameters[i]); + u = ServerInstance->FindNick(parameters[i]); + if (ison_already.find(u) != ison_already.end()) + continue; + if (u) { - strlcat(Return,u->nick,MAXBUF); - strlcat(Return," ",MAXBUF); + if (u->Visibility && !u->Visibility->VisibleTo(user)) + continue; + + reply.append(u->nick).append(" "); + if (reply.length() > 450) + { + user->WriteServ(reply); + reply = std::string("303 ") + user->nick + " :"; + } + ison_already[u] = u; + } + else + { + if ((i == pcnt-1) && (strchr(parameters[i],' '))) + { + /* Its a space seperated list of nicks (RFC1459 says to support this) + */ + irc::spacesepstream list(parameters[i]); + std::string item("*"); + while (((item = list.GetToken()) != "")) + { + u = ServerInstance->FindNick(item); + if (ison_already.find(u) != ison_already.end()) + continue; + + if (u) + { + if (u->Visibility && !u->Visibility->VisibleTo(user)) + continue; + + reply.append(u->nick).append(" "); + if (reply.length() > 450) + { + user->WriteServ(reply); + reply = std::string("303 ") + user->nick + " :"; + } + ison_already[u] = u; + } + } + } + /* There will only be one of these, we can bail after. */ + break; } } - WriteServ(user->fd,Return); -} + if (!reply.empty()) + user->WriteServ(reply); + return CMD_SUCCESS; +}