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 * ---------------------------------------------------
17 /* NO, THIS MODULE DOES NOT SPY ON CHANNELS OR USERS.
18 * IT JUST ALLOWS OPERS TO SEE +s CHANNELS IN LIST AND
19 * WHOIS, WHICH IS SUPPORTED BY MOST IRCDS IN CORE.
24 /* $ModDesc: Provides SPYLIST and SPYNAMES capability, allowing opers to see who's in +s channels */
26 #include "inspircd_config.h"
33 void spy_userlist(userrec *user,chanrec *c)
35 static char list[MAXBUF];
40 snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
42 CUList *ulist= c->GetUsers();
43 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
45 strlcat(list,c->GetPrefixChar(i->second),MAXBUF);
46 strlcat(list,i->second->nick,MAXBUF);
47 strlcat(list," ",MAXBUF);
48 if (strlen(list)>(480-NICKMAX))
50 /* list overflowed into
51 * multiple numerics */
52 user->WriteServ(std::string(list));
53 snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
56 /* if whats left in the list isnt empty, send it */
57 if (list[strlen(list)-1] != ':')
59 user->WriteServ(std::string(list));
65 class cmd_spylist : public command_t
68 cmd_spylist (InspIRCd* Instance) : command_t(Instance,"SPYLIST", 'o', 0)
70 this->source = "m_spy.so";
74 void Handle (const char** parameters, int pcnt, userrec *user)
76 ServerInstance->WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick);
77 user->WriteServ("321 %s Channel :Users Name",user->nick);
78 for (chan_hash::const_iterator i = ServerInstance->chanlist.begin(); i != ServerInstance->chanlist.end(); i++)
80 if (pcnt && !match(i->second->name, parameters[0]))
82 user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,i->second->GetUserCounter(),i->second->ChanModes(true),i->second->topic);
84 user->WriteServ("323 %s :End of channel list.",user->nick);
88 class cmd_spynames : public command_t
91 cmd_spynames (InspIRCd* Instance) : command_t(Instance,"SPYNAMES", 'o', 0)
93 this->source = "m_spy.so";
94 syntax = "{<channel>{,<channel>}}";
97 void Handle (const char** parameters, int pcnt, userrec *user)
103 user->WriteServ("366 %s * :End of /NAMES list.",user->nick);
107 if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 1))
110 ServerInstance->WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]);
112 c = ServerInstance->FindChan(parameters[0]);
115 spy_userlist(user,c);
116 user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, c->name);
120 user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
125 class ModuleSpy : public Module
127 cmd_spylist *mycommand;
128 cmd_spynames *mycommand2;
130 ModuleSpy(InspIRCd* Me) : Module::Module(Me)
133 mycommand = new cmd_spylist(ServerInstance);
134 mycommand2 = new cmd_spynames(ServerInstance);
135 ServerInstance->AddCommand(mycommand);
136 ServerInstance->AddCommand(mycommand2);
143 virtual Version GetVersion()
145 return Version(1, 0, 0, 0, VF_VENDOR);
150 class ModuleSpyFactory : public ModuleFactory
161 virtual Module * CreateModule(InspIRCd* Me)
163 return new ModuleSpy(Me);
169 extern "C" void * init_module( void )
171 return new ModuleSpyFactory;