Skip to content

Commit 78e2f5b

Browse files
authored
Add ability for opers to view related information (#76)
- Locked nicks will show up as such in a `/WHOIS` from an oper - Added ability to `/nicklock -list`
1 parent 4c0017c commit 78e2f5b

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

files/nicklock.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module
3232

3333
ModuleHeader MOD_HEADER = {
3434
"third/nicklock",
35-
"1.0",
35+
"1.1",
3636
"Adds the /NICKLOCK command which allows server operators to prevent a user from changing their nick during their session.",
3737
"Valware",
3838
"unrealircd-6",
@@ -54,6 +54,7 @@ CMD_OVERRIDE_FUNC(nick_override);
5454
void nicklock_free(ModData *m);
5555
const char *nicklock_serialize(ModData *m);
5656
void nicklock_unserialize(const char *str, ModData *m);
57+
int nicklock_whois(Client *requester, Client *client, NameValuePrioList **list);
5758

5859
ModDataInfo *nicklock_md;
5960

@@ -76,6 +77,7 @@ MOD_INIT() {
7677
return MOD_FAILED;
7778
}
7879

80+
HookAdd(modinfo->handle, HOOKTYPE_WHOIS, 0, nicklock_whois);
7981
CommandAdd(modinfo->handle, NLOCK, NICKLOCK, 2, CMD_OPER);
8082
CommandAdd(modinfo->handle, RNLOCK, NICKUNLOCK, 1, CMD_OPER);
8183

@@ -118,9 +120,6 @@ CMD_FUNC(NICKLOCK)
118120
char oldnickname[NICKLEN+1];
119121
MessageTag *mtags = NULL;
120122

121-
if (hunt_server(client, NULL, "NICKLOCK", 1, parc, parv) != HUNTED_ISME)
122-
return;
123-
124123
if (!IsOper(client))
125124
{
126125
sendnumeric(client, ERR_NOPRIVILEGES);
@@ -132,6 +131,24 @@ CMD_FUNC(NICKLOCK)
132131
return;
133132
}
134133

134+
/* the oper wants to see a list of nicklocked nicks =] */
135+
if (!strcasecmp(parv[1],"-list"))
136+
{
137+
int listnum = 1;
138+
sendnotice(client, "Listing NICKLOCK'd users:");
139+
list_for_each_entry(target, &client_list, client_node)
140+
{
141+
if (IsNickLock(target))
142+
{
143+
sendnotice(client,"%d) %s", listnum, target->name); /* show them */
144+
listnum++;
145+
}
146+
}
147+
return;
148+
}
149+
if (hunt_server(client, NULL, "NICKLOCK", 1, parc, parv) != HUNTED_ISME)
150+
return;
151+
135152
if (!(target = find_user(parv[1], NULL))) {
136153
sendnumeric(client, ERR_NOSUCHNICK, parv[1]);
137154
return;
@@ -237,3 +254,11 @@ CMD_OVERRIDE_FUNC(nick_override)
237254
CallCommandOverride(ovr, client, recv_mtags, parc, parv);
238255
return;
239256
}
257+
258+
int nicklock_whois(Client *requester, Client *client, NameValuePrioList **list)
259+
{
260+
if (IsOper(requester) && IsNickLock(client))
261+
add_nvplist_numeric_fmt(list, 0, "nicklock", client, 320, "%s :has been locked from changing nicks", client->name);
262+
263+
return 0;
264+
}

0 commit comments

Comments
 (0)