]>
Commit | Line | Data |
---|---|---|
212380e3 | 1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * m_quit.c: Makes a user quit from IRC. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
23 | * | |
212380e3 | 24 | */ |
25 | ||
26 | #include "stdinc.h" | |
27 | #include "client.h" | |
28 | #include "ircd.h" | |
29 | #include "numeric.h" | |
30 | #include "s_serv.h" | |
31 | #include "send.h" | |
32 | #include "msg.h" | |
33 | #include "parse.h" | |
34 | #include "modules.h" | |
35 | #include "s_conf.h" | |
7e8e21a4 | 36 | #include "inline/stringops.h" |
212380e3 | 37 | |
38 | static int m_quit(struct Client *, struct Client *, int, const char **); | |
39 | static int ms_quit(struct Client *, struct Client *, int, const char **); | |
40 | ||
41 | struct Message quit_msgtab = { | |
42 | "QUIT", 0, 0, 0, MFLG_SLOW | MFLG_UNREG, | |
43 | {{m_quit, 0}, {m_quit, 0}, {ms_quit, 0}, mg_ignore, mg_ignore, {m_quit, 0}} | |
44 | }; | |
45 | ||
46 | mapi_clist_av1 quit_clist[] = { &quit_msgtab, NULL }; | |
47 | ||
48 | DECLARE_MODULE_AV1(quit, NULL, NULL, quit_clist, NULL, NULL, "$Revision: 1333 $"); | |
49 | ||
50 | /* | |
51 | ** m_quit | |
212380e3 | 52 | ** parv[1] = comment |
53 | */ | |
54 | static int | |
55 | m_quit(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
56 | { | |
57 | char *comment = LOCAL_COPY((parc > 1 && parv[1]) ? parv[1] : client_p->name); | |
58 | char reason[REASONLEN + 1]; | |
59 | ||
60 | source_p->flags |= FLAGS_NORMALEX; | |
61 | ||
62 | if(strlen(comment) > (size_t) REASONLEN) | |
63 | comment[REASONLEN] = '\0'; | |
64 | ||
65 | strip_colour(comment); | |
66 | ||
67 | if(ConfigFileEntry.client_exit && comment[0]) | |
68 | { | |
581fa5c4 | 69 | rb_snprintf(reason, sizeof(reason), "Quit: %s", comment); |
212380e3 | 70 | comment = reason; |
71 | } | |
72 | ||
c0e2aa60 JH |
73 | if(!IsOper(source_p) && !EmptyString(ConfigFileEntry.static_quit)) |
74 | { | |
75 | exit_client(client_p, source_p, source_p, ConfigFileEntry.static_quit); | |
76 | return 0; | |
77 | } | |
78 | ||
212380e3 | 79 | if(!IsOper(source_p) && |
80 | (source_p->localClient->firsttime + ConfigFileEntry.anti_spam_exit_message_time) > | |
9f6bbe3c | 81 | rb_current_time()) |
212380e3 | 82 | { |
83 | exit_client(client_p, source_p, source_p, "Client Quit"); | |
84 | return 0; | |
85 | } | |
86 | ||
87 | exit_client(client_p, source_p, source_p, comment); | |
88 | ||
89 | return 0; | |
90 | } | |
91 | ||
92 | /* | |
93 | ** ms_quit | |
212380e3 | 94 | ** parv[1] = comment |
95 | */ | |
96 | static int | |
97 | ms_quit(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
98 | { | |
99 | char *comment = LOCAL_COPY((parc > 1 && parv[1]) ? parv[1] : client_p->name); | |
100 | ||
101 | source_p->flags |= FLAGS_NORMALEX; | |
102 | if(strlen(comment) > (size_t) REASONLEN) | |
103 | comment[REASONLEN] = '\0'; | |
104 | ||
105 | exit_client(client_p, source_p, source_p, comment); | |
106 | ||
107 | return 0; | |
108 | } |