X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcmd_ison.cpp;h=4ca319afcd21a8a187518c867bbc382501fe58b2;hb=2e28b264afa667923b6c17d88ffcb12315309936;hp=e7256b2a24ea62df346e6f190d1971728b8a53bc;hpb=6b43da7511ca875b64e58b84f72dd89485c0e7fd;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/cmd_ison.cpp b/src/cmd_ison.cpp index e7256b2a2..4ca319afc 100644 --- a/src/cmd_ison.cpp +++ b/src/cmd_ison.cpp @@ -2,58 +2,86 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd is copyright (C) 2002-2006 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) { - char retbuf[MAXBUF]; - userrec *u; + return new cmd_ison(Instance); +} - snprintf(retbuf, MAXBUF, "303 %s :", user->nick); +/** Handle /ISON + */ +CmdResult cmd_ison::Handle (const char** parameters, int pcnt, userrec *user) +{ + std::map ison_already; + userrec *u; + std::string reply = std::string("303 ") + user->nick + " :"; for (int i = 0; i < pcnt; i++) { - u = Find(parameters[i]); + u = ServerInstance->FindNick(parameters[i]); + if (ison_already.find(u) != ison_already.end()) + continue; if (u) { - strlcat(retbuf, u->nick, MAXBUF); - charlcat(retbuf, ' ', 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 (list.GetToken(item)) + { + 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; + } + } + } } } - WriteServ(user->fd, retbuf); -} - + if (!reply.empty()) + user->WriteServ(reply); + return CMD_SUCCESS; +}