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 * ---------------------------------------------------
16 /* $ModDesc: Restricts banned users in a channel. May not speak, etc. */
18 class ModuleRestrictBanned : public Module
22 ModuleRestrictBanned(InspIRCd* Me) : Module(Me)
26 virtual ~ModuleRestrictBanned()
30 virtual Version GetVersion()
32 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
35 void Implements(char* List)
37 List[I_OnLocalTopicChange] = List[I_OnUserPreNick] = List[I_OnUserPreNotice] = List[I_OnUserPreMessage] = 1;
40 int CheckRestricted(User *user, Channel *channel, const std::string &action)
42 /* aren't local? we don't care. */
46 if (channel->GetStatus(user) < STATUS_VOICE && channel->IsBanned(user))
48 /* banned, boned. drop the message. */
49 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** You may not " + action + ", as you are banned on channel " + channel->name);
56 virtual int OnUserPreNick(User *user, const std::string &newnick)
58 /* if they aren't local, we don't care */
62 /* Allow changes to UID */
63 if (isdigit(newnick[0]))
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(User *user, Channel *channel, const std::string &topic)
78 return CheckRestricted(user, channel, "change the topic");
81 virtual int OnUserPreMessage(User* 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(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
88 if (target_type == TYPE_CHANNEL)
90 Channel *channel = (Channel *)dest;
92 return CheckRestricted(user, channel, "message the channel");
99 MODULE_INIT(ModuleRestrictBanned)