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 * ---------------------------------------------------
25 /* $ModDesc: Restricts banned users in a channel. May not speak, etc. */
27 class ModuleRestrictBanned : public Module
31 ModuleRestrictBanned(InspIRCd* Me) : Module::Module(Me)
35 virtual ~ModuleRestrictBanned()
39 virtual Version GetVersion()
41 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
44 void Implements(char* List)
46 List[I_OnLocalTopicChange] = List[I_OnUserPreNick] = List[I_OnUserPreNotice] = List[I_OnUserPreMessage] = 1;
49 int CheckRestricted(userrec *user, chanrec *channel, const std::string &action)
51 /* aren't local? we don't care. */
55 if (channel->IsBanned(user) && channel->GetStatus(user) < STATUS_VOICE)
57 /* banned, boned. drop the message. */
58 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** You may not " + action + ", as you are banned on channel " + channel->name);
65 virtual int OnUserPreNick(userrec *user, const std::string &newnick)
67 /* if they aren't local, we don't care */
71 /* bit of a special case. */
72 for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
74 if (CheckRestricted(user, i->first, "change your nickname") == 1)
81 virtual int OnLocalTopicChange(userrec *user, chanrec *channel, const std::string &topic)
83 return CheckRestricted(user, channel, "change the topic");
86 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
88 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
91 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
93 if (target_type == TYPE_CHANNEL)
95 chanrec *channel = (chanrec *)dest;
97 return CheckRestricted(user, channel, "message the channel");
105 class ModuleRestrictBannedFactory : public ModuleFactory
108 ModuleRestrictBannedFactory()
112 ~ModuleRestrictBannedFactory()
116 virtual Module * CreateModule(InspIRCd* Me)
118 return new ModuleRestrictBanned(Me);
124 extern "C" void * init_module( void )
126 return new ModuleRestrictBannedFactory;