Requesting module: +X Adults only

These are old archives. They are kept for historic purposes only.
WilliamWIkked
Posts: 59
Joined: Sun Jun 20, 2004 3:30 am
Contact:

Requesting module: +X Adults only

Post by WilliamWIkked » Sat May 10, 2008 7:33 am

I want to request a module for adult only channels.

User A tries to join channel #Adult, which is set channel mode +X
IRCD or Services warns user that #Adult is for adults only (18+) and prompts for some kind of input? or something to let them join.. ie: /join #Adult yes

Is this possible?

Thanks
William
WikkedWire Network Administrator
[insert another cliche sig here.]

Casper
Posts: 338
Joined: Sun Jul 08, 2007 7:44 am
Location: The Netherlands

Re: Requesting module: +X Adults only

Post by Casper » Sat May 10, 2008 4:48 pm

I think it's a great idea, as on many networks (like mine) are a lot of kids around! I'll be using it for sure if someone would like to make it ;)
Ex Network-Administrator

Stealth
Head of Support
Posts: 2086
Joined: Tue Jun 15, 2004 8:50 pm
Location: Chino Hills, CA, US
Contact:

Re: Requesting module: +X Adults only

Post by Stealth » Sat May 10, 2008 5:24 pm

That won't keep them from lying about it. There's nothing you can really do to keep kids from lying about how old they are to get into such channels.

We have all been kids once, so we should all know that if something says "Adults only" or "No kids" or just plain "no" kids will do anything they can to get in.

Casper
Posts: 338
Joined: Sun Jul 08, 2007 7:44 am
Location: The Netherlands

Re: Requesting module: +X Adults only

Post by Casper » Sat May 10, 2008 6:55 pm

At least they will be warned for the content they may see.
Ex Network-Administrator

BigSmoke
Posts: 23
Joined: Sun Apr 13, 2008 3:36 am
Location: Amsterdam, The Netherlands
Contact:

Re: Requesting module: +X Adults only

Post by BigSmoke » Sat May 10, 2008 7:48 pm

Yes, but most channels uses topic for that.. and if they don't, most likly they won't use +X either.
http://www.fazconi.com
irc://irc.fazconi.com
Email: biggie@fazconi.com

Casper
Posts: 338
Joined: Sun Jul 08, 2007 7:44 am
Location: The Netherlands

Re: Requesting module: +X Adults only

Post by Casper » Sat May 10, 2008 7:51 pm

You can kindly ask the channel owners to set the channelmode. Should be a little afford.
Ex Network-Administrator

WilliamWIkked
Posts: 59
Joined: Sun Jun 20, 2004 3:30 am
Contact:

Re: Requesting module: +X Adults only

Post by WilliamWIkked » Sun May 11, 2008 6:49 am

Yes, we will be asking channel owners to set it. Most adult channels already set either +s or put "18+" in the topic (it's in our server rules).. and we're a small network so it's easy to see which channels do it..
[insert another cliche sig here.]

Capitaine
Posts: 27
Joined: Mon Apr 26, 2004 6:09 pm

Re: Requesting module: +X Adults only

Post by Capitaine » Wed May 14, 2008 1:46 pm

I am currently making one !
Yes it's useful to extend it to Anope/Services and warn users on your web site.

Edit : ok it seems to work now.

Yet the code is very basic, there might be some bugs left. Still testing this...
Your ircd could crash, you have been warned.

See below
Last edited by Capitaine on Sat May 31, 2008 5:51 pm, edited 1 time in total.

Casper
Posts: 338
Joined: Sun Jul 08, 2007 7:44 am
Location: The Netherlands

Re: Requesting module: +X Adults only

Post by Casper » Fri May 16, 2008 9:24 am

I'll check it out on my testnet ;) Thanks for the effort!

Works pretty well.
Ex Network-Administrator

robc62
Posts: 13
Joined: Thu Feb 21, 2008 8:30 pm
Location: outer space
Contact:

Re: Requesting module: +X Adults only

Post by robc62 » Tue May 20, 2008 10:25 pm

great little module - caused a restart of my ircd on /rehash ... but only the once - works fine on initial inspection. ideal :)

Casper
Posts: 338
Joined: Sun Jul 08, 2007 7:44 am
Location: The Netherlands

Re: Requesting module: +X Adults only

Post by Casper » Wed May 21, 2008 10:33 am

I didn't need to restart..
Ex Network-Administrator

robc62
Posts: 13
Joined: Thu Feb 21, 2008 8:30 pm
Location: outer space
Contact:

Re: Requesting module: +X Adults only

