1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 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('u') != adding)
30 channel->SetMode('u', adding);
31 return MODEACTION_ALLOW;
35 return MODEACTION_DENY;
40 class ModuleAuditorium : public Module
50 if (!ServerInstance->Modes->AddMode(&aum))
51 throw ModuleException("Could not add new modes!");
55 Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnBuildNeighborList, I_OnNamesListItem, I_OnRehash };
56 ServerInstance->Modules->Attach(eventlist, this, 6);
64 void OnRehash(User* user)
67 ShowOps = conf.ReadFlag("auditorium", "showops", 0);
68 OperOverride = conf.ReadFlag("auditorium", "operoverride", 0);
73 return Version("Allows for auditorium channels (+u) where nobody can see others joining and parting or the nick list", VF_COMMON | VF_VENDOR);
76 void OnNamesListItem(User* issuer, Membership* memb, std::string &prefixes, std::string &nick)
78 if (!memb->chan->IsModeSet('u'))
81 /* Some module hid this from being displayed, dont bother */
85 /* If user is oper and operoverride is on, don't touch the list */
86 if (OperOverride && issuer->HasPrivPermission("channels/auspex"))
89 if (ShowOps && (issuer != memb->user) && (memb->getRank() < OP_VALUE))
91 /* Showops is set, hide all non-ops from the user, except themselves */
96 if (!ShowOps && (issuer != memb->user))
98 /* ShowOps is not set, hide everyone except the user whos requesting NAMES */
104 void BuildExcept(Membership* memb, CUList& excepts)
106 if (!memb->chan->IsModeSet('u'))
108 if (ShowOps && memb->getRank() >= OP_VALUE)
111 const UserMembList* users = memb->chan->GetUsers();
112 for(UserMembCIter i = users->begin(); i != users->end(); i++)
114 if (i->first == memb->user || !IS_LOCAL(i->first))
116 if (ShowOps && i->second->getRank() >= OP_VALUE)
118 if (OperOverride && i->first->HasPrivPermission("channels/auspex"))
120 // This is a different user in the channel, local, and not op/oper
121 // so, hide the join from them
122 excepts.insert(i->first);
125 void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts)
127 BuildExcept(memb, excepts);
130 void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts)
132 BuildExcept(memb, excepts);
135 void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts)
137 BuildExcept(memb, excepts);
140 void OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exception)
142 UCListIter i = include.begin();
143 while (i != include.end())
146 if (c->IsModeSet('u'))
152 MODULE_INIT(ModuleAuditorium)