search another bot if unable to send funcmd replies over textbot
authorpk910 <philipp@zoelle1.de>
Sat, 10 Nov 2012 17:12:01 +0000 (18:12 +0100)
committerpk910 <philipp@zoelle1.de>
Sat, 10 Nov 2012 17:12:01 +0000 (18:12 +0100)
src/modules/funcmd.mod/cmd_funcmds.c

index 46a068e313e28c7cdd2819ac410c8de081b9a6f0..eda55cca075e18fcaa8fd2d369301abbb7078382 100644 (file)
@@ -127,6 +127,7 @@ free(header);
 #define REPLYTYPE_NOTICE 0x04
 static void funcmd_reply(struct funcmd_header_info *header, const char *text, int type, ...) {
     if (!(header->client->flags & SOCKET_FLAG_CONNECTED)) return;
+    struct ClientSocket *client = header->client;
     const char *reply_format = get_language_string((header->null_language ? NULL : header->user), text);
     if(reply_format)
         text = reply_format;
@@ -141,6 +142,8 @@ static void funcmd_reply(struct funcmd_header_info *header, const char *text, in
             sprintf(formatBuf, "PRIVMSG %s :\001ACTION %s\001", header->chan->name, text);
         else
             sprintf(formatBuf, "PRIVMSG %s :%s", header->chan->name, text);
+        if(!isUserOnChan(client->user, header->chan) && isModeSet(header->chan->modes, 'n'))
+            client = getChannelBot(header->chan, 0);
     }
     va_list arg_list;
     char sendBuf[MAXLEN];
@@ -152,7 +155,7 @@ static void funcmd_reply(struct funcmd_header_info *header, const char *text, in
     if (pos < 0 || pos > (MAXLEN - 2)) pos = MAXLEN - 2;
     sendBuf[pos] = '\n';
     sendBuf[pos+1] = '\0';
-    write_socket(header->client, sendBuf, pos+1);
+    write_socket(client, sendBuf, pos+1);
 }
 
 static char* getSetting(struct UserNode *user, struct ChanNode *chan, const char *setting) {