1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2005 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 virtual int OnUserPreJoin(userrec *user, chanrec *chan, const char *cname)
125 /* check cbans in here, and apply as necessary. */
126 log(DEBUG,"In OnUserPreJoin cbans.size() == %d",cbans.size());
128 std::string chname = cname;
130 for (unsigned int a = 0; a < cbans.size(); a++)
132 log(DEBUG,"m_cban: DEBUG: checking %s against %s in OnPreUserJoin()", chname.c_str(), cbans[a].GetName().c_str());
133 if (chname == cbans[a].GetName())
136 WriteOpers("DENY join");
141 log(DEBUG,"DONE checking, allowed");
143 /* Allow the change. */
147 virtual ~ModuleCBan()
151 virtual Version GetVersion()
153 return Version(1,0,0,0,VF_VENDOR);
158 class ModuleCBanFactory : public ModuleFactory
169 virtual Module * CreateModule(Server* Me)
171 return new ModuleCBan(Me);
177 extern "C" void * init_module( void )
179 return new ModuleCBanFactory;