irctk

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

commit 4c1cc7456587b9601c66f84df5cf508fea81653d
parent 31ab1c32da4dbd9961baa7565dcb3cd5e8318e9b
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Fri,  7 Sep 2012 17:10:28 +0200

support for /me

Diffstat:
irctk.c | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/irctk.c b/irctk.c @@ -988,6 +988,28 @@ char* consume_word(char **from) return result; } +int do_me(irc_session_t *s, char *chan, char *password, char *line) { + /* TODO2 only join channels we haven't joined yet */ + if (args.join) + irc_cmd_join(s, chan, password); + if (args.own) { + if (args.event_to == COMMAND) + mprintf("[%s] <%s%s> /me %s", chan, + output_nick(args.nick), + args.with_host ? args.hostname : "", + line); + if (args.event_to == MESSAGE) + mprintf("[%s] <%s%s> * %s%s %s", chan, + output_nick(args.nick), + args.with_host ? args.hostname : "", + output_nick(args.nick), + args.with_host ? args.hostname : "", + line); + } + + return irc_cmd_me(s, chan, line); +} + int do_say(irc_session_t *s, char *chan, char *password, char *line) { /* TODO2 only join channels we haven't joined yet */ if (args.join) @@ -1093,6 +1115,9 @@ int do_cmd_msg(irc_session_t *s, char *chan, char* line) char *knick = consume_word(&arg); rsl = irc_cmd_kick(s, knick, chan, arg); free(knick); + } else if ((arg = MATCH_CMD0(line, "me"))) { + // just a way to escape messages starting by '/' + rsl = do_me(s, chan, password, arg + (*arg?1:0)); } else if ((arg = MATCH_CMD0(line, "say"))) { // just a way to escape messages starting by '/' rsl = do_say(s, chan, password, arg + (*arg?1:0));