Anope IRC Services
Anope Development => Modules => Topic started by: CrazyCat on December 15, 2011, 10:48:52 AM
-
Hello there,
I've a few idea about bs_quotes and I need your feedback before beginning develop them:
- Having MySQL config optional, using the main Anope MySQL config as default.
- Allow to change the level to add a quote via a in-code config.
- Limit the random display to the quotes from the channel.
- Allow to display (or not) the infos about the quote.
- Your ideas ?
-
Hello there,
I'm a really beginner in C and I've a small question for you.
I want, as said in my previous post, make the mysql config optional. So, the wanted working might be: if QuoteMySQLHost isn't defined in config, use MySQLHost. And if it isn't defined, return error.
What I did:
char *Q_MYSQL_HOST = NULL;
/* ... now in load_config, called by AnopeInit */
Directive confvalues[][1] = {
{{ "QuoteMySQLHost", { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_HOST } } }},
{{ "QuoteMySQLPort", { { PARAM_PORT, PARAM_RELOAD, &Q_MYSQL_PORT } } }},
{{ "QuoteMySQLSocket", { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_SOCK } } }},
{{ "QuoteMySQLUser", { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_USER } } }},
{{ "QuoteMySQLPassword", { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_PASS } } }},
{{ "QuoteMySQLDatabase", { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_DB } } }},
{{ "QuoteEnableMultiLine", { { PARAM_SET, PARAM_RELOAD, &Q_ENABLE_MULTILINE } } }},
{{ "QuoteMySQLTable", { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_TABLE } } }}
};
/* Setting of MySQLHost */
moduleGetConfigDirective(confvalues[0]);
if (!Q_MYSQL_HOST) {
Directive confvalues[0][1] = {
{{ "MySQLHost", { { PARAM_STRING, PARAM_RELOAD, &Q_MYSQL_HOST } } }}
};
moduleGetConfigDirective(confvalues[0]);
if (!Q_MYSQL_HOST) { alog("[\002bs_quotes\002]: Missing config options!"); return MOD_STOP; }
}
/* Will be done for sock, user, pass, db */
I wonder there is a better way to do this, so I ask you : wich ?
Thanks a lot !