summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/InspIRCd.layout30
-rw-r--r--src/modules/m_services.cpp136
2 files changed, 137 insertions, 29 deletions
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout
index 08ae870b7..031b101b5 100644
--- a/src/InspIRCd.layout
+++ b/src/InspIRCd.layout
@@ -253,9 +253,9 @@ LeftChar=1
[Editor_32]
Open=1
Top=0
-CursorCol=1
-CursorRow=1
-TopLine=1
+CursorCol=3
+CursorRow=50
+TopLine=52
LeftChar=1
[Editor_33]
Open=1
@@ -357,10 +357,10 @@ TopLine=1
LeftChar=1
[Editor_47]
Open=1
-Top=0
-CursorCol=1
-CursorRow=35
-TopLine=10
+Top=1
+CursorCol=138
+CursorRow=103
+TopLine=96
LeftChar=1
[Editor_48]
Open=1
@@ -381,7 +381,7 @@ Open=1
Top=0
CursorCol=1
CursorRow=211
-TopLine=179
+TopLine=203
LeftChar=1
[Editor_51]
Open=1
@@ -400,14 +400,14 @@ LeftChar=1
[Editor_53]
Open=1
Top=0
-CursorCol=17
-CursorRow=28
-TopLine=10
+CursorCol=1
+CursorRow=58
+TopLine=16
LeftChar=1
[Editor_54]
Open=1
-Top=1
-CursorCol=50
-CursorRow=20
-TopLine=14
+Top=0
+CursorCol=1
+CursorRow=29
+TopLine=2
LeftChar=1
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 &params)
{
- 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;