2 * IRC - Internet Relay Chat, ircd/m_svspart.c
3 * Written by Pierre Schweitzer.
13 #include "ircd_chattr.h"
14 #include "ircd_features.h"
15 #include "ircd_reply.h"
16 #include "ircd_string.h"
29 * SVSPART is forwarded to the server where the user is connected to.
30 * This allows to send SVSPARTs from all servers in the network but additionally causes
31 * some overhead. Though, SVSPART is not often called and this overhead can be ignored.
33 /* ms_svspart - server message handler
35 * parv[0] = sender prefix
36 * parv[1] = numeric of client
37 * parv[2] = channel, NO CHANLIST!
38 * parv[3] = comment (optional)
40 signed int ms_svspart(struct Client* cptr, struct Client* sptr, signed int parc, char* parv[]) {
42 struct Channel *chptr;
44 struct Membership *member;
45 unsigned int flags = 0;
49 return protocol_violation(cptr, "Too few arguments for SVSPART");
52 /* Ignore if the user has already quitted. */
53 if(!(acptr = findNUser(parv[1]))) {
57 /* Check channelname. */
58 if(!IsChannelName(parv[2]) || !strIsIrcCh(parv[2])) {
63 chptr = get_channel(acptr, parv[2], CGT_NO_CREATE);
65 /* Ensure the user is in channel */
66 if (!(member = find_member_link(chptr, acptr))) return 0;
68 /* Forward the message to the server where the user is connected to. */
69 if(!MyConnect(acptr)) {
71 sendcmdto_one(sptr, CMD_SVSPART, acptr, "%s %s :%s", parv[1], chptr->chname, parv[3]);
73 sendcmdto_one(sptr, CMD_SVSPART, acptr, "%s %s", parv[1], chptr->chname);
77 /* Check if we can put part message */
78 use_comment = (parc > 3 && !EmptyString(parv[3]) &&
79 member_can_send_to_channel(member, 0));
81 /* Use join buf to make him leave - use comment if provided */
82 joinbuf_init(&part, acptr, acptr, JOINBUF_TYPE_PART,
83 use_comment ? parv[3] : 0, 0);
85 if (!member_can_send_to_channel(member, 0))
88 if (IsDelayedJoin(member))
89 flags |= CHFL_DELAYED;
91 /* Make the user leave */
92 joinbuf_join(&part, chptr, flags);