Post by robc62 » Wed May 21, 2008 8:17 pm

hi Casper - i didnt physically restart - i rehashed to make a change to an oper block and add the 'X' module, and the restart happened then - but like I say, only the once, as I could not recreate the problem and can therefore only assume it was a 'glitch'.

Capitaine
Posts: 27
Joined: Mon Apr 26, 2004 6:09 pm

Re: Requesting module: +X Adults only

Post by Capitaine » Sat May 31, 2008 5:51 pm

I add a crash with a segfault, do *not* use anymore v1.1 !
Be warned, the previous v1.1 isn't safe : update it or remove it.

Here is a fixed 1.11 version :

Code: Select all

/*
 * ==================================================================================
 * Filename:          m_adult.c
 * Description:       Add user and channel mode +X for adults, and join restriction
 * Author:            Capitaine
 * History:
 * - v1.0 (20070220) New modes added
 * - v1.1 (20080424) Join check added
 * - v1.11(20080531) Using now a hook instead of command override => segfault bug fix
 * ==================================================================================
 */

#include "config.h"
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#endif
#include <fcntl.h>
#include "h.h"
#ifdef _WIN32
#include "version.h"
#endif



extern void			sendto_one(aClient *to, char *pattern, ...);

#define CFLAG_ADULT		'X'
#define UFLAG_ADULT		'X'
#define DelCmode(x)		if (x) CmodeDel(x); x = NULL
#define DelUmode(x)		if (x) UmodeDel(x); x = NULL
#define DelHook(x)		if (x) HookDel(x); x = NULL


DLLFUNC int		MOD_UNLOAD(adult)(int module_unload);
DLLFUNC int		cb_join(aClient *sptr, aChannel *chptr, char *parv[]);

static Cmode		*AddCmode(Module *module, CmodeInfo *req, Cmode_t *mode);
static Umode		*AddUmode(Module *module, char ch, long *mode);
static int		cmode_check(aClient *, aChannel *, char *, int, int);
Hook			*HookJoin = NULL;
static ModuleInfo	*thismodinfo = NULL;

#ifdef HOOKTYPE_REHASH_COMPLETE
static int		cb_rehash_complete();
Hook			*HookRehashDone;
#endif

Cmode_t			MODE_ADULT = 0L;
long			UMODE_ADULT = 0;
Cmode			*ModeAdult = NULL;
Umode			*UmodeAdult = NULL;

ModuleHeader MOD_HEADER(adult) = { "m_adult", "$Id: m_adult.c,v 1.11 2008/05/31 16:58 $", "user and channel modes +X ", "3.2-b8-1", NULL };

DLLFUNC int MOD_TEST(adult)(ModuleInfo *modinfo)
{
	CmodeInfo req;

	memset(&req, 0, sizeof req);

	req.paracount	= 0;
	req.is_ok	= cmode_check;
	req.flag	= CFLAG_ADULT;
	ModeAdult	= AddCmode(modinfo->handle, &req, &MODE_ADULT);
	UmodeAdult	= AddUmode(modinfo->handle, UFLAG_ADULT, &UMODE_ADULT);
	
	if (!ModeAdult || !UmodeAdult)
	{
		MOD_UNLOAD(adult)(0);
		return MOD_FAILED;
	}

	return MOD_SUCCESS;
}

DLLFUNC int MOD_INIT(adult)(ModuleInfo *modinfo)
{
	thismodinfo = modinfo;
	
#ifndef STATIC_LINKING
	ModuleSetOptions(modinfo->handle, MOD_OPT_PERM);
#endif

	return MOD_SUCCESS;
}

DLLFUNC int MOD_LOAD(adult)(int module_load)
{
	HookJoin = HookAddEx(thismodinfo->handle, HOOKTYPE_PRE_LOCAL_JOIN, cb_join);
	
	if (!HookJoin)
	{
		sendto_realops("m_adult: Couldn't load properly: %s", ModuleGetErrorStr(thismodinfo->handle));
		return MOD_FAILED;
	}

#ifdef HOOKTYPE_REHASH_COMPLETE
	HookRehashDone	= HookAddEx(thismodinfo->handle, HOOKTYPE_REHASH_COMPLETE, cb_rehash_complete);
	if (!HookRehashDone)
	{
		sendto_realops("m_adult: Couldn't load properly: %s", ModuleGetErrorStr(thismodinfo->handle));
		return MOD_FAILED;
	}
#endif

	return MOD_SUCCESS;
}

