Here is the entire source, so it's quite big. Sorry 
Code: Select all
#define MODULE_NAME "animextacy"
#define MAKING_ANIMEXTACY
#include "src\mod\module.h"
#include "src\mod\channels.mod\channels.h"
#include "src\mod\modvals.h"
#include "src\mod\irc.mod/irc.h"
#include <stdlib.h>
#include <time.h>
/* general channel rules */
static int pub_rules(char *nick, char *host, char *hand, char *channel, char * text);
/* displays all releases that we have done to date */
static int pub_releases(char *nick, char *host, char *hand, char *channel, char *text);
/* general help */
static int pub_help(char* nick, char *host, char *hand, char *channel, char *text);
/* new releases as of XX */
static int pub_newreleases(char* nick, char *host, char *hand, char *channel, char *text);
/* Serving rules */
static int pub_servrules(char* nick, char *host, char *hand, char *channel, char *text); // server rules
static void notice_user(char *nick, char buffer[], int idx);
static void notice_text(char *nick, char text);
#undef global
static Function *global = NULL;
static int animextacy_expmem()
{
	int size = 0;
	Context;
	return size;
}
/* BEGIN FUNCTION IMPLEMENTATIONS HERE */
FILE* pStream = NULL;
static int pub_rules(char *nick, char *host, char *hand, char *channel, char *text)
{
	/* if the file stream pointer is null, open the file */
	if( pStream ) return 0; 
	pStream = fopen(".\\rules.txt", "r");
	if( !pStream ) return 0;
	
	/* read the strings into a buffer array */
	char nArray[25];
	int i = 0;
	while( !feof( pStream ) )
	{
		char buffer;
		if( !fgets(&buffer, 255, pStream ) ) return 0; // couldn't read a string from the file.
		nArray[i++] = buffer;
	}
	notice_user(nick, nArray, i); // notice the user
	
	/* close the open file  and set pStream to null */
	fclose(pStream);
	pStream = NULL;
}
static int pub_releases(char *nick, char *host, char *hand, char *channel, char *text)
{
	if( !pStream ) return 0;
	
	pStream = fopen(".\\releases.txt", "r");
	if( !pStream ) return 0;
	
	char buffer;
	
	if( !fgets(&buffer, 255, pStream ) ) return 0;
	notice_text(nick, buffer);
	wait(1000);
	
	/* close open file stream & reset pStream to NULL */
	fclose( pStream );
	pStream = NULL;
}
static int pub_help(char* nick, char *host, char *hand, char *channel, char *text)
{
	return 0;	
}
static int pub_newreleases(char* nick, char *host, char *hand, char *channel, char *text)
{
	return 0;
}
static int pub_servrules(char* nick, char *host, char *hand, char *channel, char *text)
{
	return 0;
}
/* END OF FUNCTION IMPLEMENTATIONS HERE */
static void animextacy_report(int idx, int details)
{
	int size = 0;
	Context;
	size = animextacy_expmem();
	if( details ) dprintf(idx, "      0 AnimeXtacy.dll is using [%d] bytes\n", size);
}
static cmd_t pub_cmds[] = 
{
	{"rules",	"",	pub_rules,	NULL},
//	{"help"	"",	pub_help, NULL},
//	{"releases",	"",	pub_releases, 	NULL},
//	{"newreleases", 	"",	pub_newreleases, 	NULL},
//	{"serv_rules",	"",	pub_servrules,	NULL},
	{0}
};
static char *animextacy_close()
{
	table = find_bind_table("pub");
	if (table) rem_builtins(table, pub_cmds);
	module_undepend("animextacy");
	//return "This module cannot be unloaded!";
}
EXPORT_SCOPE char *animextacy_start();
static Function animextacy_table[] = 
{
	(Function) animextacy_start,
	(Function) animextacy_close,
	(Function) animextacy_expmem,
	(Function) animextacy_report,
};
char *animextacy_start(Function *global_funcs)
{
	global = global_funcs;	
	module_register(MODULE_NAME, animextacy_table, 1, 0);
	if( !module_depend(MODULE_NAME, "eggdrop", 106, 0) ) {
		module_undepend(MODULE_NAME);
		return "This module needs eggdrop 1.6.00 or better to run.";
	}
	table = find_bind_table("pub");
	if( table )
	{
		add_builtins(table, pub_cmds); // this is the hot spot
	}
	return NULL;
}
static void notice_text(char *nick, char text)
{
	dprintf(DP_SERVER, "PRIVMSG %s :%s", nick, text);	
}
static void notice_user(char *nick, char buffer[], int idx)
{
	if( !nick ) return ;
	if( !idx ) return;
	int i = 0;
	for( i = 0; i <= idx; i++) 
	{ 
		notice_text(nick, buffer[i]);
	}
}