1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides the /TAXONOMY command, used to view all metadata attached to a user */
20 class cmd_taxonomy : public Command
25 /* Command 'taxonomy', takes no parameters and needs no special modes */
26 cmd_taxonomy (InspIRCd* Instance, Module* maker, bool &claim) : Command(Instance,"TAXONOMY", 'o', 1), Creator(maker), claimed(claim)
28 this->source = "m_taxonomy.so";
29 syntax = "<nickname>";
32 CmdResult Handle (const char** parameters, int pcnt, User *user)
34 User* dest = ServerInstance->FindNick(parameters[0]);
37 std::deque<std::string> list;
39 user->GetExtList(list);
40 user->WriteServ("304 " + std::string(user->nick) + ":TAXONOMY ITEMS " + std::string(dest->nick) + " " +ConvToStr(list.size()));
41 for (unsigned int j = 0; j < list.size(); j++)
44 FOREACH_MOD(I_OnSyncUserMetaData, OnSyncUserMetaData(user, Creator, dest, list[j], true));
47 user->WriteServ("304 " + std::string(user->nick) + ":TAXONOMY METADATA " + list[j] + " = <unknown>");
50 user->WriteServ("304 " + std::string(user->nick) + ":TAXONOMY END");
56 class ModuleTaxonomy : public Module
58 cmd_taxonomy* newcommand;
61 ModuleTaxonomy(InspIRCd* Me)
65 // Create a new command
66 newcommand = new cmd_taxonomy(ServerInstance, this, claimed);
67 ServerInstance->AddCommand(newcommand);
70 void Implements(char* List)
72 List[I_ProtoSendMetaData] = 1;
75 void ProtoSendMetaData(void* opaque, int target_type, void* target, const std::string &extname, const std::string &extdata)
77 if (target_type == TYPE_USER)
79 User* spool = (User*)opaque;
80 std::string taxstr = "304 " + std::string(spool->nick) + ":TAXONOMY METADATA "+extname+" = "+extdata;
81 spool->WriteServ(taxstr);
86 virtual ~ModuleTaxonomy()
90 virtual Version GetVersion()
92 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
96 MODULE_INIT(ModuleTaxonomy)