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. */
38 CBan(std::string chname, std::string reason, unsigned long expiry)
48 std::string GetReason()
53 unsigned long GetExpiry()
60 /* don't ask why this is here. */
62 class cmd_cban : public command_t
68 cmd_cban () : command_t("CBAN", 'o', 1)
70 this->source = "m_cban.so";
73 void Handle(char **parameters, int pcnt, userrec *user)
75 /* syntax: CBAN #channel time :reason goes here */
76 /* 'time' is a human-readable timestring, like 2d3h2s. */
84 /* form: CBAN #channel removes a CBAN */
88 /* full form to add a CBAN */
89 /* XXX - checking on chnames */
90 chname = parameters[0];
91 expiry = TIME + Srv->CalcDuration(parameters[1]);
92 reason = parameters[2];
94 CBan meow(chname, reason, expiry);
95 cbans.push_back(meow);
100 class ModuleCBan : public Module
105 ModuleCBan(Server* Me) : Module::Module(Me)
108 mycommand = new cmd_cban();
109 Srv->AddCommand(mycommand);
112 virtual int OnUserPreJoin (userrec *user, chanrec *chan, const char *cname)
114 /* check cbans in here, and apply as necessary. */
116 std::string chname = cname;
118 for (unsigned int a = 0; a < cbans.size(); a++)
120 if (chname == cbans[a].GetName())
127 /* Allow the change. */
131 virtual ~ModuleCBan()
135 virtual Version GetVersion()
137 return Version(1,0,0,0,VF_VENDOR);
142 class ModuleCBanFactory : public ModuleFactory
153 virtual Module * CreateModule(Server* Me)
155 return new ModuleCBan(Me);
161 extern "C" void * init_module( void )
163 return new ModuleCBanFactory;