fixed #989cb8324ec8fe9caba511d89051552638dbc776
authorpk910 <philipp@zoelle1.de>
Wed, 4 Jan 2012 22:44:28 +0000 (23:44 +0100)
committerpk910 <philipp@zoelle1.de>
Wed, 4 Jan 2012 23:17:31 +0000 (00:17 +0100)
src/bot_NeonHelp.c
src/cmd_neonhelp.h
src/cmd_neonhelp_delete.c
src/cmd_neonhelp_next.c
src/commands.c

index 1ff01ccf2a30b7f267a1cba58e839d134747c06b..506a797446c49ac18244a0ea4cc9fd30316c867c 100644 (file)
@@ -18,6 +18,7 @@
 #include "bot_NeonHelp.h"
 #include "modcmd.h"
 #include "cmd_neonhelp.h"
+#include "lang.h"
 #include "mysqlConn.h"
 #include "ClientSocket.h"
 #include "UserNode.h"
@@ -27,6 +28,7 @@
 #include "IRCParser.h"
 #include "bots.h"
 #include "DBHelper.h"
+#include "WHOHandler.h"
 
 #define BOTID 4
 #define BOTALIAS "NeonHelp"
@@ -38,8 +40,8 @@ static const struct default_language_entry msgtab[] = {
     {"NH_REQUEST_OTHERS_0", "There are no other unhandled requests."},
     {"NH_REQUEST_OTHERS_1", "There is 1 other unhandled request."},
     {"NH_REQUEST_OTHERS_2", "There are %d other unhandled requests."}, /* {ARGS: 1337} */
-    {"NH_REQUEST_FOOTER_1", "Everything you tell me until you are helped (or you leave %s) will be recorded. If you part %s, your request will be lost."}, /* {ARGS: "#test"} */
-    {"NH_REQUEST_FOOTER_2", "Everything you tell me until you are helped (or you leave %s or %s) will be recorded. If you part %s or %s, your request will be lost."}, /* {ARGS: "#test", "#test-support"} */
+    {"NH_REQUEST_FOOTER_1", "Everything you tell me until you are helped (or you leave %1$s) will be recorded. If you part %1$s, your request will be lost."}, /* {ARGS: "#test"} */
+    {"NH_REQUEST_FOOTER_2", "Everything you tell me until you are helped (or you leave %1$s or %2$s) will be recorded. If you part %1$s or %2$s, your request will be lost."}, /* {ARGS: "#test", "#test-support"} */
     {"NH_NEW_REQUEST", "New request #%d by %s: %s"}, /* {ARGS: 5, "pk910", "Help, I've fallen and I can't get up!"} */
     {"NH_NEXT_NONE", "No more requests."},
     {"NH_NEXT_NOT_FOUND", "No request found."},
@@ -267,9 +269,9 @@ static void neonhelp_event_privmsg_async(struct ClientSocket *client, struct Use
     }
 }
 
