diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-05-08 17:42:35 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-05-08 17:42:35 +0000 |
commit | 7db4aae14db7917133beb70f5513a6cc73647432 (patch) | |
tree | 8ed2280ceb370d623025dd93c30d016ee6ac39ac /src/modules/m_services.cpp | |
parent | 5b949866d429203ae48f2088e4f97592755592c6 (diff) |
Added user/chanel modes +R, +M
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@797 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_services.cpp')
-rw-r--r-- | src/modules/m_services.cpp | 136 |
1 files changed, 122 insertions, 14 deletions
diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp index 39cd55d6b..4202da2d0 100644 --- a/src/modules/m_services.cpp +++ b/src/modules/m_services.cpp @@ -20,42 +20,150 @@ class ModuleServices : public Module Srv->AddExtendedMode('r',MT_CHANNEL,false,0,0); Srv->AddExtendedMode('r',MT_CLIENT,false,0,0); + Srv->AddExtendedMode('R',MT_CHANNEL,false,0,0); + Srv->AddExtendedMode('R',MT_CLIENT,false,0,0); + Srv->AddExtendedMode('M',MT_CHANNEL,false,0,0); } virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms) { - if (modechar != 'r') { - return 0; + if (modechar == 'r') + { + if (type == MT_CHANNEL) + { + // only a u-lined server may add or remove the +r mode. + if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server))) + { + return 1; + } + else + { + Srv->SendServ(user->fd,"500 "+std::string(user->nick)+" :Only a U-Lined server may modify the +r channel mode"); + } + } + else + { + if (!strcmp(user->server,"")) + { + return 1; + } + else + { + Srv->SendServ(user->fd,"500 "+std::string(user->nick)+" :Only a server may modify the +r user mode"); + } + } } - - if (type == MT_CHANNEL) + else if (modechar == 'R') { - // only a u-lined server may add or remove the +r mode. - if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server))) + if (type == MT_CHANNEL) { return 1; } - else + } + else if (modechar == 'M') + { + if (type == MT_CHANNEL) { - Srv->SendServ(user->fd,"500 "+std::string(user->nick)+" :Only a U-Lined server may modify the +r channel mode"); + return 1; } } - else + + return 0; + } + + virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string text) + { + if (target_type == TYPE_CHANNEL) { - if (!strcmp(user->server,"")) + chanrec* c = (chanrec*)dest; + if ((c->IsCustomModeSet('M')) && (!strchr(user->modes,'r'))) { + if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server))) + { + // user is ulined, can speak regardless + return 0; + } + // user messaging a +M channel and is not registered + Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(c->name)+" :You need a registered nickname to speak on this channel"); return 1; } - else + } + if (target_type == TYPE_USER) + { + userrec* u = (userrec*)dest; + if ((strchr(u->modes,'R')) && (!strchr(user->modes,'r'))) { - Srv->SendServ(user->fd,"500 "+std::string(user->nick)+" :Only a server may modify the +r user mode"); + if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server))) + { + // user is ulined, can speak regardless + return 0; + } + // user messaging a +R user and is not registered + Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(u->nick)+" :You need a registered nickname to message this user"); + return 1; } } - return 0; } - + + virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text) + { + if (target_type == TYPE_CHANNEL) + { + chanrec* c = (chanrec*)dest; + if ((c->IsCustomModeSet('M')) && (!strchr(user->modes,'r'))) + { + if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server))) + { + // user is ulined, can speak regardless + return 0; + } + // user noticing a +M channel and is not registered + Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(c->name)+" :You need a registered nickname to speak on this channel"); + return 1; + } + } + if (target_type == TYPE_USER) + { + userrec* u = (userrec*)dest; + if ((strchr(u->modes,'R')) && (!strchr(user->modes,'r'))) + { + if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server))) + { + // user is ulined, can speak regardless + return 0; + } + // user noticing a +R user and is not registered + Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(u->nick)+" :You need a registered nickname to message this user"); + return 1; + } + } + return 0; + } + + virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) + { + if (chan) + { + if (chan->IsCustomModeSet('R')) + { + if (!strchr(user->modes,'r')) + { + if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server))) + { + // user is ulined, won't be stopped from joining + return 0; + } + // joining a +R channel and not identified + Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(c->name)+" :You need a registered nickname to join this channel"); + return 1; + } + } + } + return 0; + } + virtual ~ModuleServices() { delete Srv; |