1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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)
24 Implementation eventlist[] = { I_OnLocalTopicChange, I_OnUserPreNick, I_OnUserPreNotice, I_OnUserPreMessage };
25 ServerInstance->Modules->Attach(eventlist, this, 4);
28 virtual ~ModuleRestrictBanned()
32 virtual Version GetVersion()
34 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
38 int CheckRestricted(User *user, Channel *channel, const std::string &action)
40 /* aren't local? we don't care. */
44 if (channel->GetStatus(user) < STATUS_VOICE && channel->IsBanned(user))
46 /* banned, boned. drop the message. */
47 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** You may not " + action + ", as you are banned on channel " + channel->name);
54 virtual int OnUserPreNick(User *user, const std::string &newnick)
56 /* if they aren't local, we don't care */
60 /* Allow changes to UID */
61 if (isdigit(newnick[0]))
64 /* bit of a special case. */
65 for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
67 if (CheckRestricted(user, i->first, "change your nickname") == 1)
74 virtual int OnLocalTopicChange(User *user, Channel *channel, const std::string &topic)
76 return CheckRestricted(user, channel, "change the topic");
79 virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
81 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
84 virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
86 if (target_type == TYPE_CHANNEL)
88 Channel *channel = (Channel *)dest;
90 return CheckRestricted(user, channel, "message the channel");
97 MODULE_INIT(ModuleRestrictBanned)