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()
61 /* don't ask why this is here. */
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 */
90 /* full form to add a CBAN */
91 /* XXX - checking on chnames */
92 chname = parameters[0];
93 expiry = TIME + Srv->CalcDuration(parameters[1]);
94 reason = parameters[2];
96 CBan meow(chname, reason, expiry);
97 cbans.push_back(meow);
102 class ModuleCBan : public Module
108 ModuleCBan(Server* Me) : Module::Module(Me)
111 mycommand = new cmd_cban(Srv);
112 Srv->AddCommand(mycommand);
115 virtual int OnUserPreJoin(userrec *user, chanrec *chan, const char *cname)
117 /* check cbans in here, and apply as necessary. */
118 log(DEBUG,"In OnUserPreJoin cbans.size() == %d",cbans.size());
120 std::string chname = cname;
122 for (unsigned int a = 0; a < cbans.size(); a++)
124 log(DEBUG,"m_cban: DEBUG: checking %s against %s in OnPreUserJoin()", chname.c_str(), cbans[a].GetName().c_str());
125 if (chname == cbans[a].GetName())
128 WriteOpers("DENY join");
133 log(DEBUG,"DONE checking, allowed");
135 /* Allow the change. */
139 virtual ~ModuleCBan()
143 virtual Version GetVersion()
145 return Version(1,0,0,0,VF_VENDOR);
150 class ModuleCBanFactory : public ModuleFactory
161 virtual Module * CreateModule(Server* Me)
163 return new ModuleCBan(Me);
169 extern "C" void * init_module( void )
171 return new ModuleCBanFactory;