* ---------------------------------------------------
*/
-#include <stdio.h>
-#include <sstream>
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
#include "inspircd.h"
/* $ModDesc: Provides support for unreal-style channel mode +c */
public:
BlockColor(InspIRCd* Instance) : ModeHandler(Instance, 'c', 0, 0, false, MODETYPE_CHANNEL, false) { }
- ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
+ ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
{
if (adding)
{
BlockColor *bc;
public:
- ModuleBlockColour(InspIRCd* Me) : Module::Module(Me)
+ ModuleBlockColour(InspIRCd* Me) : Module(Me)
{
bc = new BlockColor(ServerInstance);
- if (!ServerInstance->AddMode(bc, 'c'))
+ if (!ServerInstance->AddMode(bc))
throw ModuleException("Could not add new modes!");
-
- OnRehash(NULL, "");
}
void Implements(char* List)
{
- List[I_OnRehash] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
+ List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
}
- virtual void OnRehash(userrec* user, const std::string ¶meter)
- {
- ConfigReader Conf(ServerInstance);
-
- AllowChanOps = Conf.ReadFlag("blockcolor", "allowchanops", 0);
- }
-
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+ virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
{
- chanrec* c = (chanrec*)dest;
+ Channel* c = (Channel*)dest;
if(c->IsModeSet('c'))
{
- if (!AllowChanOps || AllowChanOps && c->GetStatus(user) != STATUS_OP)
+ if (!CHANOPS_EXEMPT(ServerInstance, 'c') || CHANOPS_EXEMPT(ServerInstance, 'c') && c->GetStatus(user) != STATUS_OP)
{
for (std::string::iterator i = text.begin(); i != text.end(); i++)
{
return 0;
}
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+ virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
}
}
};
-
-class ModuleBlockColourFactory : public ModuleFactory
-{
- public:
- ModuleBlockColourFactory()
- {
- }
-
- ~ModuleBlockColourFactory()
- {
- }
-
- virtual Module * CreateModule(InspIRCd* Me)
- {
- return new ModuleBlockColour(Me);
- }
-
-};
-
-
-extern "C" void * init_module( void )
-{
- return new ModuleBlockColourFactory;
-}
+MODULE_INIT(ModuleBlockColour)