From: pk910 Date: Tue, 1 Nov 2011 15:12:56 +0000 (+0100) Subject: fork extscripts to increase performance & ignore messages coming from bots (NeonSpam) X-Git-Tag: v5.3~225 X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=commitdiff_plain;h=c73dc6f2c494e7f6f8e71c03a008923ec76a9758 fork extscripts to increase performance & ignore messages coming from bots (NeonSpam) --- diff --git a/src/cmd_neonserv_extscript.c b/src/cmd_neonserv_extscript.c index a2202f5..2d7e0bd 100644 --- a/src/cmd_neonserv_extscript.c +++ b/src/cmd_neonserv_extscript.c @@ -114,16 +114,26 @@ CMD_BIND(neonserv_cmd_extscript) { FILE *fp; fp = popen(command, "r"); if (fp) { - char *a; - while (fgets(command, 1024, fp) != NULL) { - if((a = strchr(command, '\n'))) - *a = '\0'; - if(answere_channel) { - putsock(client, "PRIVMSG %s :%s", chan->name, command); - } else - reply(getTextBot(), user, "%s", command); + struct ClientSocket *textbot = getTextBot(); + pid_t pID = fork(); + if (pID == 0) { //We're the child process :D + char *a; + while (fgets(command, 1024, fp) != NULL) { + if((a = strchr(command, '\n'))) + *a = '\0'; + if(answere_channel) + putsock(client, "PRIVMSG %s :%s", chan->name, command); + else + reply(textbot, user, "%s", command); + } + pclose(fp); + exit(0); + } else if (pID < 0) { + reply(getTextBot(), user, "internal bot error - please contact an administrator!"); + pclose(fp); + } else { + //parent bot - continue program } - pclose(fp); } else { //error reply(getTextBot(), user, "internal bot error - please contact an administrator!"); diff --git a/src/event_neonspam_chanmsg.c b/src/event_neonspam_chanmsg.c index f503596..c20065f 100644 --- a/src/event_neonspam_chanmsg.c +++ b/src/event_neonspam_chanmsg.c @@ -36,7 +36,7 @@ struct neonspam_event_chanmsg_cache { static void neonspam_event_chanmsg(struct UserNode *user, struct ChanNode *chan, char *message) { struct ClientSocket *client = getChannelBot(chan, BOTID); - if(!client) return; //we can't "see" this event + if(!client || (user->flags & USERFLAG_ISBOT)) return; //we can't "see" this event loadNeonSpamSettings(chan); struct NeonSpamSettings *settings = chan->spam_settings; struct ChanUser *chanuser = getChanUser(user, chan);