1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
20 /* $ModDesc: Restricts banned users in a channel. May not speak, etc. */
22 class ModuleRestrictBanned : public Module
26 ModuleRestrictBanned(InspIRCd* Me) : Module::Module(Me)
30 virtual ~ModuleRestrictBanned()
34 virtual Version GetVersion()
36 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
39 void Implements(char* List)
41 List[I_OnLocalTopicChange] = List[I_OnUserPreNick] = List[I_OnUserPreNotice] = List[I_OnUserPreMessage] = 1;
44 int CheckRestricted(userrec *user, chanrec *channel, const std::string &action)
46 /* aren't local? we don't care. */
50 if (channel->IsBanned(user) && channel->GetStatus(user) < STATUS_VOICE)
52 /* banned, boned. drop the message. */
53 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** You may not " + action + ", as you are banned on channel " + channel->name);
60 virtual int OnUserPreNick(userrec *user, const std::string &newnick)
62 /* if they aren't local, we don't care */
66 /* bit of a special case. */
67 for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
69 if (CheckRestricted(user, i->first, "change your nickname") == 1)
76 virtual int OnLocalTopicChange(userrec *user, chanrec *channel, const std::string &topic)
78 return CheckRestricted(user, channel, "change the topic");
81 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
83 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
86 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
88 if (target_type == TYPE_CHANNEL)
90 chanrec *channel = (chanrec *)dest;
92 return CheckRestricted(user, channel, "message the channel");
100 class ModuleRestrictBannedFactory : public ModuleFactory
103 ModuleRestrictBannedFactory()
107 ~ModuleRestrictBannedFactory()
111 virtual Module * CreateModule(InspIRCd* Me)
113 return new ModuleRestrictBanned(Me);
119 extern "C" void * init_module( void )
121 return new ModuleRestrictBannedFactory;