diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/botserv.c | 17 | ||||
-rw-r--r-- | src/messages.c | 9 |
2 files changed, 9 insertions, 17 deletions
diff --git a/src/botserv.c b/src/botserv.c index 6f1ff2289..b8710672b 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -185,17 +185,15 @@ void botmsgs(User * u, BotInfo * bi, char *buf) * */ -void botchanmsgs(User * u, ChannelInfo * ci, char *buff) +void botchanmsgs(User * u, ChannelInfo * ci, char *buf) { int c; int16 cstatus = 0; - char *cmd, *buf; + char *cmd; UserData *ud; - buf = sstrdup(buff); if (!u) { - free(buf); return; } @@ -243,7 +241,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) if ((ci->botflags & BS_KICK_BOLDS) && strchr(buf, 2)) { check_ban(ci, u, TTB_BOLDS); bot_kick(ci, u, BOT_REASON_BOLD); - free(buf); return; } @@ -251,7 +248,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) if ((ci->botflags & BS_KICK_COLORS) && strchr(buf, 3)) { check_ban(ci, u, TTB_COLORS); bot_kick(ci, u, BOT_REASON_COLOR); - free(buf); return; } @@ -259,7 +255,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) if ((ci->botflags & BS_KICK_REVERSES) && strchr(buf, 22)) { check_ban(ci, u, TTB_REVERSES); bot_kick(ci, u, BOT_REASON_REVERSE); - free(buf); return; } @@ -267,7 +262,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) if ((ci->botflags & BS_KICK_UNDERLINES) && strchr(buf, 31)) { check_ban(ci, u, TTB_UNDERLINES); bot_kick(ci, u, BOT_REASON_UNDERLINE); - free(buf); return; } @@ -285,7 +279,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) if (i >= ci->capsmin && i * 100 / c >= ci->capspercent) { check_ban(ci, u, TTB_CAPS); bot_kick(ci, u, BOT_REASON_CAPS); - free(buf); return; } } @@ -405,7 +398,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) bot_kick(ci, u, BOT_REASON_BADWORD_GENTLE); else bot_kick(ci, u, BOT_REASON_BADWORD, bw->word); - free(buf); return; } } @@ -421,7 +413,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) ud = get_user_data(ci->c, u); if (!ud) { - free(buf); return; } @@ -434,7 +425,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) if (ud->lines >= ci->floodlines) { check_ban(ci, u, TTB_FLOOD); bot_kick(ci, u, BOT_REASON_FLOOD); - free(buf); return; } } @@ -443,7 +433,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) if (ci->botflags & BS_KICK_REPEAT) { ud = get_user_data(ci->c, u); if (!ud) { - free(buf); return; } if (ud->lastline && stricmp(ud->lastline, buf)) { @@ -459,7 +448,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) if (ud->times >= ci->repeattimes) { check_ban(ci, u, TTB_REPEAT); bot_kick(ci, u, BOT_REASON_REPEAT); - free(buf); return; } } @@ -468,7 +456,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buff) /* return if the user is on the ignore list */ if (get_ignore(u->nick) != NULL) { - free(buf); return; } diff --git a/src/messages.c b/src/messages.c index 9e5d4466b..eb83909b2 100644 --- a/src/messages.c +++ b/src/messages.c @@ -577,6 +577,7 @@ static int m_part(char *source, int ac, char **av) static int m_privmsg(char *source, int ac, char **av) { char *s; + char *buf; time_t starttime, stoptime; /* When processing started and finished */ BotInfo *bi; @@ -596,8 +597,12 @@ static int m_privmsg(char *source, int ac, char **av) if (*av[0] == '#') { if (s_BotServ && (ci = cs_findchan(av[0]))) - if (!(ci->flags & CI_VERBOTEN) && ci->c && ci->bi) /* Some paranoia checks */ - botchanmsgs(u, ci, av[1]); + if (!(ci->flags & CI_VERBOTEN) && ci->c && ci->bi) + /* Some paranoia checks */ + /* Copy the message to a temp. variable, otherwise botchanmsgs would break the buffer for modules -Keeper */ + buf = sstrdup(av[1]); + botchanmsgs(u, ci, buf); + free(buf); } else { /* Check if we should ignore. Operators always get through. */ |