1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 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: Provides support for unreal-style channel mode +c */
27 class ModuleNoCTCP : public Module
36 Srv->AddExtendedMode('C',MT_CHANNEL,false,0,0);
39 virtual void On005Numeric(std::string &output)
41 std::stringstream line(output);
42 std::string temp1, temp2;
46 if (temp1.substr(0,10) == "CHANMODES=")
48 // append the chanmode to the end
49 temp1 = temp1.substr(10,temp1.length());
50 temp1 = "CHANMODES=" + temp1 + "C";
52 temp2 = temp2 + temp1 + " ";
55 output = temp2.substr(0,temp2.length()-1);
58 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
60 if (target_type == TYPE_CHANNEL)
62 chanrec* c = (chanrec*)dest;
63 if (c->IsCustomModeSet('C'))
65 if ((text.length()) && (text[0] == '\1'))
67 if (strncmp(text.c_str(),"\1ACTION ",8))
69 WriteServ(user->fd,"492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
78 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
80 if (target_type == TYPE_CHANNEL)
82 chanrec* c = (chanrec*)dest;
83 if (c->IsCustomModeSet('C'))
85 if ((text.length()) && (text[0] == '\1'))
87 if (strncmp(text.c_str(),"\1ACTION ",8))
89 WriteServ(user->fd,"492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
98 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
100 // check if this is our mode character...
101 if ((modechar == 'C') && (type == MT_CHANNEL))
103 log(DEBUG,"Allowing C change");
112 virtual ~ModuleNoCTCP()
117 virtual Version GetVersion()
119 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
124 class ModuleNoCTCPFactory : public ModuleFactory
127 ModuleNoCTCPFactory()
131 ~ModuleNoCTCPFactory()
135 virtual Module * CreateModule()
137 return new ModuleNoCTCP;
143 extern "C" void * init_module( void )
145 return new ModuleNoCTCPFactory;