mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
irc: Expose more IRC functionality
Now exposing the connection event and raw incoming commands.
This commit is contained in:
parent
356bb73fe9
commit
c97c47da47
2 changed files with 14 additions and 4 deletions
10
irc.c
10
irc.c
|
@ -3,6 +3,8 @@
|
|||
#include "daemon/log.h"
|
||||
|
||||
void (*irc_privmsg_cb)(struct ircstate *, const struct privmsg *) = NULL;
|
||||
void (*irc_command_cb)(struct ircstate *, const struct irccommand *) = NULL;
|
||||
void (*irc_connect_cb)(struct ircstate *) = NULL;
|
||||
void (*irc_disconnect_cb)(struct ircstate *) = NULL;
|
||||
|
||||
static struct io_plan *irc_connected(struct io_conn *conn, struct lightningd_state *dstate, struct ircstate *state);
|
||||
|
@ -94,6 +96,10 @@ static void handle_irc_command(struct ircstate *state, const char *line)
|
|||
pm->msg = tal_strjoin(m, splits + 2, " ", STR_NO_TRAIL);
|
||||
irc_privmsg_cb(state, pm);
|
||||
}
|
||||
|
||||
if (irc_command_cb != NULL)
|
||||
irc_command_cb(state, m);
|
||||
|
||||
tal_free(m);
|
||||
}
|
||||
|
||||
|
@ -168,7 +174,9 @@ static struct io_plan *irc_connected(struct io_conn *conn, struct lightningd_sta
|
|||
state->connected = true;
|
||||
irc_send(state, "USER", "%s 0 * :A lightning node", state->nick);
|
||||
irc_send(state, "NICK", "%s", state->nick);
|
||||
irc_send(state, "JOIN", "#lightning-nodes");
|
||||
|
||||
if (irc_connect_cb != NULL)
|
||||
irc_connect_cb(state);
|
||||
|
||||
return io_duplex(conn,
|
||||
io_read_partial(conn,
|
||||
|
|
4
irc.h
4
irc.h
|
@ -53,8 +53,10 @@ struct ircstate {
|
|||
struct timerel reconnect_timeout;
|
||||
};
|
||||
|
||||
/* Callback to register for incoming messages */
|
||||
/* Callbacks to register for incoming messages, events and raw commands */
|
||||
extern void (*irc_privmsg_cb)(struct ircstate *, const struct privmsg *);
|
||||
extern void (*irc_command_cb)(struct ircstate *, const struct irccommand *);
|
||||
extern void (*irc_connect_cb)(struct ircstate *);
|
||||
extern void (*irc_disconnect_cb)(struct ircstate *);
|
||||
|
||||
/* Send messages to IRC */
|
||||
|
|
Loading…
Add table
Reference in a new issue