DLLFUNC int MOD_UNLOAD(adult)(int module_unload)
{
	DelCmode(ModeAdult);
	DelUmode(UmodeAdult);
	DelHook(HookJoin);

#ifdef HOOKTYPE_REHASH_COMPLETE
	DelHook(HookRehashDone);
#endif

	return MOD_SUCCESS;
}

static Cmode *AddCmode(Module *module, CmodeInfo *req, Cmode_t *mode)
{
	Cmode *cmode;

	*mode = 0;
	cmode = CmodeAdd(module, *req, mode);

#ifndef STATIC_LINKING
	if (ModuleGetError(module) != MODERR_NOERROR || !cmode)
	{
		config_error("Error adding channel mode +%c when loading module %s: %s", req->flag, MOD_HEADER(adult).name, ModuleGetErrorStr(module));
		return NULL;
	}
#else
    	if (!cmode)
	{
		config_error("Error adding channel mode +%c when loading module %s", req->flag, MOD_HEADER(adult).name);
		return NULL;
	}
#endif

	return cmode;
}

static Umode *AddUmode(Module *module, char ch, long *mode)
{
	Umode *umode;

	*mode = 0;
	umode = UmodeAdd(module, ch, UMODE_GLOBAL, NULL, mode);

#ifndef STATIC_LINKING
	if (ModuleGetError(module) != MODERR_NOERROR || !umode)
	{
		config_error("Error adding user mode +%c when loading module %s: %s", ch, MOD_HEADER(adult).name, ModuleGetErrorStr(module));
		return NULL;
	}
#else
	if (!umode)
	{
		config_error("Error adding user mode +%c when loading module %s", ch, MOD_HEADER(adult).name);
		return NULL;
	}
#endif

	return umode;
}

static int cmode_check(aClient *sptr, aChannel *chptr, char *para, int type, int what)
{
	if ((type == EXCHK_ACCESS) || (type == EXCHK_ACCESS_ERR))
	{
		if (IsPerson(sptr) && !IsULine(sptr) && !is_chan_op(sptr, chptr))
		{
			if (type == EXCHK_ACCESS_ERR)
				sendto_one(sptr, err_str(ERR_CHANOPRIVSNEEDED), me.name, sptr->name, chptr->chname);
			return EX_DENY;
		}

		return EX_ALLOW;
	}

	return 0;
}

int cb_join(aClient *sptr, aChannel *chptr, char *parv[])
{

	if (chptr && !IsMember(sptr, chptr))
	{
		
		/* Is this channel rated for adults ? */
		
		if ((chptr->mode.extmode & CFLAG_ADULT) && !(sptr->umodes & UMODE_ADULT))
		{
			/* Deny access */

			sendto_one(sptr, ":%s %s %s :*** This is an adults only channel. To join %s you must be of legal age and type : /MODE %s +X", me.name, IsWebTV(sptr) ? "PRIVMSG" : "NOTICE", sptr->name, chptr->chname, sptr->name);
						
			return HOOK_DENY;
		}
	}

	return HOOK_CONTINUE;
}

#ifdef HOOKTYPE_REHASH_COMPLETE
static int cb_rehash_complete()
{
	HookJoin = HookAddEx(thismodinfo->handle, HOOKTYPE_PRE_LOCAL_JOIN, cb_join);

	if (!HookJoin)
	{
		sendto_realops("m_adult: Couldn't load properly: %s", ModuleGetErrorStr(thismodinfo->handle));
		return MOD_FAILED;
	}
}
#endif


[dx]
Posts: 107
Joined: Sat Jun 16, 2007 1:03 am

Re: Requesting module: +X Adults only

Post by [dx] » Mon Jul 07, 2008 10:11 pm

Perfect..
But can someone help me to edit this

Code: Select all

        sendto_one(sptr, ":%s %s %s :*** This is an adults only channel. To join %s you must be of legal age and type : /MODE %s +X", me.name, IsWebTV(sptr) ? "PRIVMSG" : "NOTICE", sptr->name, chptr->chname, sptr->name);
This make to use notice.
I know that I must put sendnotice instead of sendto_one. But what is prob?
I got msg like this -server.name- server.name NOTICE nick :*** other text..

Can be done just to show -server.name- TEXT

I hope you understand me ;)

Regards

[dx]
Posts: 107
Joined: Sat Jun 16, 2007 1:03 am

Re: Requesting module: +X Adults only

Post by [dx] » Wed Jul 09, 2008 8:22 am

Thing solved :-)

Code: Select all

sendnotice(sptr, ":%s %s %s :*** This is an adults only channel. To join %s you must be of legal age and type : /MODE %s +X", chptr->chname, sptr->name);
Anyway thnx for module.. great

Post Reply