Remove cruft left behind by removed stats_p_hook.
[seven-1.x.git] / modules / m_away.c
blob9463f066c666e07685a8da264436393b8c5819dd
1 /* {{{ irc-seven: Cows like it.
3 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center.
4 * Copyright (C) 1996-2002 Hybrid Development Team.
5 * Copyright (C) 2002-2005 ircd-ratbox development team.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to:
20 * Free Software Foundation, Inc.
21 * 51 Franklin St - Fifth Floor
22 * Boston, MA 02110-1301
23 * USA
25 * }}} */
27 /* {{{ Includes. */
28 #include "stdinc.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 "parse.h"
36 #include "modules.h"
37 #include "s_conf.h"
38 #include "s_serv.h"
39 #include "packet.h"
40 /* }}} */
42 static int m_away (struct Client *, struct Client *, int, const char **);
44 /* {{{ static struct Message away_msgtab = { ... } */
45 static struct Message away_msgtab =
47 "AWAY", 0, 0, 0, MFLG_SLOW,
49 mg_unreg, {m_away, 0}, {m_away, 0},
50 mg_ignore, mg_ignore, {m_away, 0},
53 /* }}} */
55 /* {{{ static mapi_clist_av1 away_clist[] = { ... } */
56 static mapi_clist_av1 away_clist[] =
58 &away_msgtab,
59 NULL
61 /* }}} */
63 /* {{{ DECLARE_MODULE_AV1(...) */
64 DECLARE_MODULE_AV1
66 away,
67 NULL,
68 NULL,
69 away_clist,
70 NULL,
71 NULL,
72 "1.1"
74 /* }}} */
76 /* {{{ static int m_away()
78 * AWAY message handler.
80 * Usage:
81 * AWAY [<message>]
83 * parv[0] - prefix
84 * parv[1] - message, or nothing
86 static int
87 m_away (struct Client *client_p, struct Client *source_p, int parc, const char **parv)
89 char *away = NULL;
90 char *away2 = NULL;
92 if (!IsClient(source_p))
93 return 0;
94 if (MyClient(source_p) && !IsFloodDone(source_p))
95 flood_endgrace(source_p);
97 away = source_p->user->away;
98 if (parc < 2 || EmptyString(parv[1]))
100 if (away)
102 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
103 ":%s AWAY", use_id(source_p));
104 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
105 ":%s AWAY", source_p->name);
107 MyFree(away);
108 source_p->user->away = NULL;
111 if (MyConnect(source_p))
112 sendto_one(source_p, form_str(RPL_UNAWAY), me.name,
113 source_p->name);
115 return 0;
118 if (MyConnect(source_p))
120 if (!IsOper(source_p) &&
121 (CurrentTime - source_p->localClient->last_away) < ConfigFileEntry.pace_wait)
123 sendto_one(source_p, form_str(RPL_LOAD2HI), me.name,
124 source_p->name, "AWAY");
125 return 0;
128 source_p->localClient->last_away = CurrentTime;
131 away2 = LOCAL_COPY(parv[1]);
132 if (strlen(away2) > AWAYLEN)
133 away2[AWAYLEN] = '\0';
135 if (!away)
137 sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s AWAY :%s",
138 use_id(source_p), away2);
139 sendto_server(client_p, NULL, NOCAPS, CAP_TS6, ":%s AWAY :%s",
140 source_p->name, away2);
142 else
143 MyFree(away);
145 DupString(away, away2);
146 source_p->user->away = away;
148 if (MyConnect(source_p))
149 sendto_one(source_p, form_str(RPL_NOWAWAY), me.name,
150 source_p->name);
152 return 0;
154 /* }}} */
157 * vim: ts=8 sw=8 noet fdm=marker tw=80