2 * ircd-ratbox: A slightly useful ircd.
3 * m_okick.c: Kicks a user from a channel with much prejudice.
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 * Copyright (C) 2004 ircd-ratbox Development Team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
41 static int mo_okick(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[]);
44 struct Message okick_msgtab
= {
46 {mg_unreg
, mg_not_oper
, mg_ignore
, mg_ignore
, mg_ignore
, {mo_okick
, 4}}
49 mapi_clist_av1 okick_clist
[] = { &okick_msgtab
, NULL
};
51 static const char okick_desc
[] = "Allow admins to forcibly kick users from channels with the OKICK command";
53 DECLARE_MODULE_AV2(okick
, NULL
, NULL
, okick_clist
, NULL
, NULL
, NULL
, NULL
, okick_desc
);
58 ** parv[2] = client to kick
59 ** parv[3] = kick comment
62 mo_okick(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
65 struct Client
*target_p
;
66 struct Channel
*chptr
;
67 struct membership
*msptr
;
73 static char buf
[BUFSIZE
];
77 sendto_one(source_p
, form_str(ERR_NEEDMOREPARAMS
), me
.name
, source_p
->name
, "KICK");
81 if(MyClient(source_p
) && !IsFloodDone(source_p
))
82 flood_endgrace(source_p
);
84 comment
= (EmptyString(LOCAL_COPY(parv
[3]))) ? LOCAL_COPY(parv
[2]) : LOCAL_COPY(parv
[3]);
85 if(strlen(comment
) > (size_t) TOPICLEN
)
86 comment
[TOPICLEN
] = '\0';
89 if((p
= strchr(parv
[1], ',')))
92 name
= LOCAL_COPY(parv
[1]);
94 chptr
= find_channel(name
);
97 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
, form_str(ERR_NOSUCHCHANNEL
), name
);
102 if((p
= strchr(parv
[2], ',')))
104 user
= LOCAL_COPY(parv
[2]); // strtoken(&p2, parv[2], ",");
105 if(!(who
= find_chasing(source_p
, user
, &chasing
)))
110 if((target_p
= find_client(user
)) == NULL
)
112 sendto_one(source_p
, form_str(ERR_NOSUCHNICK
), user
);
116 if((msptr
= find_channel_membership(chptr
, target_p
)) == NULL
)
118 sendto_one(source_p
, form_str(ERR_USERNOTINCHANNEL
), parv
[1], parv
[2]);
122 sendto_wallops_flags(UMODE_WALLOP
, &me
,
123 "OKICK called for %s %s by %s!%s@%s",
124 chptr
->chname
, target_p
->name
,
125 source_p
->name
, source_p
->username
, source_p
->host
);
126 ilog(L_MAIN
, "OKICK called for %s %s by %s",
127 chptr
->chname
, target_p
->name
,
128 get_oper_name(source_p
));
129 /* only sends stuff for #channels remotely */
130 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
131 ":%s WALLOPS :OKICK called for %s %s by %s!%s@%s",
132 me
.name
, chptr
->chname
, target_p
->name
,
133 source_p
->name
, source_p
->username
, source_p
->host
);
135 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s KICK %s %s :%s",
136 me
.name
, chptr
->chname
, who
->name
, comment
);
137 sendto_server(&me
, chptr
, CAP_TS6
, NOCAPS
,
138 ":%s KICK %s %s :%s", me
.id
, chptr
->chname
, who
->id
, comment
);
139 remove_user_from_channel(msptr
);