just registers can /list

These are old archives. They are kept for historic purposes only.
Post Reply
YuvaL
Posts: 14
Joined: Sun May 16, 2010 1:41 am

just registers can /list

Post by YuvaL »

there is a module that just register to the services can /list?
Stealth
Head of Support
Posts: 2085
Joined: Tue Jun 15, 2004 8:50 pm
Location: Chino Hills, CA, US
Contact:

Re: just registers can /list

Post by Stealth »

I wrote this in like 2 minutes, so it's highly recommended that you load it on a test server first.

Code: Select all

/*
 * ==================================================================
 * Module:      m_regonlylist.c
 * Author:      Stealth <[email protected]>
 * Version:     0.0.1
 * Licence:     I wrote this in like 2 minutes so if it breaks your
                stuff don't come crying to me.
                USE THIS MODULE AT YOUR OWN RISK.
 * Description: Deny /LIST for non-registered users
 * ==================================================================
 */

#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"
#include "proto.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif

static Cmdoverride *m_regonlylist_override = NULL;
static ModuleInfo *m_regonlylist_modinfo = NULL;

DLLFUNC int m_regonlylist(Cmdoverride *anoverride, aClient *cptr, aClient *sptr, int parc, char *parv[]);

ModuleHeader MOD_HEADER(m_regonlylist)
  = {
	"m_regonlylist",	/* Name */
	"0.0.1", /* Ver */
	"Deny /LIST for non-registered users by Stealth", /* Desc. */
	"3.2-b8-1",
	NULL
    };

DLLFUNC int MOD_INIT(m_regonlylist)(ModuleInfo *modinfo)
{
	m_regonlylist_modinfo = modinfo;
	return MOD_SUCCESS;
}

DLLFUNC int MOD_LOAD(m_regonlylist)(int module_load)
{
	m_regonlylist_override = CmdoverrideAdd(m_regonlylist_modinfo->handle, "LIST", m_regonlylist);
	if (!m_regonlylist_override)
	{
		sendto_realops("m_regonlylist: Failed to allocate override: %s", ModuleGetErrorStr(m_regonlylist_modinfo->handle));
		return MOD_FAILED;
	}
	return MOD_SUCCESS;
}

DLLFUNC int MOD_UNLOAD(m_regonlylist)(int module_unload)
{
	CmdoverrideDel(m_regonlylist_override);
	return MOD_SUCCESS;
}

DLLFUNC int m_regonlylist(Cmdoverride *anoverride, aClient *cptr, aClient *sptr, int parc, char *parv[])
{
	if (!IsAnOper(sptr) && MyClient(sptr) && !(sptr->umodes & UMODE_REGNICK))
	{
		sendto_one(sptr, ":%s %s %s :*** You must be using a registered nickname to use LIST", me.name, IsWebTV(sptr) ? "PRIVMSG" : "NOTICE", sptr->name);
		return 0;
	}

	/* aww, no fun. they're allowed :( - let it through */
	return CallCmdoverride(m_regonlylist_override, cptr, sptr, parc, parv);
}
YuvaL
Posts: 14
Joined: Sun May 16, 2010 1:41 am

Re: just registers can /list

Post by YuvaL »

when i do /list second time the message not appear

and when i registered my nickname /list not working
Stealth
Head of Support
Posts: 2085
Joined: Tue Jun 15, 2004 8:50 pm
Location: Chino Hills, CA, US
Contact:

Re: just registers can /list

Post by Stealth »

Try this:

Code: Select all

/*
 * ==================================================================
 * Module:      m_regonlylist.c
 * Author:      Stealth <[email protected]>
 * Version:     0.0.1
 * Licence:     I wrote this in like 2 minutes so if it breaks your
                stuff don't come crying to me.
                USE THIS MODULE AT YOUR OWN RISK.
 * Description: Deny /LIST for non-registered users
 * ==================================================================
 */

#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"
#include "proto.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif

static Cmdoverride *m_regonlylist_override = NULL;
static ModuleInfo *m_regonlylist_modinfo = NULL;

DLLFUNC int m_regonlylist(Cmdoverride *anoverride, aClient *cptr, aClient *sptr, int parc, char *parv[]);

ModuleHeader MOD_HEADER(m_regonlylist)
  = {
	"m_regonlylist",	/* Name */
	"0.0.1", /* Ver */
	"Deny /LIST for non-registered users by Stealth", /* Desc. */
	"3.2-b8-1",
	NULL
    };

DLLFUNC int MOD_INIT(m_regonlylist)(ModuleInfo *modinfo)
{
	m_regonlylist_modinfo = modinfo;
	return MOD_SUCCESS;
}

DLLFUNC int MOD_LOAD(m_regonlylist)(int module_load)
{
	m_regonlylist_override = CmdoverrideAdd(m_regonlylist_modinfo->handle, "LIST", m_regonlylist);
	if (!m_regonlylist_override)
	{
		sendto_realops("m_regonlylist: Failed to allocate override: %s", ModuleGetErrorStr(m_regonlylist_modinfo->handle));
		return MOD_FAILED;
	}
	return MOD_SUCCESS;
}

DLLFUNC int MOD_UNLOAD(m_regonlylist)(int module_unload)
{
	CmdoverrideDel(m_regonlylist_override);
	return MOD_SUCCESS;
}

DLLFUNC int m_regonlylist(Cmdoverride *anoverride, aClient *cptr, aClient *sptr, int parc, char *parv[])
{
	if (!IsAnOper(sptr) && MyClient(sptr) && !(sptr->umodes & UMODE_REGNICK))
	{
		sendto_one(sptr, ":%s %s %s :*** You must be using a registered nickname to use LIST", me.name, IsWebTV(sptr) ? "PRIVMSG" : "NOTICE", sptr->name);
        sendto_one(sptr, rpl_str(RPL_LISTSTART), me.name, parv[0]);
        sendto_one(sptr, rpl_str(RPL_LISTEND), me.name, parv[0]);
		return 0;
	}

	/* aww, no fun. they're allowed :( - let it through */
	return CallCmdoverride(m_regonlylist_override, cptr, sptr, parc, parv);
}
YuvaL
Posts: 14
Joined: Sun May 16, 2010 1:41 am

Re: just registers can /list

Post by YuvaL »

Thanks, it's working.
katsklaw
Posts: 1124
Joined: Sun Apr 18, 2004 5:06 pm
Contact:

Re: just registers can /list

Post by katsklaw »

would be cool if you could have exemptions in the config file for crawlers like searchirc and netsplit bots.
Stealth
Head of Support
Posts: 2085
Joined: Tue Jun 15, 2004 8:50 pm
Location: Chino Hills, CA, US
Contact:

Re: just registers can /list

Post by Stealth »

katsklaw wrote:would be cool if you could have exemptions in the config file for crawlers like searchirc and netsplit bots.
Too bad that's over my head, I won't mind if someone takes the base code and does that.
katsklaw
Posts: 1124
Joined: Sun Apr 18, 2004 5:06 pm
Contact:

Re: just registers can /list

Post by katsklaw »

Stealth wrote:
katsklaw wrote:would be cool if you could have exemptions in the config file for crawlers like searchirc and netsplit bots.
Too bad that's over my head, I won't mind if someone takes the base code and does that.
I might do that. I've a few Anope modules under my belt but sadly I know their code far better than I know U3's. I'd be able to do it if it was Anope .. lol. The coding style is far different between the 2 projects and I'm not exactly an expert to start with. Then there is the lack of time factor, but hey I might get around to it eventually and I'll pass it back if I do. :)
Post Reply