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);
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);
//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);
}
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 {
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;