12 #define mg_remove {m_remove, 0}
14 static int m_remove (struct Client
*client_p
, struct Client
*source_p
, int parc
, const char **parv
);
16 /* {{{ struct Message remove_msgtab = { ... } */
17 struct Message remove_msgtab
=
19 "REMOVE", 0, 0, 0, MFLG_SLOW
,
31 /* {{{ mapi_clist_av1 remove_clist[] = { ... } */
32 mapi_clist_av1 remove_clist
[] =
39 /* {{{ DECLARE_MODULE_AV1(...) */
52 /* {{{ static int m_remove()
54 * REMOVE <channel> <nick> [<reason>]
63 m_remove (struct Client
*client_p
, struct Client
*source_p
, int parc
, const char **parv
)
65 uint8_t have_reason
= 0;
66 char reason_buf
[REASONLEN
+ 1];
68 struct Channel
*chptr
= NULL
;
69 struct membership
*msptr
= NULL
;
70 struct Client
*target_p
= NULL
;
73 if (MyClient(source_p
) && !IsFloodDone(source_p
))
74 flood_endgrace(source_p
);
78 sendto_one(source_p
, form_str(ERR_NEEDMOREPARAMS
), me
.name
, source_p
->name
, "REMOVE");
82 if (parc
> 3 && *parv
[3])
85 ircsnprintf(reason_buf
, sizeof(reason_buf
), "requested by %s%s%s%s",
87 !have_reason
? "" : ": \"",
88 !have_reason
? "" : parv
[3],
89 !have_reason
? "" : "\"");
90 reason_buf
[REASONLEN
] = '\0';
92 p
= strchr(parv
[1], ',');
96 chptr
= find_channel(p
);
99 sendto_one(source_p
, form_str(ERR_NOSUCHCHANNEL
), me
.name
, source_p
->name
, p
);
103 if (!IsServer(source_p
) && !IsOverride(source_p
))
105 msptr
= find_channel_membership(chptr
, source_p
);
106 if (!msptr
&& MyConnect(source_p
))
108 sendto_one(source_p
, form_str(ERR_NOTONCHANNEL
), me
.name
, source_p
->name
, p
);
113 * Nicked from m_kick.c; see that file for reasoning behind the
117 if(!is_chanop(msptr
))
119 if(MyConnect(source_p
))
121 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
122 me
.name
, source_p
->name
, p
);
126 /* If its a TS 0 channel, do it the old way */
127 if(chptr
->channelts
== 0)
129 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
130 get_id(&me
, source_p
), get_id(source_p
, source_p
), p
);
136 p
= strchr(parv
[2], ',');
140 target_p
= find_chasing(source_p
, p
, &chasing
);
144 msptr
= find_channel_membership(chptr
, target_p
);
147 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
, form_str(ERR_USERNOTINCHANNEL
),
152 if (MyClient(source_p
))
154 if (IsService(target_p
))
156 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
), me
.name
, source_p
->name
,
160 else if (IsOverride(target_p
))
162 sendto_one_numeric(source_p
, ERR_ISCHANSERVICE
,
163 "%s %s User is immune from kick", target_p
->name
, chptr
->chname
);
168 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s PART %s :%s",
169 target_p
->name
, target_p
->username
, target_p
->host
,
170 chptr
->chname
, reason_buf
);
172 /* propagate to TS6 servers that support REMOVE. */
173 sendto_server(client_p
, chptr
, CAP_TS6
| CAP_REMOVE
, NOCAPS
,
174 ":%s REMOVE %s %s %s%s", use_id(source_p
), chptr
->chname
, use_id(target_p
),
175 !have_reason
? "" : ":",
176 !have_reason
? "" : parv
[3]);
178 /* ...and to those that do not, translating to KICK. */
179 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
180 ":%s KICK %s %s %s%s",
181 use_id(source_p
), chptr
->chname
, use_id(target_p
),
182 !have_reason
? "" : ":",
183 !have_reason
? "" : parv
[3]);
184 sendto_server(client_p
, chptr
, NOCAPS
, CAP_TS6
,
185 ":%s KICK %s %s %s%s",
186 source_p
->name
, chptr
->chname
, target_p
->name
,
187 !have_reason
? "" : ":",
188 !have_reason
? "" : parv
[3]);
190 remove_user_from_channel(msptr
);
197 * vim: ts=8 sw=8 noet fdm=marker tw=80