void DelChannelUser(struct userNode* user, struct chanNode* channel, const char *reason, int deleting) { struct modeNode* mNode; unsigned int n; if (IsLocal(user) && reason) irc_part(user, channel, reason); mNode = GetUserMode(channel, user); /* Sometimes we get a PART when the user has been KICKed. * In this case, we get no usermode, and should not try to free it. */ if (!mNode) return; /* remove modeNode from channel and user */ modeList_remove(&channel->members, mNode); modeList_remove(&user->channels, mNode); /* make callbacks */ for (n=0; n<pf_used; n++) pf_list[n](mNode, reason, pf_list_extra[n]); /* free memory */ free(mNode); /* A single check for APASS only should be enough here */ if (!deleting && !channel->members.used && !channel->locks && !(channel->modes & MODE_REGISTERED) && !(channel->modes & MODE_APASS)) DelChannel(channel); }
void test_irc_part() { char msg[READ_BUF]; irc_part("#circus"); read_mock(msg); mu_assert(s_eq(msg, "PART #circus\r\n"), "test_irc_part: msg should be 'PART #circus\\r\\n'"); }
void ChannelUserKicked(struct userNode* kicker, struct userNode* victim, struct chanNode* channel) { unsigned int n; struct modeNode *mn; if (!victim || !channel || !GetUserMode(channel, victim)) return; /* Update the kicker's idle time (kicker may be null if it was a server) */ if (kicker && (mn = GetUserMode(channel, kicker))) mn->idle_since = now; for (n=0; n<kf_used; n++) kf_list[n](kicker, victim, channel, kf_list_extra[n]); DelChannelUser(victim, channel, 0, 0); if (IsLocal(victim)) irc_part(victim, channel, NULL); }
int irc_leave_channel(irc_t *irc) { return irc_part(irc->s, irc->channel); }
static int irc_leave_channel(irc_t *irc, const char* channel) { return irc_part(irc->s, channel); }