]>
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 | |
212380e3 AC |
23 | */ |
24 | ||
25 | #include "stdinc.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 "parse.h" | |
33 | #include "modules.h" | |
34 | #include "s_conf.h" | |
35 | #include "s_serv.h" | |
36 | #include "packet.h" | |
37 | ||
eeabf33a EM |
38 | static const char away_desc[] = "Provides the AWAY command to set yourself away"; |
39 | ||
3c7d6fcc | 40 | static void m_away(struct MsgBuf *, struct Client *, struct Client *, int, const char **); |
212380e3 AC |
41 | |
42 | struct Message away_msgtab = { | |
7baa37a9 | 43 | "AWAY", 0, 0, 0, 0, |
212380e3 AC |
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 }; | |
3c88406e | 48 | |
3c88406e | 49 | DECLARE_MODULE_AV2(away, NULL, NULL, away_clist, NULL, NULL, NULL, NULL, away_desc); |
212380e3 AC |
50 | |
51 | /*********************************************************************** | |
55abcbb2 | 52 | * m_away() - Added 14 Dec 1988 by jto. |
212380e3 AC |
53 | * Not currently really working, I don't like this |
54 | * call at all... | |
55 | * | |
56 | * ...trying to make it work. I don't like it either, | |
57 | * but perhaps it's worth the load it causes to net. | |
58 | * This requires flooding of the whole net like NICK, | |
59 | * USER, MODE, etc messages... --msa | |
55abcbb2 | 60 | * |
212380e3 AC |
61 | * The above comments have long since irrelvant, but |
62 | * are kept for historical purposes now ;) | |
63 | ***********************************************************************/ | |
64 | ||
65 | /* | |
66 | ** m_away | |
212380e3 AC |
67 | ** parv[1] = away message |
68 | */ | |
3c7d6fcc | 69 | static void |
428ca87b | 70 | m_away(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 | 71 | { |
725403fd JT |
72 | if(MyClient(source_p) && source_p->localClient->next_away && |
73 | !IsFloodDone(source_p)) | |
f237e31a JT |
74 | flood_endgrace(source_p); |
75 | ||
76 | if(!IsClient(source_p)) | |
3c7d6fcc | 77 | return; |
f237e31a JT |
78 | |
79 | if(parc < 2 || EmptyString(parv[1])) | |
80 | { | |
81 | /* Marking as not away */ | |
c127b45b | 82 | if(source_p->user->away != NULL) |
f237e31a JT |
83 | { |
84 | /* we now send this only if they were away before --is */ | |
85 | sendto_server(client_p, NULL, CAP_TS6, NOCAPS, | |
86 | ":%s AWAY", use_id(source_p)); | |
c127b45b | 87 | free_away(source_p); |
c5bbc603 | 88 | |
583f064f | 89 | sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, NOCAPS, ":%s!%s@%s AWAY", |
c5bbc603 | 90 | source_p->name, source_p->username, source_p->host); |
f237e31a JT |
91 | } |
92 | if(MyConnect(source_p)) | |
e85075ec | 93 | sendto_one_numeric(source_p, RPL_UNAWAY, form_str(RPL_UNAWAY)); |
3c7d6fcc | 94 | return; |
f237e31a JT |
95 | } |
96 | ||
d42e6915 | 97 | /* Rate limit this because it is sent to common channels. */ |
dc0fd462 | 98 | if (MyClient(source_p)) |
d42e6915 | 99 | { |
dc0fd462 AC |
100 | if(!IsOper(source_p) && |
101 | source_p->localClient->next_away > rb_current_time()) | |
102 | { | |
103 | sendto_one(source_p, form_str(RPL_LOAD2HI), | |
104 | me.name, source_p->name, "AWAY"); | |
3c7d6fcc | 105 | return; |
dc0fd462 AC |
106 | } |
107 | if(source_p->localClient->next_away < rb_current_time() - | |
108 | ConfigFileEntry.away_interval) | |
109 | source_p->localClient->next_away = rb_current_time(); | |
110 | else | |
111 | source_p->localClient->next_away = rb_current_time() + | |
112 | ConfigFileEntry.away_interval; | |
d42e6915 | 113 | } |
d42e6915 | 114 | |
c127b45b | 115 | if(source_p->user->away == NULL) |
c127b45b | 116 | allocate_away(source_p); |
76a2bba9 JT |
117 | if(strncmp(source_p->user->away, parv[1], AWAYLEN - 1)) |
118 | { | |
c127b45b | 119 | rb_strlcpy(source_p->user->away, parv[1], AWAYLEN); |
55abcbb2 | 120 | sendto_server(client_p, NULL, CAP_TS6, NOCAPS, |
c127b45b | 121 | ":%s AWAY :%s", use_id(source_p), source_p->user->away); |
65b8d06c | 122 | sendto_common_channels_local_butone(source_p, |
583f064f | 123 | CLICAP_AWAY_NOTIFY, NOCAPS, |
65b8d06c JT |
124 | ":%s!%s@%s AWAY :%s", |
125 | source_p->name, | |
126 | source_p->username, | |
127 | source_p->host, | |
128 | source_p->user->away); | |
c127b45b | 129 | } |
dc0fd462 | 130 | |
f237e31a | 131 | if(MyConnect(source_p)) |
e85075ec | 132 | sendto_one_numeric(source_p, RPL_NOWAWAY, form_str(RPL_NOWAWAY)); |
212380e3 | 133 | } |