From d3329913e0bd65cab6d670facf373b6609ace662 Mon Sep 17 00:00:00 2001 From: Egor Date: Tue, 3 May 2022 23:10:33 +0300 Subject: [PATCH] try to fix JOIN on some clients --- irc.c | 8 ++++---- irc.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/irc.c b/irc.c index 896869e..e876e76 100644 --- a/irc.c +++ b/irc.c @@ -158,7 +158,7 @@ int processPacket(struct client_data *client) { return 0; if (!args[1]) { // TODO: +s - channel_sendtopic(client, chan); + channel_sendtopic(client, chan, 0); } else { // TODO: +t check, membership check free(chan->topic); @@ -479,7 +479,7 @@ void setNick(struct client_data *client, char* nickname) { return; } -void channel_sendtopic(struct client_data *client, struct channel *chan) +void channel_sendtopic(struct client_data *client, struct channel *chan, int joining) { if (chan->topic) { copy_strf(&databuf, ":%s 332 %s %s :%s\n", hostname, client->nick, chan->name, chan->topic); @@ -488,7 +488,7 @@ void channel_sendtopic(struct client_data *client, struct channel *chan) //copy_strf(&databuf, ":%s 333 %s %s %s %d\n", hostname, client->nick, chan->name, chan->topic_who, chan->topic_when); copy_strf(&databuf, ":%s 333 %s %s %s 0\n", hostname, client->nick, chan->name, chan->topic_who); send_log(client->FD, databuf.buf, databuf.len, 0); - } else { + } else if (!joining) { copy_strf(&databuf, ":%s 331 %s %s :No topic is set\n", hostname, client->nick, chan->name); send_log(client->FD, databuf.buf, databuf.len, 0); } @@ -541,7 +541,7 @@ void channel_join(struct client_data *client, const char *channel, const char *c send_log(cl->FD, databuf.buf, databuf.len, 0); } while(trie_findnext(&f) == 1); // send topic - channel_sendtopic(client, chan); + channel_sendtopic(client, chan, 1); // send names if (trie_findfirst(&f, &client_map) == 1) do { diff --git a/irc.h b/irc.h index 699ab10..a413f33 100644 --- a/irc.h +++ b/irc.h @@ -11,7 +11,7 @@ void sendMOTD(struct client_data *client); void setNick(struct client_data *client, char* nickname); struct client_data *findClient(const char *nickname); struct channel *findChannel(const char *channel); -void channel_sendtopic(struct client_data *client, struct channel *chan); +void channel_sendtopic(struct client_data *client, struct channel *chan, int joining); void channel_join(struct client_data *client, const char *channel, const char *chankey); void channel_part(struct client_data *client, struct channel *chan, const char *reason); extern struct dynarr databuf; -- 2.56.0