]> jfr.im git - irc/rqf/shadowircd.git/blame - extensions/m_okick.c
[svn] - update IDEAS as TS6 only is partially done
[irc/rqf/shadowircd.git] / extensions / m_okick.c
CommitLineData
212380e3 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
22 *
23 * $Id: m_okick.c 3117 2007-01-02 13:11:04Z jilles $
24 */
25
26#include "stdinc.h"
27#include "tools.h"
28#include "channel.h"
29#include "client.h"
30#include "irc_string.h"
31#include "ircd.h"
32#include "numeric.h"
33#include "send.h"
34#include "msg.h"
35#include "modules.h"
36#include "parse.h"
37#include "hash.h"
38#include "packet.h"
39#include "s_conf.h"
40#include "s_serv.h"
41
42static int mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
43
44
45struct Message okick_msgtab = {
46 "OKICK", 0, 0, 0, MFLG_SLOW,
47 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_okick, 4}}
48};
49
50mapi_clist_av1 okick_clist[] = { &okick_msgtab, NULL };
51
52DECLARE_MODULE_AV1(okick, NULL, NULL, okick_clist, NULL, NULL, "$Revision: 3117 $");
53
54/*
55** m_okick
56** parv[0] = sender prefix
57** parv[1] = channel
58** parv[2] = client to kick
59** parv[3] = kick comment
60*/
61static int
62mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
63{
64 struct Client *who;
65 struct Client *target_p;
66 struct Channel *chptr;
67 struct membership *msptr;
68 int chasing = 0;
69 char *comment;
70 char *name;
71 char *p = NULL;
72 char *user;
73 static char buf[BUFSIZE];
74
75 if(*parv[2] == '\0')
76 {
77 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "KICK");
78 return 0;
79 }
80
81 if(MyClient(source_p) && !IsFloodDone(source_p))
82 flood_endgrace(source_p);
83
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';
87
88 *buf = '\0';
89 if((p = strchr(parv[1], ',')))
90 *p = '\0';
91
92 name = LOCAL_COPY(parv[1]);
93
94 chptr = find_channel(name);
95 if(!chptr)
96 {
97 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
98 return 0;
99 }
100
101
102 if((p = strchr(parv[2], ',')))
103 *p = '\0';
104 user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ",");
105 if(!(who = find_chasing(source_p, user, &chasing)))
106 {
107 return 0;
108 }
109
110 if((target_p = find_client(user)) == NULL)
111 {
112 sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], user);
113 return 0;
114 }
115
116 if((msptr = find_channel_membership(chptr, target_p)) == NULL)
117 {
118 sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
119 me.name, parv[0], parv[1], parv[2]);
120 return 0;
121 }
122
123 sendto_wallops_flags(UMODE_WALLOP, &me,
124 "OKICK called for %s %s by %s!%s@%s",
125 chptr->chname, target_p->name,
126 source_p->name, source_p->username, source_p->host);
127 ilog(L_MAIN, "OKICK called for %s %s by %s",
128 chptr->chname, target_p->name,
129 get_oper_name(source_p));
130 /* only sends stuff for #channels remotely */
131 sendto_server(NULL, chptr, NOCAPS, NOCAPS,
132 ":%s WALLOPS :OKICK called for %s %s by %s!%s@%s",
133 me.name, chptr->chname, target_p->name,
134 source_p->name, source_p->username, source_p->host);
135
136 sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s",
137 me.name, chptr->chname, who->name, comment);
138 sendto_server(&me, chptr, NOCAPS, NOCAPS,
139 ":%s KICK %s %s :%s", me.name, chptr->chname, who->name, comment);
140 remove_user_from_channel(msptr);
141 return 0;
142}