2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* m_okick.c: Kicks a user from a channel with much prejudice.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by the past and present ircd coders, and others.
|
|
|
|
* Copyright (C) 2004 ircd-ratbox Development Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
static const char okick_desc[] = "Allow admins to forcibly kick users from channels with the OKICK command";
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void mo_okick(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[]);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
struct Message okick_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"OKICK", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_okick, 4}}
|
|
|
|
};
|
|
|
|
|
|
|
|
mapi_clist_av1 okick_clist[] = { &okick_msgtab, NULL };
|
|
|
|
|
2016-03-07 10:40:51 +01:00
|
|
|
DECLARE_MODULE_AV2(okick, NULL, NULL, okick_clist, NULL, NULL, NULL, NULL, okick_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
** m_okick
|
|
|
|
** parv[1] = channel
|
|
|
|
** parv[2] = client to kick
|
|
|
|
** parv[3] = kick comment
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mo_okick(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
client::client *who;
|
|
|
|
client::client *target_p;
|
2016-08-18 07:33:38 +02:00
|
|
|
chan::chan *chptr;
|
|
|
|
chan::membership *msptr;
|
2007-01-25 07:40:21 +01:00
|
|
|
int chasing = 0;
|
|
|
|
char *comment;
|
|
|
|
char *name;
|
|
|
|
char *p = NULL;
|
|
|
|
char *user;
|
|
|
|
static char buf[BUFSIZE];
|
|
|
|
|
|
|
|
if(*parv[2] == '\0')
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NEEDMOREPARAMS), me.name, source.name, "KICK");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(my(source) && !is_flood_done(source))
|
2016-08-23 02:37:07 +02:00
|
|
|
flood_endgrace(&source);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
comment = (EmptyString(LOCAL_COPY(parv[3]))) ? LOCAL_COPY(parv[2]) : LOCAL_COPY(parv[3]);
|
|
|
|
if(strlen(comment) > (size_t) TOPICLEN)
|
|
|
|
comment[TOPICLEN] = '\0';
|
|
|
|
|
|
|
|
*buf = '\0';
|
2016-07-13 07:17:21 +02:00
|
|
|
if((p = (char *)strchr(parv[1], ',')))
|
2007-01-25 07:40:21 +01:00
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
name = LOCAL_COPY(parv[1]);
|
|
|
|
|
2016-08-20 04:51:37 +02:00
|
|
|
chptr = chan::get(name, std::nothrow);
|
2007-01-25 07:40:21 +01:00
|
|
|
if(!chptr)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-13 07:17:21 +02:00
|
|
|
if((p = (char *)strchr(parv[2], ',')))
|
2007-01-25 07:40:21 +01:00
|
|
|
*p = '\0';
|
2014-03-03 05:25:47 +01:00
|
|
|
user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ",");
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!(who = find_chasing(&source, user, &chasing)))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if((target_p = find_client(user)) == NULL)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NOSUCHNICK), user);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-20 02:32:26 +02:00
|
|
|
if((msptr = get(chptr->members, *target_p, std::nothrow)) == NULL)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_USERNOTINCHANNEL), parv[1], parv[2]);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-24 00:25:09 +02:00
|
|
|
sendto_wallops_flags(umode::WALLOP, &me,
|
2007-01-25 07:40:21 +01:00
|
|
|
"OKICK called for %s %s by %s!%s@%s",
|
2016-08-18 07:33:38 +02:00
|
|
|
chptr->name.c_str(), target_p->name,
|
2016-08-23 02:37:07 +02:00
|
|
|
source.name, source.username, source.host);
|
2007-01-25 07:40:21 +01:00
|
|
|
ilog(L_MAIN, "OKICK called for %s %s by %s",
|
2016-08-18 07:33:38 +02:00
|
|
|
chptr->name.c_str(), target_p->name,
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source));
|
2007-01-25 07:40:21 +01:00
|
|
|
/* only sends stuff for #channels remotely */
|
|
|
|
sendto_server(NULL, chptr, NOCAPS, NOCAPS,
|
|
|
|
":%s WALLOPS :OKICK called for %s %s by %s!%s@%s",
|
2016-08-18 07:33:38 +02:00
|
|
|
me.name, chptr->name.c_str(), target_p->name,
|
2016-08-23 02:37:07 +02:00
|
|
|
source.name, source.username, source.host);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
sendto_channel_local(chan::ALL_MEMBERS, chptr, ":%s KICK %s %s :%s",
|
|
|
|
me.name, chptr->name.c_str(), who->name, comment);
|
2007-08-11 00:31:14 +02:00
|
|
|
sendto_server(&me, chptr, CAP_TS6, NOCAPS,
|
2016-08-18 07:33:38 +02:00
|
|
|
":%s KICK %s %s :%s", me.id, chptr->name.c_str(), who->id, comment);
|
2016-08-20 02:32:26 +02:00
|
|
|
|
|
|
|
del(*chptr, *target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|