1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 *the file COPYING for details.
14 * ---------------------------------------------------
24 static const char* dummy = "ON";
26 /* $ModDesc: Provides aliases of commands. */
28 class ModuleNamesX : public Module
32 ModuleNamesX(InspIRCd* Me)
37 void Implements(char* List)
39 List[I_OnPreCommand] = List[I_OnUserList] = List[I_On005Numeric] = 1;
42 virtual ~ModuleNamesX()
46 virtual Version GetVersion()
48 return Version(1,0,0,1,VF_VENDOR,API_VERSION);
51 virtual void On005Numeric(std::string &output)
53 output.append(" NAMESX");
56 virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
58 irc::string c = command.c_str();
59 /* We don't actually create a proper command handler class for PROTOCTL,
60 * because other modules might want to have PROTOCTL hooks too.
61 * Therefore, we just hook its as an unvalidated command therefore we
62 * can capture it even if it doesnt exist! :-)
66 if ((pcnt) && (!strcasecmp(parameters[0],"NAMESX")))
68 user->Extend("NAMESX",dummy);
75 virtual int OnUserList(userrec* user, chanrec* Ptr)
77 if (user->GetExt("NAMESX"))
81 dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, Ptr->name);
83 char* ptr = list + dlen;
84 CUList *ulist= Ptr->GetUsers();
85 bool has_user = Ptr->HasUser(user);
86 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
88 if ((!has_user) && (i->second->modes[UM_INVISIBLE]))
92 size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", Ptr->GetAllPrefixChars(i->second), i->second->nick);
96 if (curlen > (480-NICKMAX))
98 /* list overflowed into multiple numerics */
99 user->WriteServ(std::string(list));
100 /* reset our lengths */
101 dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, Ptr->name);
107 /* if whats left in the list isnt empty, send it */
110 user->WriteServ(std::string(list));
112 user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, Ptr->name);
120 class ModuleNamesXFactory : public ModuleFactory
123 ModuleNamesXFactory()
127 ~ModuleNamesXFactory()
131 virtual Module * CreateModule(InspIRCd* Me)
133 return new ModuleNamesX(Me);
138 extern "C" void * init_module( void )
140 return new ModuleNamesXFactory;