-static void destroy_support_request(struct ClientSocket *client, struct NeonHelpNode *helpnode, int reply) {
+static void destroy_support_request(struct ClientSocket *client, struct NeonHelpNode *helpnode, int do_reply) {
     printf_mysql_query("UPDATE `helpserv_requests` SET `status` = '2' WHERE `id` = %d", helpnode->suppid);
-    if(reply) {
+    if(do_reply) {
         reply(client, helpnode->user, "NH_DELETED", helpnode->suppid);
     }
     free(helpnode);
@@ -351,9 +353,6 @@ static void neonhelp_event_part(struct ChanUser *target, char *reason) {
 
 static void neonhelp_event_quit(struct UserNode *target, char *reason) {
     struct ClientSocket *client;
-    MYSQL_RES *res;
-    MYSQL_ROW row;
-    struct ChanNode *support, *public;
     int userHasRequest;
     for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
         if(client->botid == BOTID) {
index 5f6165754dddfe464bcf25d9785bf18b46a9380a..5993886e534e78ec1356ad0856358f0f6ba62acf 100644 (file)
 #define _cmd_neonhelp_h
 #include "main.h"
 #include "modcmd.h"
+#include "mysqlConn.h"
+#include "ClientSocket.h"
+#include "UserNode.h"
+#include "ChanNode.h"
+#include "ChanUser.h"
+#include "DBHelper.h"
+#include "IRCParser.h"
+#include "bot_NeonHelp.h"
+#include "lang.h"
 
+CMD_BIND(neonhelp_cmd_delete);
 CMD_BIND(neonhelp_cmd_next);
 
 #endif
\ No newline at end of file
index 3f589d57c2806399052527e9b443fe2f9622ad1e..43d5829bf8ce71f9b29a189033e6478c6c146bec 100644 (file)
@@ -61,7 +61,6 @@ CMD_BIND(neonhelp_cmd_delete) {
         return;
     }
     struct NeonHelpNode *helpnode, *next_helpnode = NULL, *prev_helpnode = NULL;
-    int lowest_id = -1;
     for(helpnode = client->botclass_helpnode; helpnode; helpnode = helpnode->next) {
         if(atoi(argv[0]) == helpnode->suppid) {
             next_helpnode = helpnode;
@@ -73,7 +72,6 @@ CMD_BIND(neonhelp_cmd_delete) {
         reply(getTextBot(), user, "NH_NEXT_NOT_FOUND");
         return;
     }
-    char sendbuf[MAXLEN];
     reply(client, next_helpnode->user, "NH_DELETED", next_helpnode->suppid);
     printf_mysql_query("UPDATE `helpserv_requests` SET `status` = '2' WHERE `id` = '%d'", next_helpnode->suppid);
     if(prev_helpnode)
index 666b1a57e5e25f869940b0cfcc75be6c694b3b1e..4cb7ee335ca40ca8cb78c5f5837a9b4d027b18f6 100644 (file)
@@ -87,7 +87,7 @@ CMD_BIND(neonhelp_cmd_next) {
     reply(getTextBot(), user, "NH_NEXT_HEADER", next_helpnode->suppid, next_helpnode->user->nick);
     char *a, *b = row2[0];
     do {
-        a = strstr("\n", b);
+        a = strstr(b, "\n");
         if(a) *a = '\0';
         reply(getTextBot(), user, "  %s", b);
         if(a) {
@@ -101,7 +101,7 @@ CMD_BIND(neonhelp_cmd_next) {
         putsock(client, "MODE %s +v %s", row[0], next_helpnode->user->nick);
     char sendbuf1[MAXLEN];
     char sendbuf2[MAXLEN];
-    char *join_now = (row[1] ? build_language_string(user, sendbuf2, "NH_NEXT_JOIN", row[1]) : "");
+    char *join_now = (row[1] ? build_language_string(user, sendbuf2, "NH_NEXT_JOIN", row[0]) : "");
     putsock(client, "PRIVMSG %s :%s %s", next_helpnode->user->nick, build_language_string(user, sendbuf1, "NH_NEXT_HELPER", next_helpnode->suppid, user->auth, user->nick), join_now);
     next_helpnode->status = 1;
     printf_mysql_query("UPDATE `helpserv_requests` SET `status` = '1' WHERE `id` = '%d'", next_helpnode->suppid);
index 5ea34ec75c53b8856cbf9d0510dd2998bd79a719..fcfe78b852d86826d5fcc505c1ddff71483e330c 100644 (file)
@@ -19,6 +19,7 @@
 #include "cmd_neonserv.h"
 #include "cmd_neonspam.h"
 #include "cmd_funcmds.h"
+#include "cmd_neonhelp.h"
 #include "modcmd.h"
 
 void register_commands() {
@@ -157,7 +158,7 @@ void register_commands() {
     //NeonHelp Commands
     register_command_alias(4, "NeonHelp");
     
-    #define USER_COMMAND(NAME,FUNCTION,PARAMCOUNT,PRIVS,FLAGS) register_command(2, NAME, FUNCTION, PARAMCOUNT, PRIVS, 0, FLAGS)
+    #define USER_COMMAND(NAME,FUNCTION,PARAMCOUNT,PRIVS,FLAGS) register_command(4, NAME, FUNCTION, PARAMCOUNT, PRIVS, 0, FLAGS)
     //               NAME              FUNCTION        PARAMS     PRIVS                FLAGS
     USER_COMMAND("next",         neonhelp_cmd_next,      0, NULL,                   CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH);
     USER_COMMAND("delete",       neonhelp_cmd_delete,    1, NULL,                   CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH);