]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * m_okick.c: Kicks a user from a channel with much prejudice. | |
4 | * | |
5 | * Copyright (C) 2002 by the past and present ircd coders, and others. | |
6 | * Copyright (C) 2004 ircd-ratbox Development Team | |
7 | * | |
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. | |
12 | * | |
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. | |
17 | * | |
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 | |
21 | * USA | |
212380e3 AC |
22 | */ |
23 | ||
24 | #include "stdinc.h" | |
212380e3 AC |
25 | #include "channel.h" |
26 | #include "client.h" | |
4562c604 | 27 | #include "match.h" |
212380e3 AC |
28 | #include "ircd.h" |
29 | #include "numeric.h" | |
30 | #include "send.h" | |
31 | #include "msg.h" | |
32 | #include "modules.h" | |
33 | #include "parse.h" | |
34 | #include "hash.h" | |
35 | #include "packet.h" | |
36 | #include "s_conf.h" | |
37 | #include "s_serv.h" | |
a6adeaad | 38 | #include "messages.h" |
77d3d2db | 39 | #include "logger.h" |
212380e3 | 40 | |
760bafda | 41 | static int mo_okick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); |
212380e3 AC |
42 | |
43 | ||
44 | struct Message okick_msgtab = { | |
7baa37a9 | 45 | "OKICK", 0, 0, 0, 0, |
212380e3 AC |
46 | {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_okick, 4}} |
47 | }; | |
48 | ||
49 | mapi_clist_av1 okick_clist[] = { &okick_msgtab, NULL }; | |
50 | ||
04f832b7 | 51 | DECLARE_MODULE_AV2(okick, NULL, NULL, okick_clist, NULL, NULL, NULL, NULL, NULL); |
212380e3 AC |
52 | |
53 | /* | |
54 | ** m_okick | |
212380e3 AC |
55 | ** parv[1] = channel |
56 | ** parv[2] = client to kick | |
57 | ** parv[3] = kick comment | |
58 | */ | |
59 | static int | |
760bafda | 60 | mo_okick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
61 | { |
62 | struct Client *who; | |
63 | struct Client *target_p; | |
64 | struct Channel *chptr; | |
65 | struct membership *msptr; | |
66 | int chasing = 0; | |
67 | char *comment; | |
68 | char *name; | |
69 | char *p = NULL; | |
70 | char *user; | |
71 | static char buf[BUFSIZE]; | |
72 | ||
73 | if(*parv[2] == '\0') | |
74 | { | |
3dfaa671 | 75 | sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "KICK"); |
212380e3 AC |
76 | return 0; |
77 | } | |
78 | ||
79 | if(MyClient(source_p) && !IsFloodDone(source_p)) | |
80 | flood_endgrace(source_p); | |
81 | ||
82 | comment = (EmptyString(LOCAL_COPY(parv[3]))) ? LOCAL_COPY(parv[2]) : LOCAL_COPY(parv[3]); | |
83 | if(strlen(comment) > (size_t) TOPICLEN) | |
84 | comment[TOPICLEN] = '\0'; | |
85 | ||
86 | *buf = '\0'; | |
87 | if((p = strchr(parv[1], ','))) | |
88 | *p = '\0'; | |
89 | ||
90 | name = LOCAL_COPY(parv[1]); | |
91 | ||
92 | chptr = find_channel(name); | |
93 | if(!chptr) | |
94 | { | |
95 | sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name); | |
96 | return 0; | |
97 | } | |
98 | ||
99 | ||
100 | if((p = strchr(parv[2], ','))) | |
101 | *p = '\0'; | |
55abcbb2 | 102 | user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ","); |
212380e3 AC |
103 | if(!(who = find_chasing(source_p, user, &chasing))) |
104 | { | |
105 | return 0; | |
106 | } | |
107 | ||
108 | if((target_p = find_client(user)) == NULL) | |
109 | { | |
a6adeaad | 110 | sendto_one(source_p, form_str(ERR_NOSUCHNICK), user); |
212380e3 AC |
111 | return 0; |
112 | } | |
113 | ||
114 | if((msptr = find_channel_membership(chptr, target_p)) == NULL) | |
115 | { | |
a6adeaad | 116 | sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL), parv[1], parv[2]); |
212380e3 AC |
117 | return 0; |
118 | } | |
119 | ||
120 | sendto_wallops_flags(UMODE_WALLOP, &me, | |
121 | "OKICK called for %s %s by %s!%s@%s", | |
122 | chptr->chname, target_p->name, | |
123 | source_p->name, source_p->username, source_p->host); | |
124 | ilog(L_MAIN, "OKICK called for %s %s by %s", | |
125 | chptr->chname, target_p->name, | |
126 | get_oper_name(source_p)); | |
127 | /* only sends stuff for #channels remotely */ | |
128 | sendto_server(NULL, chptr, NOCAPS, NOCAPS, | |
129 | ":%s WALLOPS :OKICK called for %s %s by %s!%s@%s", | |
130 | me.name, chptr->chname, target_p->name, | |
131 | source_p->name, source_p->username, source_p->host); | |
132 | ||
133 | sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s", | |
134 | me.name, chptr->chname, who->name, comment); | |
8e8f4ffc JT |
135 | sendto_server(&me, chptr, CAP_TS6, NOCAPS, |
136 | ":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment); | |
212380e3 AC |
137 | remove_user_from_channel(msptr); |
138 | return 0; | |
139 | } |