irctk

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

commit c1c5cdbbd03b91499796cae8a9a345e780daf8f5
parent 42fd8efc8044f335790df49f5ef3aeea5aecffb7
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Thu, 14 Feb 2013 21:57:04 +0100

Fix broken /me messages

Diffstat:
irctk.c | 16+++++++++++++++-
test/1events.sh | 2++
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/irctk.c b/irctk.c @@ -988,6 +988,9 @@ char* consume_word(char **from) int do_me(irc_session_t *s, char *chan, char *password, char *line) { /* TODO2 only join channels we haven't joined yet */ + int ret; + int oldend; + char oldchar; if (args.join && chan[0] == '#') irc_cmd_join(s, chan, password); if (args.own) { @@ -1005,7 +1008,18 @@ int do_me(irc_session_t *s, char *chan, char *password, char *line) { line); } - return irc_cmd_me(s, chan, line); + /* kludge: replace trailing '\n's by '\0's temporarily to avoid problem with + * the '\01' of ACTION falling on a different line */ + oldend = strlen(line); + while (oldend >= 0 && (line[oldend] == '\n' || line[oldend] == 0)) + oldend--; + oldend++; + // oldend is now the last index that is >= 0 and line[oldend] is '\0' or '\n' + oldchar = line[oldend]; + line[oldend] = 0; + ret = irc_cmd_me(s, chan, line); + line[oldend] = oldchar; + return ret; } int do_say(irc_session_t *s, char *chan, char *password, char *line) { diff --git a/test/1events.sh b/test/1events.sh @@ -15,6 +15,7 @@ cat >tosay <<EOF [#events_test2] /invite eventsc [#events_test2] /kick eventsc kickarg /say hello +/me blah / /hello2 /quit quitarg EOF @@ -35,6 +36,7 @@ cat > ref_message <<EOF [#events_test2] -!- eventsop2 changed the topic of #events_test2 to mytopic [#events_test2] -!- eventsc was kicked from #events_test2 by eventsop2 (kickarg) [#events_test2] <eventsop2> hello +[#events_test2] *** eventsop2 blah [#events_test2] <eventsop2> /hello2 [] -!- eventsop2 has quit ("quitarg") EOF