Page 1 of 2
Requesting module: +X Adults only
Posted: Sat May 10, 2008 7:33 am
by WilliamWIkked
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
Re: Requesting module: +X Adults only
Posted: Sat May 10, 2008 4:48 pm
by Casper
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
Re: Requesting module: +X Adults only
Posted: Sat May 10, 2008 5:24 pm
by Stealth
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.
Re: Requesting module: +X Adults only
Posted: Sat May 10, 2008 6:55 pm
by Casper
At least they will be warned for the content they may see.
Re: Requesting module: +X Adults only
Posted: Sat May 10, 2008 7:48 pm
by BigSmoke
Yes, but most channels uses topic for that.. and if they don't, most likly they won't use +X either.
Re: Requesting module: +X Adults only
Posted: Sat May 10, 2008 7:51 pm
by Casper
You can kindly ask the channel owners to set the channelmode. Should be a little afford.
Re: Requesting module: +X Adults only
Posted: Sun May 11, 2008 6:49 am
by WilliamWIkked
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..
Re: Requesting module: +X Adults only
Posted: Wed May 14, 2008 1:46 pm
by Capitaine
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
Re: Requesting module: +X Adults only
Posted: Fri May 16, 2008 9:24 am
by Casper
I'll check it out on my testnet
Thanks for the effort!
Works pretty well.
Re: Requesting module: +X Adults only
Posted: Tue May 20, 2008 10:25 pm
by robc62
great little module - caused a restart of my ircd on /rehash ... but only the once - works fine on initial inspection. ideal
Re: Requesting module: +X Adults only
Posted: Wed May 21, 2008 10:33 am
by Casper
I didn't need to restart..
Re: Requesting module: +X Adults only
Posted: Wed May 21, 2008 8:17 pm
by robc62
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'.
Re: Requesting module: +X Adults only
Posted: Sat May 31, 2008 5:51 pm
by Capitaine
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
Re: Requesting module: +X Adults only
Posted: Mon Jul 07, 2008 10:11 pm
by [dx]
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
Re: Requesting module: +X Adults only
Posted: Wed Jul 09, 2008 8:22 am
by [dx]
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