--- /dev/null
+
+#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++] = '\002';
+ i++;
+ break;
+ case 'k':
+ sendBuf[sendBufPos++] = '\003';
+ i++;
+ break;
+ case 'u':
+ sendBuf[sendBufPos++] = '\031';
+ 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;
+ }
+}