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 * ---------------------------------------------------
23 #include "helperfuncs.h"
25 /* $ModDesc: Gives /cban, aka C:lines. Think Q:lines, for channels. */
37 CBan(std::string cn, std::string rs, unsigned long ex)
49 std::string GetReason()
54 unsigned long GetExpiry()
60 /* cbans is declared here, as our type is right above. Don't try move it. */
63 class cmd_cban : public command_t
69 cmd_cban (Server* Me) : command_t("CBAN", 'o', 1)
71 this->source = "m_cban.so";
75 void Handle(char **parameters, int pcnt, userrec *user)
77 /* syntax: CBAN #channel time :reason goes here */
78 /* 'time' is a human-readable timestring, like 2d3h2s. */
86 /* form: CBAN #channel removes a CBAN */
87 for (vector<CBan>::iterator myiter; myiter < cbans.end(); myiter++)
89 if (parameters[0] == (*myiter).GetName())
98 /* full form to add a CBAN */
99 /* XXX - checking on chnames */
100 chname = parameters[0];
101 expiry = TIME + Srv->CalcDuration(parameters[1]);
102 reason = parameters[2];
104 CBan meow(chname, reason, expiry);
105 cbans.push_back(meow);
110 class ModuleCBan : public Module
116 ModuleCBan(Server* Me) : Module::Module(Me)
119 mycommand = new cmd_cban(Srv);
120 Srv->AddCommand(mycommand);
123 void Implements(char* List)
125 List[I_OnUserPreJoin] = 1;
128 virtual int OnUserPreJoin(userrec *user, chanrec *chan, const char *cname)
130 /* check cbans in here, and apply as necessary. */
131 log(DEBUG,"In OnUserPreJoin cbans.size() == %d",cbans.size());
133 std::string chname = cname;
135 for (unsigned int a = 0; a < cbans.size(); a++)
137 log(DEBUG,"m_cban: DEBUG: checking %s against %s in OnPreUserJoin()", chname.c_str(), cbans[a].GetName().c_str());
138 if (chname == cbans[a].GetName())
141 WriteOpers("DENY join");
146 log(DEBUG,"DONE checking, allowed");
148 /* Allow the change. */
152 virtual ~ModuleCBan()
156 virtual Version GetVersion()
158 return Version(1,0,0,0,VF_VENDOR);
163 class ModuleCBanFactory : public ModuleFactory
174 virtual Module * CreateModule(Server* Me)
176 return new ModuleCBan(Me);
182 extern "C" void * init_module( void )
184 return new ModuleCBanFactory;