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 * ---------------------------------------------------
24 /* $ModDesc: Povides support for services +r user/chan modes and more */
26 class ModuleServices : public Module
34 Srv->AddExtendedMode('r',MT_CHANNEL,false,0,0);
35 Srv->AddExtendedMode('r',MT_CLIENT,false,0,0);
36 Srv->AddExtendedMode('R',MT_CHANNEL,false,0,0);
37 Srv->AddExtendedMode('R',MT_CLIENT,false,0,0);
38 Srv->AddExtendedMode('M',MT_CHANNEL,false,0,0);
41 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
46 if (type == MT_CHANNEL)
48 // only a u-lined server may add or remove the +r mode.
49 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
55 Srv->SendServ(user->fd,"500 "+std::string(user->nick)+" :Only a U-Lined server may modify the +r channel mode");
60 if (!strcmp(user->server,""))
66 Srv->SendServ(user->fd,"500 "+std::string(user->nick)+" :Only a server may modify the +r user mode");
70 else if (modechar == 'R')
72 if (type == MT_CHANNEL)
77 else if (modechar == 'M')
79 if (type == MT_CHANNEL)
88 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string text)
90 if (target_type == TYPE_CHANNEL)
92 chanrec* c = (chanrec*)dest;
93 if ((c->IsCustomModeSet('M')) && (!strchr(user->modes,'r')))
95 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
97 // user is ulined, can speak regardless
100 // user messaging a +M channel and is not registered
101 Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(c->name)+" :You need a registered nickname to speak on this channel");
105 if (target_type == TYPE_USER)
107 userrec* u = (userrec*)dest;
108 if ((strchr(u->modes,'R')) && (!strchr(user->modes,'r')))
110 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
112 // user is ulined, can speak regardless
115 // user messaging a +R user and is not registered
116 Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(u->nick)+" :You need a registered nickname to message this user");
123 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text)
125 if (target_type == TYPE_CHANNEL)
127 chanrec* c = (chanrec*)dest;
128 if ((c->IsCustomModeSet('M')) && (!strchr(user->modes,'r')))
130 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
132 // user is ulined, can speak regardless
135 // user noticing a +M channel and is not registered
136 Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(c->name)+" :You need a registered nickname to speak on this channel");
140 if (target_type == TYPE_USER)
142 userrec* u = (userrec*)dest;
143 if ((strchr(u->modes,'R')) && (!strchr(user->modes,'r')))
145 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
147 // user is ulined, can speak regardless
150 // user noticing a +R user and is not registered
151 Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(u->nick)+" :You need a registered nickname to message this user");
158 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
162 if (chan->IsCustomModeSet('R'))
164 if (!strchr(user->modes,'r'))
166 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
168 // user is ulined, won't be stopped from joining
171 // joining a +R channel and not identified
172 Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(chan->name)+" :You need a registered nickname to join this channel");
180 virtual ~ModuleServices()
185 virtual Version GetVersion()
187 return Version(1,0,0,0);
190 virtual void OnUserConnect(userrec* user)
197 class ModuleServicesFactory : public ModuleFactory
200 ModuleServicesFactory()
204 ~ModuleServicesFactory()
208 virtual Module * CreateModule()
210 return new ModuleServices;
216 extern "C" void * init_module( void )
218 return new ModuleServicesFactory;