Skip to content

Commit 240ec34

Browse files
committed
groupserv: Show GROUPs in CS INFO
1 parent fbaac4d commit 240ec34

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

modules/third/GroupServ/groupserv.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
*
4949
* # Default flags granted when a user JOINs an open group.
5050
* # These are GroupServ access flags (NOT IRC user modes).
51-
* # Accepts: +A +i, +ACLVIEW +INVITE, or compact +Ai.
51+
* # Accepts: +A +I, +ACLVIEW +INVITE, or compact +AI.
5252
* default_joinflags = "+A"
5353
*
5454
* # Auto-save interval in seconds (0 disables periodic autosave)
@@ -1037,7 +1037,7 @@ class GroupServ final
10371037
GroupServ(const Anope::string& modname, const Anope::string& creator)
10381038
: Module(modname, creator, VENDOR)
10391039
, core(this)
1040-
, chanaccess(this, "groupserv/chanaccess")
1040+
, chanaccess(this, "groupserv:chanaccess")
10411041
, chanaccess_type(chanaccess)
10421042
, cmd_cs_set_group(this, core, chanaccess)
10431043
, cmd_cs_set_grouponly(this, core, chanaccess)
@@ -1124,6 +1124,31 @@ class GroupServ final
11241124
}
11251125
info["GroupServ"] = out;
11261126
}
1127+
1128+
void OnChanInfo(CommandSource& source, ChannelInfo* ci, InfoFormatter& info, bool show_hidden) override
1129+
{
1130+
if (!ci)
1131+
return;
1132+
1133+
auto* d = this->chanaccess.Get(ci);
1134+
if (!d || d->group.empty())
1135+
return;
1136+
1137+
GSGroupFlags gflags = GSGroupFlags::NONE;
1138+
if (!this->core.GetGroupFlags(d->group, gflags))
1139+
{
1140+
// Only show missing associations to users who can already see hidden details.
1141+
if (show_hidden)
1142+
info[_("GroupServ")] = d->group + " (missing)";
1143+
return;
1144+
}
1145+
1146+
// Mirror NickServ INFO behaviour: only show non-public groups to users who can see hidden details.
1147+
if (!show_hidden && !HasFlag(gflags, GSGroupFlags::PUBLIC))
1148+
return;
1149+
1150+
info[_("GroupServ")] = d->group;
1151+
}
11271152
};
11281153

11291154
MODULE_INIT(GroupServ)

modules/third/GroupServ/groupserv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class GroupServCore final
189189
bool SetGroupFlag(CommandSource& source, const Anope::string& groupname, GSGroupFlags flag, bool enabled);
190190

191191
bool GetGroupVHost(const Anope::string& groupname, Anope::string& out) const;
192+
bool GetGroupFlags(const Anope::string& groupname, GSGroupFlags& out) const;
192193
void GetGroupsForAccount(const NickCore* nc, std::vector<Anope::string>& out, bool show_hidden) const;
193194

194195
void SaveDB();

modules/third/GroupServ/groupserv_core.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,16 @@ bool GroupServCore::GetGroupVHost(const Anope::string& groupname, Anope::string&
12471247
return true;
12481248
}
12491249

1250+
bool GroupServCore::GetGroupFlags(const Anope::string& groupname, GSGroupFlags& out) const
1251+
{
1252+
out = GSGroupFlags::NONE;
1253+
auto it = this->groups.find(NormalizeKey(groupname));
1254+
if (it == this->groups.end())
1255+
return false;
1256+
out = it->second.flags;
1257+
return true;
1258+
}
1259+
12501260
void GroupServCore::GetGroupsForAccount(const NickCore* nc, std::vector<Anope::string>& out, bool show_hidden) const
12511261
{
12521262
out.clear();

0 commit comments

Comments
 (0)