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 (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++)
74 if (((ucrec*)(*i))->channel != NULL)
76 chanrec *channel = ((ucrec*)(*i))->channel;
78 if (CheckRestricted(user, channel, "change your nickname") == 1)
86 virtual int OnLocalTopicChange(userrec *user, chanrec *channel, const std::string &topic)
88 return CheckRestricted(user, channel, "change the topic");
91 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
93 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
96 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
98 if (target_type == TYPE_CHANNEL)
100 chanrec *channel = (chanrec *)dest;
102 return CheckRestricted(user, channel, "message the channel");
110 class ModuleRestrictBannedFactory : public ModuleFactory
113 ModuleRestrictBannedFactory()
117 ~ModuleRestrictBannedFactory()
121 virtual Module * CreateModule(InspIRCd* Me)
123 return new ModuleRestrictBanned(Me);
129 extern "C" void * init_module( void )
131 return new ModuleRestrictBannedFactory;