added possibility to require users to be authenticated when taking a NeonHelp request
authorpk910 <philipp@zoelle1.de>
Thu, 22 Nov 2012 16:53:43 +0000 (17:53 +0100)
committerpk910 <philipp@zoelle1.de>
Thu, 22 Nov 2012 16:53:43 +0000 (17:53 +0100)
src/modules/NeonHelp.mod/bot_NeonHelp.c

index 84448b1..5a6abbf 100644 (file)
@@ -203,6 +203,16 @@ static TIMEQ_CALLBACK(neonhelp_remind_open_requests);
 static void neonhelp_event_privmsg_async(struct ClientSocket *client, struct UserNode *user, struct UserNode *target, char *message) {
     MYSQL_RES *res;
     MYSQL_ROW row, row2;
 static void neonhelp_event_privmsg_async(struct ClientSocket *client, struct UserNode *user, struct UserNode *target, char *message) {
     MYSQL_RES *res;
     MYSQL_ROW row, row2;
+    char setting[128];
+    sprintf(setting, "modules.%s.need_auth", get_module_name(module_id));
+    if(get_int_field(setting) && !(user->flags & USERFLAG_ISAUTHED)) {
+        sprintf(setting, "modules.%s.need_auth_message", get_module_name(module_id));
+        char *message;
+        if(!(message = get_string_field(setting)))
+            message = get_language_string(user, "MODCMD_AUTH_REQUIRED");
+        reply(client, user, "%s", message);
+        return;
+    }
     printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern`, `helpserv_intern_announce` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", client->clientid);
     res = mysql_use();
     if (!(row = mysql_fetch_row(res))) return;
     printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern`, `helpserv_intern_announce` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", client->clientid);
     res = mysql_use();
     if (!(row = mysql_fetch_row(res))) return;