Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extensions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extension_LTLIBRARIES = \
chantype_dummy.la \
chm_adminonly.la \
chm_operonly.la \
chm_serviceonly.la \
chm_insecure.la \
chm_nonotice.la \
chm_operpeace.la \
Expand Down
56 changes: 56 additions & 0 deletions extensions/chm_serviceonly.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include "stdinc.h"
#include "modules.h"
#include "hook.h"
#include "client.h"
#include "ircd.h"
#include "send.h"
#include "s_conf.h"
#include "s_user.h"
#include "s_serv.h"
#include "numeric.h"
#include "chmode.h"

static const char chm_serviceonly_desc[] =
"Adds channel mode +X which makes a channel service-only";

static void h_can_join(void *);

mapi_hfn_list_av1 serviceonly_hfnlist[] = {
{ "can_join", h_can_join },
{ NULL, NULL }
};

static unsigned int mymode;

static int
_modinit(void)
{
mymode = cflag_add('X', chm_staff);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholder character, please suggest better options

if (mymode == 0)
return -1;

return 0;
}


static void
_moddeinit(void)
{
cflag_orphan('X');
}

DECLARE_MODULE_AV2(chm_serviceonly, _modinit, _moddeinit, NULL, NULL, serviceonly_hfnlist, NULL, NULL, chm_serviceonly_desc);

static void
h_can_join(void *data_)
{
hook_data_channel *data = data_;
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;

if((chptr->mode.mode & mymode) && !IsService(source_p)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way a local client can be a service, so the && !IsService(source_p) part could be removed.

This feels weird.

sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+X) - you are not a service", chptr->chname);
data->approved = ERR_CUSTOM;
}
}