/* $ModDesc: Provides support for unreal-style channel mode +V */
-class NoInvite : public ModeHandler
+class NoInvite : public SimpleChannelModeHandler
{
public:
- NoInvite(InspIRCd* Instance) : ModeHandler(Instance, 'V', 0, 0, false, MODETYPE_CHANNEL, false) { }
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
- {
- if (adding)
- {
- if (!channel->IsModeSet('V'))
- {
- channel->SetMode('V',true);
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (channel->IsModeSet('V'))
- {
- channel->SetMode('V',false);
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
- }
+ NoInvite(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'V') { }
};
class ModuleNoInvite : public Module
ni = new NoInvite(ServerInstance);
if (!ServerInstance->Modes->AddMode(ni))
throw ModuleException("Could not add new modes!");
- Implementation eventlist[] = { I_OnUserPreInvite };
- ServerInstance->Modules->Attach(eventlist, this, 1);
+ Implementation eventlist[] = { I_OnUserPreInvite, I_On005Numeric };
+ ServerInstance->Modules->Attach(eventlist, this, 2);
}
+ virtual void On005Numeric(std::string &output)
+ {
+ ServerInstance->AddExtBanChar('V');
+ }
virtual int OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout)
{
- if (channel->IsModeSet('V'))
+ if (IS_LOCAL(user))
{
- user->WriteServ("492 %s %s :Can't invite %s to channel (+V set)",user->nick, channel->name, dest->nick);
- return 1;
+ if (CHANOPS_EXEMPT(ServerInstance, 'c') && channel->GetStatus(user) == STATUS_OP)
+ {
+ return 0;
+ }
+
+ if (channel->IsModeSet('V') || channel->IsExtBanned(user, 'V'))
+ {
+ user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't invite %s to channel (+V set)",user->nick.c_str(), channel->name.c_str(), dest->nick.c_str());
+ return 1;
+ }
}
+
return 0;
}
ServerInstance->Modes->DelMode(ni);
delete ni;
}
-
+
virtual Version GetVersion()
{
- return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
+ return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
}
};