ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_away.c
Revision: 1484
Committed: Thu Jul 26 18:38:56 2012 UTC (14 years, 2 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_away.c
File size: 3903 byte(s)
Log Message:
- Add back AWAY throttling, now that we allow changing away messages
  without unsetting AWAY in the first place

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_away.c: Sets/removes away status on a user.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
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.
11     *
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.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "client.h"
27     #include "irc_string.h"
28     #include "ircd.h"
29     #include "numeric.h"
30     #include "send.h"
31     #include "parse.h"
32     #include "modules.h"
33 michael 1309 #include "conf.h"
34 adx 30 #include "s_serv.h"
35     #include "packet.h"
36     #include "s_user.h"
37    
38    
39     /*
40     * m_away
41     * parv[0] = sender prefix
42     * parv[1] = away message
43     */
44     static void
45     m_away(struct Client *client_p, struct Client *source_p,
46     int parc, char *parv[])
47     {
48     if (!IsFloodDone(source_p))
49     flood_endgrace(source_p);
50    
51     if (parc < 2 || EmptyString(parv[1]))
52     {
53     /* Marking as not away */
54 michael 1483 if (source_p->away[0])
55 adx 30 {
56     /* we now send this only if they were away before --is */
57 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
58 michael 885 ":%s AWAY", ID(source_p));
59 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
60 michael 885 ":%s AWAY", source_p->name);
61 michael 1483 source_p->away[0] = '\0';
62 adx 30 }
63    
64     sendto_one(source_p, form_str(RPL_UNAWAY),
65     me.name, source_p->name);
66     return;
67     }
68    
69 michael 1484 if ((CurrentTime - source_p->localClient->last_away) < ConfigFileEntry.pace_wait)
70     {
71     sendto_one(source_p, form_str(RPL_LOAD2HI),
72     me.name, source_p->name);
73     return;
74     }
75    
76     source_p->localClient->last_away = CurrentTime;
77 michael 1483 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
78 adx 30
79 michael 1483 sendto_server(client_p, CAP_TS6, NOCAPS,
80     ":%s AWAY :%s", ID(source_p), source_p->away);
81     sendto_server(client_p, NOCAPS, CAP_TS6,
82     ":%s AWAY :%s", source_p->name, source_p->away);
83 adx 30 sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, source_p->name);
84     }
85    
86     static void
87     ms_away(struct Client *client_p, struct Client *source_p,
88     int parc, char *parv[])
89     {
90     if (!IsClient(source_p))
91     return;
92    
93     if (parc < 2 || EmptyString(parv[1]))
94     {
95     /* Marking as not away */
96 michael 1483 if (source_p->away[0])
97 adx 30 {
98     /* we now send this only if they were away before --is */
99 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
100 michael 885 ":%s AWAY", ID(source_p));
101 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
102 michael 885 ":%s AWAY", source_p->name);
103 michael 1483 source_p->away[0] = '\0';
104 adx 30 }
105    
106     return;
107     }
108    
109 michael 1483 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
110 adx 30
111 michael 1483 sendto_server(client_p, CAP_TS6, NOCAPS,
112     ":%s AWAY :%s", ID(source_p), source_p->away);
113     sendto_server(client_p, NOCAPS, CAP_TS6,
114     ":%s AWAY :%s", source_p->name, source_p->away);
115 adx 30 }
116 michael 1230
117     static struct Message away_msgtab = {
118     "AWAY", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
119 michael 1449 { m_unregistered, m_away, ms_away, m_ignore, m_away, m_ignore }
120 michael 1230 };
121    
122     static void
123     module_init(void)
124     {
125     mod_add_cmd(&away_msgtab);
126     add_isupport("AWAYLEN", NULL, AWAYLEN);
127     }
128    
129     static void
130     module_exit(void)
131     {
132     mod_del_cmd(&away_msgtab);
133     delete_isupport("AWAYLEN");
134     }
135    
136     struct module module_entry = {
137     .node = { NULL, NULL, NULL },
138     .name = NULL,
139     .version = "$Revision$",
140     .handle = NULL,
141     .modinit = module_init,
142     .modexit = module_exit,
143     .flags = 0
144     };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision