irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit ed21d0fee0294eeb386c030f7cd22b762791b1ad
parent 30cee322c1a4f18825a2ca3de3e0829a73a7b499
Author: Antoine Amarilli <ant.amarilli@free.fr>
Date:   Sat, 22 Jan 2011 14:49:08 +0100

correct bug in command handling

Diffstat:
irctk.c | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/irctk.c b/irctk.c @@ -373,24 +373,26 @@ int do_cmd_msg(irc_session_t *s, const char* chan, const char* line) /* TODO2 provide a means to escape '/' */ if (line[0] == '/' && args.command_to_event) { - if ( strstr (line[1], "nick ") == line[1] ) + if ( strstr (line + 1, "nick ") == line + 1 ) { rsl = irc_cmd_nick (s, line+6); - } else if (strstr (line[1], "part") == line[1]) { + } else if (strstr (line + 1, "part") == line + 1) { if (!line[5] || line[5] == '\n') { rsl = irc_cmd_part(s, chan); } else if (line[5] == ' ') { rsl = irc_cmd_part(s, line + 6); } - } else if (strstr (line[1], "join") == line[1]) { + } else if (strstr (line + 1, "join") == line + 1) { if (!line[5] || line[5] == '\n') { + debug("join %s", chan); rsl = irc_cmd_join(s, chan, NULL); } else if (line[5] == ' ') { + debug("join %s", line+6); rsl = irc_cmd_join(s, line + 6, NULL); } - } else if (strstr (line[1], "quit") == line[1]) { + } else if (strstr (line + 1, "quit") == line + 1) { /* TODO notify main thread that it is over */ if (!line[5] || line[5] == '\n') { @@ -837,7 +839,7 @@ int start () while ( (res = getline((char**) &line, (size_t*) &size, stdin)) != -1 ) { - debug("got %s, waiting", line); + debug("startloop : got %s, waiting", line); while (!args.ready) { waiting = 0; @@ -892,8 +894,12 @@ int start () if (args.show_prefix && args.default_destination == DEFAULT_LAST_OUT) fprintf(stderr, "[%s] ", args.last_chans_out); usleep(args.interval); + + debug("endloop"); } + debug("exiting"); + line = NULL; usleep(2*args.interval); irc_disconnect(s);