begin work on bot_set function
This commit is contained in:
parent
7ac7fde115
commit
34c2fabe0c
14 changed files with 230 additions and 104 deletions
|
@ -11,6 +11,7 @@ NeoStats ChangeLog - Anything we add/remove/fix/change is in here (even our rant
|
|||
- add MSG_SJOIN handling to Unreal (M)
|
||||
- added command handler support function is_target_valid to validate a user (M)
|
||||
- added __attribute__((format(printf,x,y))) and __attribute__((noreturn)) to header files (M)
|
||||
- early version of bot set handler introduced (M)
|
||||
|
||||
* NeoStats * Fish (F) & Mark (M)* Version 2.5.9
|
||||
- import of libpcre into core (M)
|
||||
|
|
121
commands.c
121
commands.c
|
@ -24,8 +24,10 @@
|
|||
#include "stats.h"
|
||||
#include "dl.h"
|
||||
#include "log.h"
|
||||
#include "conf.h"
|
||||
|
||||
static int bot_cmd_help (ModUser* bot_ptr, User * u, char **av, int ac);
|
||||
static int bot_cmd_set (ModUser* bot_ptr, User * u, char **av, int ac);
|
||||
|
||||
/* hash for services bot command list */
|
||||
static hash_t *botcmds = NULL;
|
||||
|
@ -59,8 +61,8 @@ static const char *cmd_help_help[] = {
|
|||
*/
|
||||
static bot_cmd intrinsic_commands[]=
|
||||
{
|
||||
{"HELP", NULL, 0, 0, cmd_help_help, 1, cmd_help_oneline},
|
||||
{NULL, NULL, 0, 0, NULL, 0, NULL}
|
||||
{"HELP", NULL, 0, 0, cmd_help_help, cmd_help_oneline},
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
@ -104,8 +106,7 @@ add_bot_cmd(hash_t* cmd_hash, bot_cmd* cmd_ptr)
|
|||
cmd_ptr->cmd);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
/* Add the command */
|
||||
/* Seems OK, add the command */
|
||||
cmdnode = hnode_create(cmd_ptr);
|
||||
if (cmdnode) {
|
||||
hash_insert(cmd_hash, cmdnode, cmd_ptr->cmd);
|
||||
|
@ -323,6 +324,11 @@ run_bot_cmd (ModUser* bot_ptr, User *u, char **av, int ac)
|
|||
bot_cmd_help(bot_ptr, u, av, ac);
|
||||
return 1;
|
||||
}
|
||||
/* Handle SET if we have it */
|
||||
if (bot_ptr->bot_settings && !strcasecmp(av[1], "SET") ) {
|
||||
bot_cmd_set(bot_ptr, u, av, ac);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* We have run out of commands so report failure */
|
||||
prefmsg (u->nick, bot_ptr->nick, "Syntax error: unknown command: \2%s\2", av[1]);
|
||||
|
@ -364,6 +370,10 @@ bot_cmd_help (ModUser* bot_ptr, User * u, char **av, int ac)
|
|||
prefmsg(u->nick, bot_ptr->nick, " %-20s %s", cmd_ptr->cmd, cmd_ptr->onelinehelp);
|
||||
cmd_ptr++;
|
||||
}
|
||||
/* Do we have a set command? */
|
||||
if(bot_ptr->bot_settings) {
|
||||
prefmsg(u->nick, bot_ptr->nick, "SET Configure %s", bot_ptr->nick);
|
||||
}
|
||||
restartlevel:
|
||||
hash_scan_begin(&hs, bot_ptr->botcmds);
|
||||
while ((cmdnode = hash_scan_next(&hs)) != NULL) {
|
||||
|
@ -439,7 +449,7 @@ bot_cmd_help (ModUser* bot_ptr, User * u, char **av, int ac)
|
|||
/* Handle intrinsic commands */
|
||||
cmd_ptr = intrinsic_commands;
|
||||
while(cmd_ptr->cmd) {
|
||||
if (!strcasecmp(av[1],cmd_ptr->cmd)) {
|
||||
if (!strcasecmp(av[1], cmd_ptr->cmd)) {
|
||||
privmsg_list (u->nick, bot_ptr->nick, cmd_ptr->helptext);
|
||||
return 1;
|
||||
}
|
||||
|
@ -472,3 +482,104 @@ int is_target_valid(char* bot_name, User* u, char* target_nick)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/** @brief bot_cmd_help process bot set command
|
||||
* work in progress
|
||||
* @return NS_SUCCESS if suceeds, NS_FAILURE if not
|
||||
*/
|
||||
static int
|
||||
bot_cmd_set (ModUser* bot_ptr, User * u, char **av, int ac)
|
||||
{
|
||||
bot_setting* set_ptr;
|
||||
|
||||
if (ac < 3) {
|
||||
prefmsg(u->nick, bot_ptr->nick,
|
||||
"Invalid Syntax. /msg %s HELP SET for more info",
|
||||
bot_ptr->nick);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!strcasecmp(av[2], "LIST"))
|
||||
{
|
||||
prefmsg(u->nick, bot_ptr->nick, "Current %s settings:", bot_ptr->nick);
|
||||
set_ptr = bot_ptr->bot_settings;
|
||||
while(set_ptr->option)
|
||||
{
|
||||
switch(set_ptr->type) {
|
||||
case SET_TYPE_BOOLEAN:
|
||||
prefmsg(u->nick, bot_ptr->nick, "%s: %s",
|
||||
set_ptr->option, *(int*)set_ptr->varptr ? "Enabled" : "Disabled");
|
||||
break;
|
||||
case SET_TYPE_INT:
|
||||
case SET_TYPE_INTRANGE:
|
||||
prefmsg(u->nick, bot_ptr->nick, "%s: %d",
|
||||
set_ptr->option, *(int*)set_ptr->varptr);
|
||||
break;
|
||||
case SET_TYPE_STRING:
|
||||
case SET_TYPE_STRINGRANGE:
|
||||
case SET_TYPE_NICK:
|
||||
case SET_TYPE_USER:
|
||||
case SET_TYPE_HOST:
|
||||
case SET_TYPE_RNAME:
|
||||
case SET_TYPE_CUSTOM:
|
||||
prefmsg(u->nick, bot_ptr->nick, "%s: %s",
|
||||
set_ptr->option, *(char*)set_ptr->varptr);
|
||||
break;
|
||||
}
|
||||
set_ptr++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
set_ptr = bot_ptr->bot_settings;
|
||||
while(set_ptr->option)
|
||||
{
|
||||
if(!strcasecmp(av[2], set_ptr->option))
|
||||
break;
|
||||
set_ptr++;
|
||||
}
|
||||
if(!set_ptr->option) {
|
||||
prefmsg(u->nick, bot_ptr->nick,
|
||||
"Unknown set option. /msg %s HELP SET for more info",
|
||||
bot_ptr->nick);
|
||||
return 1;
|
||||
}
|
||||
switch(set_ptr->type) {
|
||||
case SET_TYPE_BOOLEAN:
|
||||
if (!strcasecmp(av[3], "ON")) {
|
||||
*(int*)set_ptr->varptr = 1;
|
||||
SetConf((void *) 1, CFGBOOL, set_ptr->confitem);
|
||||
chanalert(bot_ptr->nick, "%s enabled by \2%s\2",
|
||||
set_ptr->option, u->nick);
|
||||
nlog(LOG_NORMAL, LOG_MOD, "%s!%s@%s enabled %s",
|
||||
u->nick, u->username, u->hostname, set_ptr->option);
|
||||
prefmsg(u->nick, bot_ptr->nick,
|
||||
"\2%s\2 enabled", set_ptr->option);
|
||||
} else if (!strcasecmp(av[3], "OFF")) {
|
||||
*(int*)set_ptr->varptr = 0;
|
||||
SetConf(0, CFGBOOL, set_ptr->confitem);
|
||||
chanalert(bot_ptr->nick, "%s disabled by \2%s\2",
|
||||
set_ptr->option, u->nick);
|
||||
nlog(LOG_NORMAL, LOG_MOD, "%s!%s@%s disabled %s ",
|
||||
u->nick, u->username, u->hostname, set_ptr->option);
|
||||
prefmsg(u->nick, bot_ptr->nick,
|
||||
"\2%s\2 disabled", set_ptr->option);
|
||||
} else {
|
||||
prefmsg(u->nick, bot_ptr->nick,
|
||||
"Invalid Syntax. /msg %s HELP SET for more info",
|
||||
bot_ptr->nick);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case SET_TYPE_INT:
|
||||
case SET_TYPE_INTRANGE:
|
||||
case SET_TYPE_STRING:
|
||||
case SET_TYPE_STRINGRANGE:
|
||||
case SET_TYPE_NICK:
|
||||
case SET_TYPE_USER:
|
||||
case SET_TYPE_HOST:
|
||||
case SET_TYPE_RNAME:
|
||||
case SET_TYPE_CUSTOM:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
4
dl.h
4
dl.h
|
@ -132,6 +132,8 @@ typedef struct ModUser {
|
|||
unsigned int flags;
|
||||
/* hash for command list */
|
||||
hash_t *botcmds;
|
||||
/* hash for settings */
|
||||
bot_setting *bot_settings;
|
||||
/** bot message function */
|
||||
message_function function;
|
||||
/** channel message function */
|
||||
|
@ -241,7 +243,7 @@ void verify_hashes(void);
|
|||
int add_bot_cmd_list(ModUser *bot_ptr, bot_cmd *bot_cmd_list);
|
||||
int del_bot_cmd_list(ModUser *bot_ptr, bot_cmd *bot_cmd_list);
|
||||
int run_bot_cmd (ModUser *bot_ptr, User *u, char **av, int ac);
|
||||
ModUser * init_mod_bot (char * nick, char * user, char * host, char * rname, const char *modes, unsigned int flags, bot_cmd *bot_cmd_list, char * modname);
|
||||
ModUser * init_mod_bot (char * nick, char * user, char * host, char * rname, const char *modes, unsigned int flags, bot_cmd *bot_cmd_list, bot_setting *bot_setting_list, char * modname);
|
||||
int del_mod_bot (ModUser *bot_ptr, char * reason);
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
ConnectServ Module for NeoStats 2.x ChangeLog
|
||||
Shmad & ^Enigma^
|
||||
==============================================================================
|
||||
* Version 1.11 * Mark (M) * November 13, 2003
|
||||
* Version 1.11 * Mark (M) * December 2, 2003
|
||||
- Use core bot message handler to process commands (M)
|
||||
- Use core bot set handler (M)
|
||||
|
||||
* Version 1.10 * Mark (M) * November 13, 2003
|
||||
- Moved mode defines to ircd header files (M)
|
||||
|
|
19
dl/cs/cs.c
19
dl/cs/cs.c
|
@ -179,10 +179,19 @@ Functions __module_functions[] = {
|
|||
|
||||
static bot_cmd cs_commands[]=
|
||||
{
|
||||
{"SET", cs_set, 1, NS_ULEVEL_ADMIN, cs_help_set, 1, cs_help_set_oneline },
|
||||
{"ABOUT", cs_about, 0, NS_ULEVEL_ADMIN, cs_help_about, 1, cs_help_about_oneline },
|
||||
{"VERSION", cs_version, 0, NS_ULEVEL_ADMIN, cs_help_version,1, cs_help_version_oneline },
|
||||
{NULL, NULL, 0, 0, NULL, 0, NULL}
|
||||
/* {"SET", cs_set, 1, NS_ULEVEL_ADMIN, cs_help_set, cs_help_set_oneline },*/
|
||||
{"ABOUT", cs_about, 0, NS_ULEVEL_ADMIN, cs_help_about, cs_help_about_oneline },
|
||||
{"VERSION", cs_version, 0, NS_ULEVEL_ADMIN, cs_help_version,cs_help_version_oneline },
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static bot_setting cs_settings[]=
|
||||
{
|
||||
{"SIGNWATCH", &cs_cfg.sign_watch, SET_TYPE_BOOLEAN, 0, 0, "SignWatch" },
|
||||
{"KILLWATCH", &cs_cfg.kill_watch, SET_TYPE_BOOLEAN, 0, 0, "KillWatch" },
|
||||
{"MODEWATCH", &cs_cfg.mode_watch, SET_TYPE_BOOLEAN, 0, 0, "ModeWatch" },
|
||||
{"NICKWATCH", &cs_cfg.nick_watch, SET_TYPE_BOOLEAN, 0, 0, "NickWatch" },
|
||||
{NULL, NULL, 0, 0, 0, NULL, },
|
||||
};
|
||||
|
||||
static int cs_about(User * u, char **av, int ac)
|
||||
|
@ -226,7 +235,7 @@ static int cs_set(User * u, char **av, int ac)
|
|||
static int Online(char **av, int ac)
|
||||
{
|
||||
cs_bot = init_mod_bot(s_ConnectServ, cs_cfg.user, cs_cfg.host, cs_cfg.rname,
|
||||
services_bot_modes, BOT_FLAG_RESTRICT_OPERS, cs_commands, __module_info.module_name);
|
||||
services_bot_modes, BOT_FLAG_RESTRICT_OPERS, cs_commands, cs_settings, __module_info.module_name);
|
||||
if(cs_bot)
|
||||
cs_online = 1;
|
||||
return 1;
|
||||
|
|
|
@ -46,8 +46,8 @@ const char sr_help_list_oneline[] = "ServiceRoots List";
|
|||
|
||||
bot_cmd extauth_commands[]=
|
||||
{
|
||||
{"SRLIST", ext_auth_list, 0, NS_ULEVEL_OPER, sr_help_list, 0, sr_help_list_oneline},
|
||||
{NULL, NULL, 0, 0, NULL, 0, "\0"}
|
||||
{"SRLIST", ext_auth_list, 0, NS_ULEVEL_OPER, sr_help_list, sr_help_list_oneline},
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
ModuleInfo __module_info = {
|
||||
|
|
|
@ -289,17 +289,17 @@ Functions __module_functions[] = {
|
|||
|
||||
static bot_cmd hs_commands[]=
|
||||
{
|
||||
{"ABOUT", hs_about, 0, 0, hs_help_about, 1, hs_help_about_oneline },
|
||||
{"ADD", hs_add, 0, (int)&hs_cfg.add, hs_help_add, 1, hs_help_add_oneline },
|
||||
{"DEL", hs_del, 0, (int)&hs_cfg.del, hs_help_del, 1, hs_help_del_oneline },
|
||||
{"LIST", hs_list, 0, (int)&hs_cfg.list, hs_help_list, 1, hs_help_list_oneline },
|
||||
{"BANS", hs_bans, 0, NS_ULEVEL_ADMIN, hs_help_bans, 1, hs_help_bans_oneline },
|
||||
{"LEVELS", hs_levels, 0, NS_ULEVEL_OPER, hs_help_levels, 1, hs_help_levels_oneline },
|
||||
{"VIEW", hs_view, 0, (int)&hs_cfg.view, hs_help_view, 1, hs_help_view_oneline },
|
||||
{"LOGIN", hs_login, 0, 0, hs_help_login, 1, hs_help_login_oneline },
|
||||
{"CHPASS", hs_chpass, 0, 0, hs_help_chpass, 1, hs_help_chpass_oneline },
|
||||
{"SET", hs_set, 0, NS_ULEVEL_ADMIN, hs_help_set, 1, hs_help_set_oneline },
|
||||
{NULL, NULL, 0, 0, NULL, 0, NULL}
|
||||
{"ABOUT", hs_about, 0, 0, hs_help_about, hs_help_about_oneline },
|
||||
{"ADD", hs_add, 0, (int)&hs_cfg.add, hs_help_add, hs_help_add_oneline },
|
||||
{"DEL", hs_del, 0, (int)&hs_cfg.del, hs_help_del, hs_help_del_oneline },
|
||||
{"LIST", hs_list, 0, (int)&hs_cfg.list, hs_help_list, hs_help_list_oneline },
|
||||
{"BANS", hs_bans, 0, NS_ULEVEL_ADMIN, hs_help_bans, hs_help_bans_oneline },
|
||||
{"LEVELS", hs_levels, 0, NS_ULEVEL_OPER, hs_help_levels, hs_help_levels_oneline },
|
||||
{"VIEW", hs_view, 0, (int)&hs_cfg.view, hs_help_view, hs_help_view_oneline },
|
||||
{"LOGIN", hs_login, 0, 0, hs_help_login, hs_help_login_oneline },
|
||||
{"CHPASS", hs_chpass, 0, 0, hs_help_chpass, hs_help_chpass_oneline },
|
||||
{"SET", hs_set, 0, NS_ULEVEL_ADMIN, hs_help_set, hs_help_set_oneline },
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static int hs_set(User * u, char **av, int ac)
|
||||
|
@ -383,7 +383,7 @@ int Online(char **av, int ac)
|
|||
}
|
||||
|
||||
hs_bot = init_mod_bot(s_HostServ, user, host, rname,
|
||||
services_bot_modes, 0, hs_commands, __module_info.module_name);
|
||||
services_bot_modes, 0, hs_commands, NULL, __module_info.module_name);
|
||||
|
||||
if(user)
|
||||
free(user);
|
||||
|
|
|
@ -77,25 +77,25 @@ Functions __module_functions[] = {
|
|||
|
||||
static bot_cmd ls_commands[]=
|
||||
{
|
||||
{"ABOUT", ls_about, 0, 0, ls_help_about, 1, ls_help_about_oneline },
|
||||
{"ROSE", ls_rose, 1, 0, ls_help_rose, 1, ls_help_rose_oneline },
|
||||
{"KISS", ls_kiss, 1, 0, ls_help_kiss, 1, ls_help_kiss_oneline },
|
||||
{"TONSIL", ls_tonsil, 1, 0, ls_help_tonsil, 1, ls_help_tonsil_oneline },
|
||||
{"HUG", ls_hug, 1, 0, ls_help_hug, 1, ls_help_hug_oneline },
|
||||
{"ADMIRER", ls_admirer, 1, 0, ls_help_admirer, 1, ls_help_admirer_oneline },
|
||||
{"CHOCOLATE", ls_choco, 1, 0, ls_help_chocolate, 1, ls_help_chocolate_oneline },
|
||||
{"CANDY", ls_candy, 1, 0, ls_help_candy, 1, ls_help_candy_oneline },
|
||||
{"LOVENOTE", ls_lovenote, 2, 0, ls_help_lovenote, 1, ls_help_lovenote_oneline },
|
||||
{"APOLOGY", ls_apology, 2, 0, ls_help_apology, 1, ls_help_apology_oneline },
|
||||
{"THANKYOU", ls_thankyou, 2, 0, ls_help_thankyou, 1, ls_help_thankyou_oneline },
|
||||
{"VERSION", ls_version, 0, 0, ls_help_version, 1, ls_help_version_oneline },
|
||||
{NULL, NULL, 0, 0, NULL, 0, NULL}
|
||||
{"ABOUT", ls_about, 0, 0, ls_help_about, ls_help_about_oneline },
|
||||
{"ROSE", ls_rose, 1, 0, ls_help_rose, ls_help_rose_oneline },
|
||||
{"KISS", ls_kiss, 1, 0, ls_help_kiss, ls_help_kiss_oneline },
|
||||
{"TONSIL", ls_tonsil, 1, 0, ls_help_tonsil, ls_help_tonsil_oneline },
|
||||
{"HUG", ls_hug, 1, 0, ls_help_hug, ls_help_hug_oneline },
|
||||
{"ADMIRER", ls_admirer, 1, 0, ls_help_admirer, ls_help_admirer_oneline },
|
||||
{"CHOCOLATE", ls_choco, 1, 0, ls_help_chocolate, ls_help_chocolate_oneline },
|
||||
{"CANDY", ls_candy, 1, 0, ls_help_candy, ls_help_candy_oneline },
|
||||
{"LOVENOTE", ls_lovenote, 2, 0, ls_help_lovenote, ls_help_lovenote_oneline },
|
||||
{"APOLOGY", ls_apology, 2, 0, ls_help_apology, ls_help_apology_oneline },
|
||||
{"THANKYOU", ls_thankyou, 2, 0, ls_help_thankyou, ls_help_thankyou_oneline },
|
||||
{"VERSION", ls_version, 0, 0, ls_help_version, ls_help_version_oneline },
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
int Online(char **av, int ac)
|
||||
{
|
||||
ls_bot = init_mod_bot(s_LoveServ, "love", me.name, "Network Love Service",
|
||||
services_bot_modes, 0, ls_commands, __module_info.module_name);
|
||||
services_bot_modes, 0, ls_commands, NULL, __module_info.module_name);
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
|
24
dl/ms/ms.c
24
dl/ms/ms.c
|
@ -74,23 +74,23 @@ Functions __module_functions[] = {
|
|||
|
||||
static bot_cmd ms_commands[]=
|
||||
{
|
||||
{"HAIL", ms_hail, 2, 0, ms_help_hail, 1, ms_help_hail_oneline },
|
||||
{"ODE", ms_ode, 2, 0, ms_help_ode, 1, ms_help_ode_oneline },
|
||||
{"LAPDANCE", ms_lapdance, 1, 0, ms_help_lapdance, 1, ms_help_lapdance_oneline },
|
||||
{"VERSION", ms_version, 0, 0, ms_help_version, 1, ms_help_version_oneline },
|
||||
{"ABOUT", ms_about, 0, 0, ms_help_about, 1, ms_help_about_oneline },
|
||||
{"POEM", ms_poem, 2, 0, ms_help_poem, 1, ms_help_poem_oneline },
|
||||
{"REDNECK", ms_redneck, 1, 0, ms_help_redneck, 1, ms_help_redneck_oneline },
|
||||
{"CHEERUP", ms_cheerup, 1, 0, ms_help_cheerup, 1, ms_help_cheerup_oneline },
|
||||
{"BEHAPPY", ms_behappy, 1, 0, ms_help_behappy, 1, ms_help_behappy_oneline },
|
||||
{"WONDERFUL", ms_wonderful, 1, 0, ms_help_wonderful, 1, ms_help_wonderful_oneline },
|
||||
{NULL, NULL, 0, 0, NULL, 0, NULL}
|
||||
{"HAIL", ms_hail, 2, 0, ms_help_hail, ms_help_hail_oneline },
|
||||
{"ODE", ms_ode, 2, 0, ms_help_ode, ms_help_ode_oneline },
|
||||
{"LAPDANCE", ms_lapdance, 1, 0, ms_help_lapdance, ms_help_lapdance_oneline },
|
||||
{"VERSION", ms_version, 0, 0, ms_help_version, ms_help_version_oneline },
|
||||
{"ABOUT", ms_about, 0, 0, ms_help_about, ms_help_about_oneline },
|
||||
{"POEM", ms_poem, 2, 0, ms_help_poem, ms_help_poem_oneline },
|
||||
{"REDNECK", ms_redneck, 1, 0, ms_help_redneck, ms_help_redneck_oneline },
|
||||
{"CHEERUP", ms_cheerup, 1, 0, ms_help_cheerup, ms_help_cheerup_oneline },
|
||||
{"BEHAPPY", ms_behappy, 1, 0, ms_help_behappy, ms_help_behappy_oneline },
|
||||
{"WONDERFUL", ms_wonderful, 1, 0, ms_help_wonderful, ms_help_wonderful_oneline },
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
int Online(char **av, int ac)
|
||||
{
|
||||
ms_bot = init_mod_bot(s_MoraleServ, "MS", me.name, "A Network Morale Service",
|
||||
services_bot_modes, 0, ms_commands, __module_info.module_name);
|
||||
services_bot_modes, 0, ms_commands, NULL, __module_info.module_name);
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
|
|
@ -555,7 +555,7 @@ int Online(char **av, int ac)
|
|||
{
|
||||
SET_SEGV_LOCATION();
|
||||
ss_bot = init_mod_bot(s_StatServ, StatServ.user, StatServ.host, StatServ.rname,
|
||||
services_bot_modes, BOT_FLAG_ONLY_OPERS, ss_commands, s_StatServ);
|
||||
services_bot_modes, BOT_FLAG_ONLY_OPERS, ss_commands, NULL, __module_info.module_name);
|
||||
|
||||
StatServ.onchan = 1;
|
||||
/* now that we are online, setup the timer to save the Stats database every so often */
|
||||
|
|
|
@ -248,24 +248,24 @@ void __ModFini()
|
|||
|
||||
bot_cmd ss_commands[]=
|
||||
{
|
||||
{"ABOUT", ss_about, 0, NS_ULEVEL_OPER, ss_help_about, 1, ss_help_about_oneline},
|
||||
{"VERSION", ss_version, 0, NS_ULEVEL_OPER, ss_help_version, 1, ss_help_version_oneline},
|
||||
{"SERVER", ss_server, 0, NS_ULEVEL_OPER, ss_help_server, 1, ss_help_server_oneline},
|
||||
{"MAP", ss_map, 0, NS_ULEVEL_OPER, ss_help_map, 1, ss_help_map_oneline},
|
||||
{"CHAN", ss_chans, 0, NS_ULEVEL_OPER, ss_help_chan, 1, ss_help_chan_oneline},
|
||||
{"NETSTATS", ss_netstats, 0, NS_ULEVEL_OPER, ss_help_netstats, 1, ss_help_netstats_oneline},
|
||||
{"DAILY", ss_daily, 0, NS_ULEVEL_OPER, ss_help_daily, 1, ss_help_daily_oneline},
|
||||
{"TLD", ss_tld, 1, NS_ULEVEL_OPER, ss_help_tld, 1, ss_help_tld_oneline},
|
||||
{"TLDMAP", ss_tld_map, 0, NS_ULEVEL_OPER, ss_help_tldmap, 1, ss_help_tldmap_oneline},
|
||||
{"OPERLIST", ss_operlist, 0, NS_ULEVEL_OPER, ss_help_operlist, 1, ss_help_operlist_oneline},
|
||||
#ifdef HAVE_BOT_MODE
|
||||
{"BOTLIST", ss_botlist, 0, NS_ULEVEL_OPER, ss_help_botlist, 1, ss_help_botlist_oneline},
|
||||
{"ABOUT", ss_about, 0, NS_ULEVEL_OPER, ss_help_about, ss_help_about_oneline},
|
||||
{"VERSION", ss_version, 0, NS_ULEVEL_OPER, ss_help_version, ss_help_version_oneline},
|
||||
{"SERVER", ss_server, 0, NS_ULEVEL_OPER, ss_help_server, ss_help_server_oneline},
|
||||
{"MAP", ss_map, 0, NS_ULEVEL_OPER, ss_help_map, ss_help_map_oneline},
|
||||
{"CHAN", ss_chans, 0, NS_ULEVEL_OPER, ss_help_chan, ss_help_chan_oneline},
|
||||
{"NETSTATS", ss_netstats, 0, NS_ULEVEL_OPER, ss_help_netstats, ss_help_netstats_oneline},
|
||||
{"DAILY", ss_daily, 0, NS_ULEVEL_OPER, ss_help_daily, ss_help_daily_oneline},
|
||||
{"TLD", ss_tld, 1, NS_ULEVEL_OPER, ss_help_tld, ss_help_tld_oneline},
|
||||
{"TLDMAP", ss_tld_map, 0, NS_ULEVEL_OPER, ss_help_tldmap, ss_help_tldmap_oneline},
|
||||
{"OPERLIST", ss_operlist, 0, NS_ULEVEL_OPER, ss_help_operlist, ss_help_operlist_oneline},
|
||||
#ifdef HAVE_BOT_MODE
|
||||
{"BOTLIST", ss_botlist, 0, NS_ULEVEL_OPER, ss_help_botlist, ss_help_botlist_oneline},
|
||||
#endif
|
||||
{"CLIENTVERSIONS", ss_clientversions,0,NS_ULEVEL_OPER, ss_help_clientversions,1, ss_help_clientversions_oneline},
|
||||
{"SET", ss_set, 1, NS_ULEVEL_ADMIN,ss_help_set, 1, ss_help_set_oneline},
|
||||
{"FORCEHTML", ss_forcehtml, 0, NS_ULEVEL_ADMIN,ss_help_forcehtml, 1, ss_help_forcehtml_oneline},
|
||||
{"STATS", ss_stats, 1, NS_ULEVEL_ADMIN,ss_help_stats, 1, ss_help_stats_oneline},
|
||||
{NULL, NULL, 0, 0, NULL, 0, NULL}
|
||||
{"CLIENTVERSIONS", ss_clientversions,0,NS_ULEVEL_OPER, ss_help_clientversions, ss_help_clientversions_oneline},
|
||||
{"SET", ss_set, 1, NS_ULEVEL_ADMIN, ss_help_set, ss_help_set_oneline},
|
||||
{"FORCEHTML", ss_forcehtml, 0, NS_ULEVEL_ADMIN, ss_help_forcehtml, ss_help_forcehtml_oneline},
|
||||
{"STATS", ss_stats, 1, NS_ULEVEL_ADMIN, ss_help_stats, ss_help_stats_oneline},
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static int ss_set(User * u, char **av, int ac)
|
||||
|
|
6
ircd.c
6
ircd.c
|
@ -119,9 +119,9 @@ init_bot (char *nick, char *user, char *host, char *rname, const char *modes, ch
|
|||
*/
|
||||
ModUser * init_mod_bot (char * nick, char * user, char * host, char * rname,
|
||||
const char *modes, unsigned int flags, bot_cmd *bot_cmd_list,
|
||||
char * mod_name)
|
||||
bot_setting *bot_setting_list, char * mod_name)
|
||||
{
|
||||
ModUser * bot_ptr;
|
||||
ModUser * bot_ptr;
|
||||
User *u;
|
||||
char **av;
|
||||
int ac = 0;
|
||||
|
@ -150,7 +150,7 @@ ModUser * init_mod_bot (char * nick, char * user, char * host, char * rname,
|
|||
SET_SEGV_INMODULE(mod_name);
|
||||
bot_ptr->flags = flags;
|
||||
add_bot_cmd_list(bot_ptr, bot_cmd_list);
|
||||
|
||||
bot_ptr->bot_settings = bot_setting_list;
|
||||
return bot_ptr;
|
||||
}
|
||||
|
||||
|
|
42
services.c
42
services.c
|
@ -57,28 +57,28 @@ static char no_reason[]="no reason given";
|
|||
|
||||
static bot_cmd ns_commands[]=
|
||||
{
|
||||
{"LEVEL", ns_level, 0, 0, ns_help_level, 1, ns_help_level_oneline},
|
||||
{"INFO", ns_info, 0, 0, ns_help_info, 1, ns_help_info_oneline},
|
||||
{"VERSION", ns_version, 0, 0, ns_help_version, 1, ns_help_version_oneline},
|
||||
{"SHUTDOWN", ns_shutdown, 0, NS_ULEVEL_ADMIN, ns_help_shutdown, 1, ns_help_shutdown_oneline},
|
||||
{"RELOAD", ns_reload, 0, NS_ULEVEL_ADMIN, ns_help_reload, 1, ns_help_reload_oneline},
|
||||
{"LOGS", ns_logs, 0, NS_ULEVEL_OPER, ns_help_logs, 1, ns_help_logs_oneline},
|
||||
{"MODLIST", list_modules, 0, NS_ULEVEL_ADMIN, ns_help_modlist, 1, ns_help_modlist_oneline},
|
||||
{"LOAD", ns_load, 1, NS_ULEVEL_ADMIN, ns_help_load, 1, ns_help_load_oneline},
|
||||
{"UNLOAD", ns_unload,1, NS_ULEVEL_ADMIN, ns_help_unload, 1, ns_help_unload_oneline},
|
||||
{"JUPE", ns_jupe, 1, NS_ULEVEL_ADMIN, ns_help_jupe, 1, ns_help_jupe_oneline},
|
||||
{"LEVEL", ns_level, 0, 0, ns_help_level, ns_help_level_oneline},
|
||||
{"INFO", ns_info, 0, 0, ns_help_info, ns_help_info_oneline},
|
||||
{"VERSION", ns_version, 0, 0, ns_help_version, ns_help_version_oneline},
|
||||
{"SHUTDOWN", ns_shutdown, 0, NS_ULEVEL_ADMIN, ns_help_shutdown, ns_help_shutdown_oneline},
|
||||
{"RELOAD", ns_reload, 0, NS_ULEVEL_ADMIN, ns_help_reload, ns_help_reload_oneline},
|
||||
{"LOGS", ns_logs, 0, NS_ULEVEL_OPER, ns_help_logs, ns_help_logs_oneline},
|
||||
{"MODLIST", list_modules, 0, NS_ULEVEL_ADMIN, ns_help_modlist, ns_help_modlist_oneline},
|
||||
{"LOAD", ns_load, 1, NS_ULEVEL_ADMIN, ns_help_load, ns_help_load_oneline},
|
||||
{"UNLOAD", ns_unload, 1, NS_ULEVEL_ADMIN, ns_help_unload, ns_help_unload_oneline},
|
||||
{"JUPE", ns_jupe, 1, NS_ULEVEL_ADMIN, ns_help_jupe, ns_help_jupe_oneline},
|
||||
#ifdef USE_RAW
|
||||
{"RAW", ns_raw, 0, NS_ULEVEL_ADMIN, ns_help_raw, 1, ns_help_raw_oneline},
|
||||
#endif
|
||||
{"DEBUG", ns_set_debug, 1, NS_ULEVEL_ROOT, ns_help_debug, 1, ns_help_debug_oneline},
|
||||
{"BOTLIST", list_bots, 0, NS_ULEVEL_ROOT, ns_help_botlist, 1, ns_help_botlist_oneline},
|
||||
{"SOCKLIST", list_sockets, 0, NS_ULEVEL_ROOT, ns_help_socklist, 1, ns_help_socklist_oneline},
|
||||
{"TIMERLIST", list_timers, 0, NS_ULEVEL_ROOT, ns_help_timerlist, 1, ns_help_timerlist_oneline},
|
||||
{"BOTCHANLIST", list_bot_chans, 0, NS_ULEVEL_ROOT, ns_help_botchanlist,1, ns_help_botchanlist_oneline},
|
||||
{"USERDUMP", ns_userdump, 0, NS_ULEVEL_ROOT, ns_help_userdump, 1, ns_help_userdump_oneline},
|
||||
{"CHANDUMP", ns_chandump, 0, NS_ULEVEL_ROOT, ns_help_chandump, 1, ns_help_chandump_oneline},
|
||||
{"SERVERDUMP", ns_serverdump, 0, NS_ULEVEL_ROOT, ns_help_serverdump, 1, ns_help_serverdump_oneline},
|
||||
{NULL, NULL, 0, 0, NULL, 0, NULL}
|
||||
{"RAW", ns_raw, 0, NS_ULEVEL_ADMIN, ns_help_raw, ns_help_raw_oneline},
|
||||
#endif
|
||||
{"DEBUG", ns_set_debug, 1, NS_ULEVEL_ROOT, ns_help_debug, ns_help_debug_oneline},
|
||||
{"BOTLIST", list_bots, 0, NS_ULEVEL_ROOT, ns_help_botlist, ns_help_botlist_oneline},
|
||||
{"SOCKLIST", list_sockets, 0, NS_ULEVEL_ROOT, ns_help_socklist, ns_help_socklist_oneline},
|
||||
{"TIMERLIST", list_timers, 0, NS_ULEVEL_ROOT, ns_help_timerlist, ns_help_timerlist_oneline},
|
||||
{"BOTCHANLIST", list_bot_chans, 0, NS_ULEVEL_ROOT, ns_help_botchanlist,ns_help_botchanlist_oneline},
|
||||
{"USERDUMP", ns_userdump, 0, NS_ULEVEL_ROOT, ns_help_userdump, ns_help_userdump_oneline},
|
||||
{"CHANDUMP", ns_chandump, 0, NS_ULEVEL_ROOT, ns_help_chandump, ns_help_chandump_oneline},
|
||||
{"SERVERDUMP", ns_serverdump, 0, NS_ULEVEL_ROOT, ns_help_serverdump, ns_help_serverdump_oneline},
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/** @brief init services
|
||||
|
|
22
stats.h
22
stats.h
|
@ -345,9 +345,7 @@ struct ping {
|
|||
/** @brief flags for command list
|
||||
* flags to provide more information on a command to the core
|
||||
*/
|
||||
#define CMD_FLAG_NORMAL 0x00000001
|
||||
#define CMD_FLAG_SET 0x00000002
|
||||
#define CMD_FLAG_HELP 0x00000004
|
||||
#define CMD_FLAG_SET 0x00000001
|
||||
|
||||
/** @brief bot_cmd_handler type
|
||||
* defines handler function definition
|
||||
|
@ -363,8 +361,7 @@ typedef struct bot_cmd {
|
|||
int minparams; /* min num params */
|
||||
unsigned int ulevel; /* min user level */
|
||||
const char** helptext; /* pointer to help text */
|
||||
int internal; /* is this a internal function? */
|
||||
const char* onelinehelp; /* single line help for generic help function */
|
||||
const char* onelinehelp;/* single line help for generic help function */
|
||||
}bot_cmd;
|
||||
|
||||
/** @brief flags for bots
|
||||
|
@ -373,11 +370,13 @@ typedef struct bot_cmd {
|
|||
*/
|
||||
|
||||
/* Restrict module bot to only respond to oper requests
|
||||
* when ONLY_OPERS is set in the config file
|
||||
* when ONLY_OPERS is set in the config file
|
||||
* E.g. StatServ
|
||||
*/
|
||||
#define BOT_FLAG_ONLY_OPERS 0x00000001
|
||||
/* Restrict module bot to only respond to oper requests
|
||||
* regardless of ONLY_OPERS setting in the config file
|
||||
* E.g. Connectserv
|
||||
*/
|
||||
#define BOT_FLAG_RESTRICT_OPERS 0x00000002
|
||||
|
||||
|
@ -399,16 +398,19 @@ typedef enum SET_TYPE {
|
|||
|
||||
/* "TESTSTRING", &teststring, TYPE_STRING, 0,string_buffer_size
|
||||
"TESTINT", &testint, TYPE_INT 0, 200 */
|
||||
typedef struct bot_settings {
|
||||
const char *option; /* option string */
|
||||
typedef struct bot_setting {
|
||||
char *option; /* option string */
|
||||
void* varptr; /* pointer to var */
|
||||
SET_TYPE type; /* type of var */
|
||||
unsigned int min; /* min value */
|
||||
unsigned int max; /* max value */
|
||||
const char *confitem; /* config string for kptool */
|
||||
char *confitem; /* config string for kptool */
|
||||
#if 0 /* Work in progress */
|
||||
const char *desc; /* description of setting for messages */
|
||||
bot_cmd_handler handler; /* handler for custom/post-set processing */
|
||||
}bot_settings;
|
||||
const char** helptext; /* pointer to help text */
|
||||
#endif
|
||||
}bot_setting;
|
||||
|
||||
/* sock.c */
|
||||
int sock_connect (int socktype, unsigned long ipaddr, int port, char *sockname, char *module, char *func_read, char *func_write, char *func_error);
|
||||
|
|
Reference in a new issue