Author: DNB
Date: Wed Apr 6 23:13:15 2005
New Revision: 77
Modified:
branches/3.0/ChangeLog
branches/3.0/TriviaQues.c
branches/3.0/TriviaServ.c
branches/3.0/TriviaServ.h
Log:
remove BOT_FLAG_RESTRICT_OPERS
update to ADMIN to add Trivia channels
fix bug trying to select question 0 in a file (question numbers start at 1)
code tidyups
Modified: branches/3.0/ChangeLog
==============================================================================
--- branches/3.0/ChangeLog (original)
+++ branches/3.0/ChangeLog Wed Apr 6 23:13:15 2005
@@ -2,6 +2,10 @@
Fish (F), Mark (M), DeadNotBuried (D)
==============================================================================
3.0.a3-dev
+ - remove BOT_FLAG_RESTRICT_OPERS so channel ops can use channel commands
+ to set channel options (D)
+ - set to ADMIN and above to add Trivia channels (D)
+ - fix bug trying to select question 0 in a file, should start at number 1 (D)
- save user scores on module unloading (D)
- save and reload Channel Question Sets settings (D)
- check saved scores on Registering/Identifying for NickName if scores
Modified: branches/3.0/TriviaQues.c
==============================================================================
--- branches/3.0/TriviaQues.c (original)
+++ branches/3.0/TriviaQues.c Wed Apr 6 23:13:15 2005
@@ -103,7 +103,7 @@
* Adds/Removes/Lists or resets to default
* Category Entries/Question Sets for a channel
*/
-void tvs_quesset(CmdParams* cmdparams, TriviaChan *tc, char *cn)
+void tvs_quesset(CmdParams* cmdparams, TriviaChan *tc, char *qsn)
{
lnode_t *lnode;
QuestionFiles *qf;
@@ -111,9 +111,9 @@
if (!cmdparams) {
/* Adds categories to channel on module loading */
- lnode = list_find(qfl, cn, find_cat_name);
+ lnode = list_find(qfl, qsn, find_cat_name);
if (lnode) {
- if (list_find(tc->qfl, cn, find_cat_name)) {
+ if (list_find(tc->qfl, qsn, find_cat_name)) {
return;
} else {
qf = lnode_get(lnode);
@@ -181,19 +181,15 @@
return;
}
} else if (!ircstrcasecmp(cmdparams->av[0], "RESET")) {
- /* first we remove all entries from Channel Question Sets DB */
tcqf = ns_calloc(sizeof(TriviaChannelQuestionFiles));
- while (lnode != NULL) {
+ while (!list_isempty(tc->qfl)) {
+ lnode = list_first(tc->qfl);
qf = lnode_get(lnode);
ircsnprintf(tcqf->savename, MAXCHANLEN+QUESTSIZE+1, "%s%s", qf->name, tc->c->name);
DBADelete("CQSets", tcqf->savename);
- lnode = list_next(tc->qfl, lnode);
- }
- ns_free(tcqf);
- /* then remove the list nodes */
- while (!list_isempty(tc->qfl)) {
list_destroy_nodes(tc->qfl);
}
+ ns_free(tcqf);
irc_prefmsg (tvs_bot, cmdparams->source, "Reset the Question Catagories to Default in %s", tc->name);
irc_chanprivmsg (tvs_bot, tc->name, "%s reset the Question Categories to Default", cmdparams->source->name);
return;
@@ -216,12 +212,13 @@
if (list_isempty(tc->qfl)) {
/* if the qfl for this chan is empty, use all qfl's */
if (list_count(qfl) > 1)
+ {
qfn=(unsigned)(rand()%((int)(list_count(qfl))));
- else
+ } else {
qfn= 0;
+ }
/* ok, this is bad.. but sigh, not much we can do atm. */
lnode = list_first(qfl);
- qf = lnode_get(lnode);
i = 0;
while (i != qfn) {
lnode = list_next(qfl, lnode);
@@ -241,7 +238,6 @@
qfn=(unsigned)(rand()%((int)(list_count(tc->qfl))));
/* ok, this is bad.. but sigh, not much we can do atm. */
lnode = list_first(tc->qfl);
- qf = lnode_get(lnode);
i = 0;
while (i != qfn) {
lnode = list_next(tc->qfl, lnode);
@@ -275,7 +271,7 @@
qf = tvs_randomquestfile(tc);
restartquestionselection:
- qn=(unsigned)(rand()%((int)(list_count(qf->QE)-1)));
+ qn=(unsigned)((rand()%((int)(list_count(qf->QE))))+1);
/* ok, this is bad.. but sigh, not much we can do atm. */
qnode = list_first(qf->QE);
qe = NULL;
Modified: branches/3.0/TriviaServ.c
==============================================================================
--- branches/3.0/TriviaServ.c (original)
+++ branches/3.0/TriviaServ.c Wed Apr 6 23:13:15 2005
@@ -80,25 +80,25 @@
static bot_cmd tvs_commands[]=
{
- {"CHANS", tvs_chans, 1, NS_ULEVEL_OPER, tvs_help_chans, tvs_help_chans_oneline },
- {"CATLIST", tvs_catlist, 0, 0, tvs_help_catlist, tvs_help_catlist_oneline },
- {"SCORE", tvs_cmd_score, 0, 0, NULL, NULL},
- {"HINT", tvs_cmd_hint, 0, 0, NULL, NULL},
- {"START", tvs_cmd_start, 0, 0, tvs_help_start, tvs_help_start_oneline, CMD_FLAG_CHANONLY},
- {"STOP", tvs_cmd_stop, 0, 0, tvs_help_stop, tvs_help_stop_oneline, CMD_FLAG_CHANONLY},
- {"QS", tvs_cmd_qs, 1, 0, tvs_help_qs, tvs_help_qs_oneline, CMD_FLAG_CHANONLY},
- {"SETPOINTS", tvs_cmd_sp, 1, 0, tvs_help_sp, tvs_help_sp_oneline, CMD_FLAG_CHANONLY},
- {"PUBLIC", tvs_cmd_pc, 1, 0, tvs_help_pc, tvs_help_pc_oneline, CMD_FLAG_CHANONLY},
- {"OPCHAN", tvs_cmd_opchan, 1, 0, tvs_help_opchan, tvs_help_opchan_oneline, CMD_FLAG_CHANONLY},
- {"RESETSCORES", tvs_cmd_resetscores, 1, 0, tvs_help_resetscores, tvs_help_resetscores_oneline, CMD_FLAG_CHANONLY},
- {NULL, NULL, 0, 0, NULL, NULL}
+ {"CHANS", tvs_chans, 1, NS_ULEVEL_ADMIN, tvs_help_chans, tvs_help_chans_oneline },
+ {"CATLIST", tvs_catlist, 0, 0, tvs_help_catlist, tvs_help_catlist_oneline },
+ {"SCORE", tvs_cmd_score, 0, 0, NULL, NULL},
+ {"HINT", tvs_cmd_hint, 0, 0, NULL, NULL},
+ {"START", tvs_cmd_start, 0, 0, tvs_help_start, tvs_help_start_oneline, CMD_FLAG_CHANONLY},
+ {"STOP", tvs_cmd_stop, 0, 0, tvs_help_stop, tvs_help_stop_oneline, CMD_FLAG_CHANONLY},
+ {"QS", tvs_cmd_qs, 1, 0, tvs_help_qs, tvs_help_qs_oneline, CMD_FLAG_CHANONLY},
+ {"SETPOINTS", tvs_cmd_sp, 1, 0, tvs_help_sp, tvs_help_sp_oneline, CMD_FLAG_CHANONLY},
+ {"PUBLIC", tvs_cmd_pc, 1, 0, tvs_help_pc, tvs_help_pc_oneline, CMD_FLAG_CHANONLY},
+ {"OPCHAN", tvs_cmd_opchan, 1, 0, tvs_help_opchan, tvs_help_opchan_oneline, CMD_FLAG_CHANONLY},
+ {"RESETSCORES", tvs_cmd_resetscores, 1, 0, tvs_help_resetscores, tvs_help_resetscores_oneline, CMD_FLAG_CHANONLY},
+ {NULL, NULL, NULL, NULL, NULL, NULL}
};
static bot_setting tvs_settings[]=
{
{"EXCLUSIONS", &TriviaServ.use_exc, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, tvs_help_set_exclusions, NULL, (void *) 0},
- {"DEFAULTPOINTS", &TriviaServ.defaultpoints, SET_TYPE_INT, 1, 25, NS_ULEVEL_ADMIN, NULL, tvs_help_set_defaultpoints, NULL, (void *)1 },
- {NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL},
+ {"DEFAULTPOINTS", &TriviaServ.defaultpoints, SET_TYPE_INT, 1, 25, NS_ULEVEL_ADMIN, NULL, tvs_help_set_defaultpoints, NULL, (void *) 1},
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
};
/*
@@ -132,7 +132,7 @@
"TS",
BOT_COMMON_HOST,
"Trivia Bot",
- BOT_FLAG_SERVICEBOT|BOT_FLAG_RESTRICT_OPERS,
+ BOT_FLAG_SERVICEBOT,
tvs_commands,
tvs_settings,
};
Modified: branches/3.0/TriviaServ.h
==============================================================================
--- branches/3.0/TriviaServ.h (original)
+++ branches/3.0/TriviaServ.h Wed Apr 6 23:13:15 2005
@@ -167,7 +167,7 @@
/* TriviaQues.c */
void tvs_parse_questions();
int find_cat_name(const void *catnode, const void *name);
-void tvs_quesset(CmdParams* cmdparams, TriviaChan *tc, char *cn);
+void tvs_quesset(CmdParams* cmdparams, TriviaChan *tc, char *qsn);
QuestionFiles *tvs_randomquestfile(TriviaChan *tc);
void tvs_newquest(TriviaChan *tc);
void tvs_ansquest(TriviaChan *tc);
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.