Skip to content

Commit 57a4959

Browse files
authored
New module third/restrict-chans (PR #88 from ValwareIRC/patch-25)
Module to restrict the creation of channels to logged-in users and opers
2 parents 07944fb + 366b4f4 commit 57a4959

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

files/restrict-chans.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* LICENSE: GPLv3 or later
3+
* Copyright Ⓒ 2023 Valerie Pond
4+
*
5+
* Restricts channels to registered users
6+
* Requested by Chris[A]
7+
*
8+
*/
9+
/*** <<<MODULE MANAGER START>>>
10+
module
11+
{
12+
documentation "https://github.com/ValwareIRC/valware-unrealircd-mods/blob/main/restrict-chans/README.md";
13+
troubleshooting "In case of problems, documentation or e-mail me at v.a.pond@outlook.com";
14+
min-unrealircd-version "6.*";
15+
max-unrealircd-version "6.*";
16+
post-install-text {
17+
"The module is installed. Now all you need to do is add a loadmodule line:";
18+
"loadmodule \"third/restrict-chans\";";
19+
"And /REHASH the IRCd.";
20+
"The module does not need any other configuration.";
21+
}
22+
}
23+
*** <<<MODULE MANAGER END>>>
24+
*/
25+
#include "unrealircd.h"
26+
int isreg_can_join(Client *client, Channel *channel, const char *key, char **errmsg);
27+
28+
ModuleHeader MOD_HEADER =
29+
{
30+
"third/restrict-chans",
31+
"1.0",
32+
"Restrict channel creation to logged-in users",
33+
"Valware",
34+
"unrealircd-6",
35+
};
36+
MOD_INIT()
37+
{
38+
MARK_AS_GLOBAL_MODULE(modinfo);
39+
40+
HookAdd(modinfo->handle, HOOKTYPE_CAN_JOIN, 0, isreg_can_join);
41+
return MOD_SUCCESS;
42+
}
43+
44+
MOD_LOAD()
45+
{
46+
return MOD_SUCCESS;
47+
}
48+
MOD_UNLOAD()
49+
{
50+
return MOD_SUCCESS;
51+
}
52+
53+
MOD_TEST()
54+
{
55+
return MOD_SUCCESS;
56+
}
57+
58+
int isreg_can_join(Client *client, Channel *channel, const char *key, char **errmsg)
59+
{
60+
if (!channel->users && !IsLoggedIn(client) && !has_channel_mode(channel, 'P'))
61+
{
62+
*errmsg = "%s :You must be logged in to create new channels", channel->name;
63+
return ERR_CANNOTDOCOMMAND;
64+
}
65+
return 0;
66+
}

0 commit comments

Comments
 (0)