- ModuleServices()
- {
- Srv = new Server;
-
- 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 void On005Numeric(std::string &output)
- {
- std::stringstream line(output);
- std::string temp1, temp2;
- while (!line.eof())
- {
- line >> temp1;
- if (temp1.substr(0,10) == "CHANMODES=")
- {
- // append the chanmode to the end
- temp1 = temp1.substr(10,temp1.length());
- temp1 = "CHANMODES=" + temp1 + "rRM";
- }
- temp2 = temp2 + temp1 + " ";
- }
- output = temp2.substr(0,temp2.length()-1);
- }
-
- virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
+ Channel_r(Server* srv) : ModeHandler('r', 0, 0, false, MODETYPE_CHANNEL, false), Srv(srv) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
+ {
+ // only a u-lined server may add or remove the +r mode.
+ if ((Srv->IsUlined(source->nick)) || (Srv->IsUlined(source->server)) || (!*source->server || (strchr(source->nick,'.'))))
+ {
+ log(DEBUG,"Allowing cmode +r, server and nick are: '%s','%s'",source->nick,source->server);
+ channel->SetMode('r',adding);
+ return MODEACTION_ALLOW;
+ }
+ else
+ {
+ log(DEBUG,"Only a server can set chanmode +r, server and nick are: '%s','%s'",source->nick,source->server);
+ Srv->SendServ(source->fd,"500 "+std::string(source->nick)+" :Only a server may modify the +r channel mode");
+ return MODEACTION_DENY;
+ }
+ }
+};
+
+class User_r : public ModeHandler
+{
+ Server* Srv;
+ public:
+ User_r(Server* srv) : ModeHandler('r', 0, 0, false, MODETYPE_USER, false), Srv(srv) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)