- std::string line = "";
- for (int i = 1; i < pcnt; i++)
- {
- if (i != 1)
- line = line + " ";
- line = line + std::string(parameters[i]);
- }
- char* field = dest->GetExt("swhois");
- if (field)
- {
- std::string* text = (std::string*)field;
- dest->Shrink("swhois");
- delete text;
- }
- std::string* text = new std::string(line);
- dest->Extend("swhois",(char*)text);
+ user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
+ return CMD_FAILURE;
+ }
+
+ std::string* text;
+ if (dest->GetExt("swhois", text))
+ {
+ // We already had it set...
+ if (!ServerInstance->ULine(user->server))
+ // Ulines set SWHOISes silently
+ ServerInstance->SNO->WriteToSnoMask('A', "%s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick.c_str(), dest->nick.c_str(), text->c_str(), parameters[1].c_str());
+
+ dest->Shrink("swhois");
+ delete text;
+ }
+ else if (!ServerInstance->ULine(user->server))
+ {
+ // Ulines set SWHOISes silently
+ ServerInstance->SNO->WriteToSnoMask('A', "%s used SWHOIS to set %s's extra whois to '%s'", user->nick.c_str(), dest->nick.c_str(), parameters[1].c_str());
+ }
+
+ text = new std::string(parameters[1]);
+ dest->Extend("swhois", text);
+
+ /* Bug #376 - feature request -
+ * To cut down on the amount of commands services etc have to recognise, this only sends METADATA across the network now
+ * not an actual SWHOIS command. Any SWHOIS command sent from services will be automatically translated to METADATA by this.
+ * Sorry w00t i know this was your fix, but i got bored and wanted to clear down the tracker :)
+ * -- Brain
+ */
+ ServerInstance->PI->SendMetaData(dest, TYPE_USER, "swhois", *text);
+
+ // If it's an empty swhois, unset it (not ideal, but ok)
+ if (text->empty())
+ {
+ dest->Shrink("swhois");
+ delete text;