]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * m_away.c: Sets/removes away status on a user. | |
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 | * | |
e8a2d50d | 24 | * $Id: m_away.c 3370 2007-04-03 10:15:39Z nenolod $ |
212380e3 AC |
25 | */ |
26 | ||
27 | #include "stdinc.h" | |
28 | #include "client.h" | |
4562c604 | 29 | #include "match.h" |
212380e3 AC |
30 | #include "ircd.h" |
31 | #include "numeric.h" | |
32 | #include "send.h" | |
33 | #include "msg.h" | |
34 | #include "parse.h" | |
35 | #include "modules.h" | |
36 | #include "s_conf.h" | |
37 | #include "s_serv.h" | |
38 | #include "packet.h" | |
39 | ||
212380e3 AC |
40 | static int m_away(struct Client *, struct Client *, int, const char **); |
41 | ||
42 | struct Message away_msgtab = { | |
43 | "AWAY", 0, 0, 0, MFLG_SLOW, | |
44 | {mg_unreg, {m_away, 0}, {m_away, 0}, mg_ignore, mg_ignore, {m_away, 0}} | |
45 | }; | |
46 | ||
47 | mapi_clist_av1 away_clist[] = { &away_msgtab, NULL }; | |
e8a2d50d | 48 | DECLARE_MODULE_AV1(away, NULL, NULL, away_clist, NULL, NULL, "$Revision: 3370 $"); |
212380e3 AC |
49 | |
50 | /*********************************************************************** | |
51 | * m_away() - Added 14 Dec 1988 by jto. | |
52 | * Not currently really working, I don't like this | |
53 | * call at all... | |
54 | * | |
55 | * ...trying to make it work. I don't like it either, | |
56 | * but perhaps it's worth the load it causes to net. | |
57 | * This requires flooding of the whole net like NICK, | |
58 | * USER, MODE, etc messages... --msa | |
59 | * | |
60 | * The above comments have long since irrelvant, but | |
61 | * are kept for historical purposes now ;) | |
62 | ***********************************************************************/ | |
63 | ||
64 | /* | |
65 | ** m_away | |
212380e3 AC |
66 | ** parv[1] = away message |
67 | */ | |
68 | static int | |
69 | m_away(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
70 | { | |
725403fd JT |
71 | if(MyClient(source_p) && source_p->localClient->next_away && |
72 | !IsFloodDone(source_p)) | |
f237e31a JT |
73 | flood_endgrace(source_p); |
74 | ||
75 | if(!IsClient(source_p)) | |
76 | return 0; | |
77 | ||
78 | if(parc < 2 || EmptyString(parv[1])) | |
79 | { | |
80 | /* Marking as not away */ | |
c127b45b | 81 | if(source_p->user->away != NULL) |
f237e31a JT |
82 | { |
83 | /* we now send this only if they were away before --is */ | |
84 | sendto_server(client_p, NULL, CAP_TS6, NOCAPS, | |
85 | ":%s AWAY", use_id(source_p)); | |
c127b45b | 86 | free_away(source_p); |
c5bbc603 KB |
87 | |
88 | sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, ":%s!%s@%s AWAY", | |
89 | source_p->name, source_p->username, source_p->host); | |
f237e31a JT |
90 | } |
91 | if(MyConnect(source_p)) | |
e85075ec | 92 | sendto_one_numeric(source_p, RPL_UNAWAY, form_str(RPL_UNAWAY)); |
f237e31a JT |
93 | return 0; |
94 | } | |
95 | ||
d42e6915 | 96 | /* Rate limit this because it is sent to common channels. */ |
dc0fd462 | 97 | if (MyClient(source_p)) |
d42e6915 | 98 | { |
dc0fd462 AC |
99 | if(!IsOper(source_p) && |
100 | source_p->localClient->next_away > rb_current_time()) | |
101 | { | |
102 | sendto_one(source_p, form_str(RPL_LOAD2HI), | |
103 | me.name, source_p->name, "AWAY"); | |
9120d0ef | 104 | return 0; |
dc0fd462 AC |
105 | } |
106 | if(source_p->localClient->next_away < rb_current_time() - | |
107 | ConfigFileEntry.away_interval) | |
108 | source_p->localClient->next_away = rb_current_time(); | |
109 | else | |
110 | source_p->localClient->next_away = rb_current_time() + | |
111 | ConfigFileEntry.away_interval; | |
d42e6915 | 112 | } |
d42e6915 | 113 | |
c127b45b | 114 | if(source_p->user->away == NULL) |
c127b45b | 115 | allocate_away(source_p); |
76a2bba9 JT |
116 | if(strncmp(source_p->user->away, parv[1], AWAYLEN - 1)) |
117 | { | |
c127b45b SB |
118 | rb_strlcpy(source_p->user->away, parv[1], AWAYLEN); |
119 | sendto_server(client_p, NULL, CAP_TS6, NOCAPS, | |
120 | ":%s AWAY :%s", use_id(source_p), source_p->user->away); | |
65b8d06c JT |
121 | sendto_common_channels_local_butone(source_p, |
122 | CLICAP_AWAY_NOTIFY, | |
123 | ":%s!%s@%s AWAY :%s", | |
124 | source_p->name, | |
125 | source_p->username, | |
126 | source_p->host, | |
127 | source_p->user->away); | |
c127b45b | 128 | } |
dc0fd462 | 129 | |
f237e31a | 130 | if(MyConnect(source_p)) |
e85075ec | 131 | sendto_one_numeric(source_p, RPL_NOWAWAY, form_str(RPL_NOWAWAY)); |
f237e31a | 132 | |
212380e3 AC |
133 | return 0; |
134 | } |