--- a/src/irc_log.c Thu Mar 12 18:11:44 2009 +0200
+++ b/src/irc_log.c Thu Mar 12 18:35:05 2009 +0200
@@ -14,19 +14,18 @@
} _ctx;
-static void on_PRIVMSG (const struct irc_line *line, void *arg)
+static void on_chan_msg (struct irc_chan *chan, const char *prefix, const char *message, void *arg)
{
struct irc_log_ctx *ctx = arg;
(void) ctx;
// log it! :P
- log_debug("%s: %s: %s", line->prefix, line->args[0], line->args[1]);
+ log_debug("%s: %s: %s", prefix, irc_chan_name(chan), message);
}
-static struct irc_cmd_handler _cmd_handlers[] = {
- { "PRIVMSG", &on_PRIVMSG },
- { NULL, NULL }
+static struct irc_chan_callbacks _chan_callbacks = {
+ .on_msg = on_chan_msg,
};
err_t irc_log_init (struct event_base *ev_base, const struct irc_log_info *info)
@@ -46,12 +45,16 @@
log_info("log channel: %s", irc_chan_name(info->channel));
}
- // register for events
- // XXX: need irc_chan API for this
- if ((err = irc_conn_add_cmd_handlers(info->channel->net->conn, _cmd_handlers, ctx)))
- return err;
+ // add channel callbacks
+ if ((err = irc_chan_add_callbacks(info->channel, &_chan_callbacks, ctx)))
+ goto error;
// ok
return SUCCESS;
+
+error:
+ // XXX: cleanup
+
+ return err;
}