+++ /dev/null
-/* cmd_neonserv_help.c - NeonServ v5.3
- * Copyright (C) 2011-2012 Philipp Kreil (pk910)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "cmd_neonserv.h"
-
-/*
-* argv[0-*] index
-*/
-
-CMD_BIND(neonserv_cmd_help) {
- char *ident;
- if(argc)
- ident = merge_argv(argv, 0, argc);
- else
- ident = "0";
- MYSQL_RES *res;
- MYSQL_ROW row;
- printf_mysql_query("SELECT `user_lang` FROM `users` WHERE `user_user` = '%s'", escape_string(user->auth));
- res = mysql_use();
- char *lang;
- if ((row = mysql_fetch_row(res)) != NULL)
- lang = row[0];
- else
- lang = "en";
- printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = '%s' AND `ident` = '%s'", escape_string(lang), escape_string(ident));
- res = mysql_use();
- if ((row = mysql_fetch_row(res)) == NULL) {
- if(stricmp(lang, "en")) {
- printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = 'en' AND `ident` = '%s'", escape_string(ident));
- res = mysql_use();
- }
- if ((row = mysql_fetch_row(res)) == NULL) {
- reply(getTextBot(), user, "NS_HELP_TOPIC");
- return;
- }
- }
- char sendBuf[MAXLEN];
- int sendBufPos = 0;
- int i;
- for(i = 0; i < strlen(row[0]); i++) {
- switch(row[0][i]) {
- case '\n':
- if(sendBufPos) {
- sendBuf[sendBufPos] = '\0';
- reply(getTextBot(), user, "%s", sendBuf);
- sendBufPos = 0;
- }
- break;
- case '$':
- switch(row[0][i+1]) {
- case 'b':
- sendBuf[sendBufPos++] = 2;
- i++;
- break;
- case 'k':
- sendBuf[sendBufPos++] = 3;
- i++;
- break;
- case 'u':
- sendBuf[sendBufPos++] = 31;
- i++;
- break;
- case 'C':
- case 'S':
- sendBufPos += sprintf(sendBuf + sendBufPos, "%s", client->user->nick);
- i++;
- break;
- default:
- sendBuf[sendBufPos++] = '$';
- break;
- }
- break;
- default:
- sendBuf[sendBufPos++] = row[0][i];
- break;
- }
- }
- if(sendBufPos) {
- sendBuf[sendBufPos] = '\0';
- reply(getTextBot(), user, "%s", sendBuf);
- sendBufPos = 0;
- }
-}