]> jfr.im git - irc/rqf/shadowircd.git/blame - modules/m_away.c
Do not install ban .conf files (like kline.conf, rsv.conf, etc) as they aren't used...
[irc/rqf/shadowircd.git] / modules / m_away.c
CommitLineData
212380e3 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 *
212380e3 24 */
25
26#include "stdinc.h"
27#include "client.h"
13ae2f4b 28#include "match.h"
212380e3 29#include "ircd.h"
30#include "numeric.h"
31#include "send.h"
32#include "msg.h"
33#include "parse.h"
34#include "modules.h"
35#include "s_conf.h"
36#include "s_serv.h"
37#include "packet.h"
38
39
40static int m_away(struct Client *, struct Client *, int, const char **);
41
42struct 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
47mapi_clist_av1 away_clist[] = { &away_msgtab, NULL };
e8a2d50d 48DECLARE_MODULE_AV1(away, NULL, NULL, away_clist, NULL, NULL, "$Revision: 3370 $");
212380e3 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 66** parv[1] = away message
67*/
68static int
69m_away(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
70{
9df69d5b
JT
71 if(MyClient(source_p) && !IsFloodDone(source_p))
72 flood_endgrace(source_p);
73
74 if(!IsClient(source_p))
75 return 0;
76
77 if(parc < 2 || EmptyString(parv[1]))
78 {
79 /* Marking as not away */
c387fc41 80 if(source_p->user->away != NULL)
9df69d5b
JT
81 {
82 /* we now send this only if they were away before --is */
83 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
84 ":%s AWAY", use_id(source_p));
c387fc41 85 free_away(source_p);
9df69d5b
JT
86 }
87 if(MyConnect(source_p))
8308fcdf 88 sendto_one_numeric(source_p, RPL_UNAWAY, form_str(RPL_UNAWAY));
9df69d5b
JT
89 return 0;
90 }
91
c387fc41 92 if(source_p->user->away == NULL)
c387fc41 93 allocate_away(source_p);
97bd6a2e
JT
94 if(strncmp(source_p->user->away, parv[1], AWAYLEN - 1))
95 {
c387fc41
SB
96 rb_strlcpy(source_p->user->away, parv[1], AWAYLEN);
97 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
98 ":%s AWAY :%s", use_id(source_p), source_p->user->away);
c387fc41
SB
99 }
100
9df69d5b 101 if(MyConnect(source_p))
8308fcdf 102 sendto_one_numeric(source_p, RPL_NOWAWAY, form_str(RPL_NOWAWAY));
9df69d5b 103
212380e3 104 return 0;
105}