hirc

IRC client
Log | Files | Refs

commit 206c7815ad9c3f962af66367e2af4ea86308e3c7
parent 890223df6dda46ee8d18df74d79115efb81728d6
Author: hhvn <dev@hhvn.uk>
Date:   Sat, 13 Nov 2021 11:12:32 +0000

serv.c handle.c hirc.h: don't consider connected until finished registering

Diffstat:
Mhandle.c | 15+++++++++++++++
Mhirc.h | 2++
Mserv.c | 1-
3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/handle.c b/handle.c @@ -18,9 +18,11 @@ struct Handler handlers[] = { { "NICK", handle_NICK }, { "PRIVMSG", handle_PRIVMSG }, { "NOTICE", handle_PRIVMSG }, + { "001", handle_WELCOME }, { "005", handle_ISUPPORT }, { "353", handle_NAMREPLY }, { "366", NULL /* end of names */ }, + { "376", handle_ENDOFMOTD }, { "433", handle_NICKNAMEINUSE }, { NULL, NULL }, }; @@ -297,6 +299,19 @@ handle_NICK(char *msg, char **params, struct Server *server, time_t timestamp) { } void +handle_WELCOME(char *msg, char **params, struct Server *server, time_t timestamp) { + server->status = ConnStatus_connected; + hist_add(server->history, NULL, msg, params, Activity_status, timestamp, HIST_DFL); +} + +void +handle_ENDOFMOTD(char *msg, char **params, struct Server *server, time_t timestamp) { + /* If server doesn't support RPL_WELCOME, use RPL_ENDOFMOTD to set status */ + server->status = ConnStatus_connected; + hist_add(server->history, NULL, msg, params, Activity_status, timestamp, HIST_DFL); +} + +void handle_expect(char *cmd, char *about) { int i; diff --git a/hirc.h b/hirc.h @@ -90,8 +90,10 @@ void handle_JOIN(char *msg, char **params, struct Server *server, time_t timest void handle_PART(char *msg, char **params, struct Server *server, time_t timestamp); void handle_QUIT(char *msg, char **params, struct Server *server, time_t timestamp); void handle_PRIVMSG(char *msg, char **params, struct Server *server, time_t timestamp); +void handle_WELCOME(char *msg, char **params, struct Server *server, time_t timestamp); void handle_ISUPPORT(char *msg, char **params, struct Server *server, time_t timestamp); void handle_NAMREPLY(char *msg, char **params, struct Server *server, time_t timestamp); +void handle_ENDOFMOTD(char *msg, char **params, struct Server *server, time_t timestamp); void handle_NICKNAMEINUSE(char *msg, char **params, struct Server *server, time_t timestamp); void handle_NICK(char *msg, char **params, struct Server *server, time_t timestamp); diff --git a/serv.c b/serv.c @@ -215,7 +215,6 @@ serv_connect(struct Server *server) { } server->connectfail = 0; - server->status = ConnStatus_connected; server->rfd = server->wfd = fd; hist_format(server->history, Activity_status, HIST_SHOW|HIST_MAIN, "SELF_CONNECTED %s %s %s", server->name, server->host, server->port);