From d20596083a12a8ab797614121be51d2a914abe58 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 5 Aug 2013 15:32:35 +0200 Subject: Added support for target-less commands in the IRC bridge Needed for future updates (such as receiving "QUIT" commands Signed-off-by: Haru --- src/map/irc-bot.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/map/irc-bot.c') diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index d3782bd9b..d8aa59440 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -131,15 +131,20 @@ void irc_parse_source(char *source, char *nick, char *ident, char *host) { } } void irc_parse_sub(int fd, char *str) { - char source[180], command[60], target[60], message[200]; + char source[180], command[60], buf1[500], buf2[500]; + char *target = buf1, *message = buf2; struct irc_func *func; - source[0] = command[0] = target[0] = message[0] = '\0'; + source[0] = command[0] = buf1[0] = buf2[0] = '\0'; if( str[0] == ':' ) str++; - sscanf(str, "%179s %59s %59s :%199[^\r\n]", source, command, target, message); + if (sscanf(str, "%179s %59s %499s :%499[^\r\n]", source, command, buf1, buf2) == 3 && buf1[0] == ':') { + // source command :message (i.e. QUIT) + message = buf1+1; + target = buf2; + } if( command[0] == '\0' ) return; @@ -202,7 +207,7 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) { } } -void irc_relay (char *name, char *msg) { +void irc_relay (char *name, const char *msg) { if( !ircbot->isIn ) return; sprintf(send_string,"PRIVMSG %s :[ %s ] : %s",hChSys.irc_channel,name,msg); -- cgit v1.2.3-70-g09d2