summaryrefslogtreecommitdiff
path: root/src/map/irc-bot.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-08-05 15:32:35 +0200
committerHaru <haru@dotalux.com>2013-08-12 17:14:51 +0200
commitd20596083a12a8ab797614121be51d2a914abe58 (patch)
tree85381bfec7e42eda0af7219f0b6b041c107921d2 /src/map/irc-bot.c
parent3fb307be68de6026df138b2d48f2f6b94dbec64f (diff)
downloadhercules-d20596083a12a8ab797614121be51d2a914abe58.tar.gz
hercules-d20596083a12a8ab797614121be51d2a914abe58.tar.bz2
hercules-d20596083a12a8ab797614121be51d2a914abe58.tar.xz
hercules-d20596083a12a8ab797614121be51d2a914abe58.zip
Added support for target-less commands in the IRC bridge
Needed for future updates (such as receiving "QUIT" commands Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/irc-bot.c')
-rw-r--r--src/map/irc-bot.c13
1 files changed, 9 insertions, 4 deletions
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);