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 * ---------------------------------------------------
19 /* $ModDesc: Restricts banned users in a channel. May not speak, etc. */
21 class ModuleRestrictBanned : public Module
25 ModuleRestrictBanned(InspIRCd* Me) : Module(Me)
29 virtual ~ModuleRestrictBanned()
33 virtual Version GetVersion()
35 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
38 void Implements(char* List)
40 List[I_OnLocalTopicChange] = List[I_OnUserPreNick] = List[I_OnUserPreNotice] = List[I_OnUserPreMessage] = 1;
43 int CheckRestricted(userrec *user, chanrec *channel, const std::string &action)
45 /* aren't local? we don't care. */
49 if (channel->GetStatus(user) < STATUS_VOICE && channel->IsBanned(user))
51 /* banned, boned. drop the message. */
52 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** You may not " + action + ", as you are banned on channel " + channel->name);
59 virtual int OnUserPreNick(userrec *user, const std::string &newnick)
61 /* if they aren't local, we don't care */
65 /* bit of a special case. */
66 for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
68 if (CheckRestricted(user, i->first, "change your nickname") == 1)
75 virtual int OnLocalTopicChange(userrec *user, chanrec *channel, const std::string &topic)
77 return CheckRestricted(user, channel, "change the topic");
80 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
82 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
85 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
87 if (target_type == TYPE_CHANNEL)
89 chanrec *channel = (chanrec *)dest;
91 return CheckRestricted(user, channel, "message the channel");
98 MODULE_INIT(ModuleRestrictBanned)