1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Allows for auditorium channels (+u) where nobody can see others joining and parting or the nick list */
18 class AuditoriumMode : public ModeHandler
21 AuditoriumMode(Module* Creator) : ModeHandler(Creator, "auditorium", 'u', PARAM_NONE, MODETYPE_CHANNEL)
23 levelrequired = OP_VALUE;
26 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
28 if (channel->IsModeSet(this) == adding)
29 return MODEACTION_DENY;
30 channel->SetMode(this, adding);
31 return MODEACTION_ALLOW;
35 class ModuleAuditorium : public Module
43 ModuleAuditorium() : aum(this)
49 ServerInstance->Modules->AddService(aum);
53 Implementation eventlist[] = {
54 I_OnUserJoin, I_OnUserPart, I_OnUserKick,
55 I_OnBuildNeighborList, I_OnNamesListItem, I_OnSendWhoLine,
57 ServerInstance->Modules->Attach(eventlist, this, 7);
64 void OnRehash(User* user)
66 ConfigTag* tag = ServerInstance->Config->ConfValue("auditorium");
67 OpsVisible = tag->getBool("opvisible");
68 OpsCanSee = tag->getBool("opcansee");
69 OperCanSee = tag->getBool("opercansee", true);
74 return Version("Allows for auditorium channels (+u) where nobody can see others joining and parting or the nick list", VF_VENDOR);
77 /* Can they be seen by everyone? */
78 bool IsVisible(Membership* memb)
80 if (!memb->chan->IsModeSet(&aum))
83 ModResult res = ServerInstance->OnCheckExemption(memb->user, memb->chan, "auditorium-vis");
84 return res.check(OpsVisible && memb->getRank() >= OP_VALUE);
87 /* Can they see this specific membership? */
88 bool CanSee(User* issuer, Membership* memb)
90 // If user is oper and operoverride is on, don't touch the list
91 if (OperCanSee && issuer->HasPrivPermission("channels/auspex"))
94 // You can always see yourself
95 if (issuer == memb->user)
98 // Can you see the list by permission?
99 ModResult res = ServerInstance->OnCheckExemption(issuer,memb->chan,"auditorium-see");
100 if (res.check(OpsCanSee && memb->chan->GetPrefixValue(issuer) >= OP_VALUE))
106 void OnNamesListItem(User* issuer, Membership* memb, std::string &prefixes, std::string &nick)
108 // Some module already hid this from being displayed, don't bother
115 if (CanSee(issuer, memb))
121 /** Build CUList for showing this join/part/kick */
122 void BuildExcept(Membership* memb, CUList& excepts)
127 const UserMembList* users = memb->chan->GetUsers();
128 for(UserMembCIter i = users->begin(); i != users->end(); i++)
130 if (IS_LOCAL(i->first) && !CanSee(i->first, memb))
131 excepts.insert(i->first);
135 void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts)
137 BuildExcept(memb, excepts);
140 void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts)
142 BuildExcept(memb, excepts);
145 void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts)
147 BuildExcept(memb, excepts);
150 void OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exception)
152 UCListIter i = include.begin();
153 while (i != include.end())
156 Membership* memb = c->GetUser(source);
157 if (!memb || IsVisible(memb))
159 // this channel should not be considered when listing my neighbors
161 // however, that might hide me from ops that can see me...
162 const UserMembList* users = c->GetUsers();
163 for(UserMembCIter j = users->begin(); j != users->end(); j++)
165 if (IS_LOCAL(j->first) && CanSee(j->first, memb))
166 exception[j->first] = true;
171 void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, std::string& line)
173 Channel* channel = ServerInstance->FindChan(params[0]);
176 Membership* memb = channel->GetUser(user);
179 if (CanSee(source, memb))
185 MODULE_INIT(ModuleAuditorium)