1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
24 /* $ModDesc: Provides support for ircu style usermode +d (deaf to channel messages and channel notices) */
26 /** User mode +d - filter out channel messages and channel notices
28 class User_d : public ModeHandler
31 User_d(InspIRCd* Instance) : ModeHandler(Instance, 'd', 0, 0, false, MODETYPE_USER, false) { }
33 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
37 if (!dest->IsModeSet('d'))
39 dest->SetMode('d',true);
40 return MODEACTION_ALLOW;
45 if (dest->IsModeSet('d'))
47 dest->SetMode('d',false);
48 return MODEACTION_ALLOW;
51 return MODEACTION_DENY;
55 class ModuleDeaf : public Module
59 ModuleDeaf(InspIRCd* Me)
62 m1 = new User_d(ServerInstance);
63 ServerInstance->AddMode(m1, 'd');
66 void Implements(char* List)
68 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnBuildExemptList] = 1;
71 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
73 return PreText(user, dest, target_type, text, status, exempt_list);
76 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
78 return PreText(user, dest, target_type, text, status, exempt_list);
81 virtual void OnBuildExemptList(MessageType message_type, chanrec* chan, userrec* sender, char status, CUList &exempt_list)
87 ulist = chan->GetOppedUsers();
90 ulist = chan->GetHalfoppedUsers();
93 ulist = chan->GetVoicedUsers();
96 ulist = chan->GetUsers();
100 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
102 if (IS_LOCAL(i->second))
104 if (i->second->IsModeSet('d'))
106 exempt_list[i->second] = i->second;
112 virtual int PreText(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
114 if (target_type == TYPE_CHANNEL)
116 chanrec* chan = (chanrec*)dest;
119 this->OnBuildExemptList(MSG_PRIVMSG, chan, user, status, exempt_list);
125 virtual ~ModuleDeaf()
127 ServerInstance->Modes->DelMode(m1);
131 virtual Version GetVersion()
133 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
139 class ModuleDeafFactory : public ModuleFactory
150 virtual Module * CreateModule(InspIRCd* Me)
152 return new ModuleDeaf(Me);
158 extern "C" void * init_module( void )
160 return new ModuleDeafFactory;