/[svn]/ircd-hybrid/trunk/modules/m_away.c
ViewVC logotype

Contents of /ircd-hybrid/trunk/modules/m_away.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2341 - (show annotations)
Wed Jul 3 13:54:23 2013 UTC (9 years, 1 month ago) by michael
File MIME type: text/x-chdr
File size: 5000 byte(s)
- Removed useless sanity checks
- Fixed bug where remote /STATS requests were not rate limited

1 /*
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 * $Id$
23 */
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 #include "conf.h"
34 #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 if (source_p->away[0])
55 {
56 source_p->away[0] = '\0';
57 /* we now send this only if they were away before --is */
58 sendto_server(client_p, CAP_TS6, NOCAPS,
59 ":%s AWAY", ID(source_p));
60 sendto_server(client_p, NOCAPS, CAP_TS6,
61 ":%s AWAY", source_p->name);
62 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
63 ":%s!%s@%s AWAY",
64 source_p->name, source_p->username,
65 source_p->host);
66 }
67
68 sendto_one(source_p, form_str(RPL_UNAWAY),
69 me.name, source_p->name);
70 return;
71 }
72
73 if ((CurrentTime - source_p->localClient->last_away) < ConfigFileEntry.pace_wait)
74 {
75 sendto_one(source_p, form_str(RPL_LOAD2HI),
76 me.name, source_p->name);
77 return;
78 }
79
80 source_p->localClient->last_away = CurrentTime;
81 sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, source_p->name);
82
83 if (!strncmp(source_p->away, parv[1], sizeof(source_p->away) - 1))
84 return;
85
86 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
87
88 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
89 ":%s!%s@%s AWAY :%s",
90 source_p->name, source_p->username,
91 source_p->host, source_p->away);
92 sendto_server(client_p, CAP_TS6, NOCAPS,
93 ":%s AWAY :%s", ID(source_p), source_p->away);
94 sendto_server(client_p, NOCAPS, CAP_TS6,
95 ":%s AWAY :%s", source_p->name, source_p->away);
96 }
97
98 static void
99 ms_away(struct Client *client_p, struct Client *source_p,
100 int parc, char *parv[])
101 {
102 if (parc < 2 || EmptyString(parv[1]))
103 {
104 /* Marking as not away */
105 if (source_p->away[0])
106 {
107 source_p->away[0] = '\0';
108 /* we now send this only if they were away before --is */
109 sendto_server(client_p, CAP_TS6, NOCAPS,
110 ":%s AWAY", ID(source_p));
111 sendto_server(client_p, NOCAPS, CAP_TS6,
112 ":%s AWAY", source_p->name);
113 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
114 ":%s!%s@%s AWAY",
115 source_p->name, source_p->username,
116 source_p->host);
117 }
118
119 return;
120 }
121
122 if (!strncmp(source_p->away, parv[1], sizeof(source_p->away) - 1))
123 return;
124
125 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
126
127 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
128 ":%s!%s@%s AWAY :%s",
129 source_p->name, source_p->username,
130 source_p->host, source_p->away);
131 sendto_server(client_p, CAP_TS6, NOCAPS,
132 ":%s AWAY :%s", ID(source_p), source_p->away);
133 sendto_server(client_p, NOCAPS, CAP_TS6,
134 ":%s AWAY :%s", source_p->name, source_p->away);
135 }
136
137 static struct Message away_msgtab = {
138 "AWAY", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
139 { m_unregistered, m_away, ms_away, m_ignore, m_away, m_ignore }
140 };
141
142 static void
143 module_init(void)
144 {
145 mod_add_cmd(&away_msgtab);
146 add_isupport("AWAYLEN", NULL, AWAYLEN);
147 }
148
149 static void
150 module_exit(void)
151 {
152 mod_del_cmd(&away_msgtab);
153 delete_isupport("AWAYLEN");
154 }
155
156 struct module module_entry = {
157 .node = { NULL, NULL, NULL },
158 .name = NULL,
159 .version = "$Revision$",
160 .handle = NULL,
161 .modinit = module_init,
162 .modexit = module_exit,
163 .flags = 0
164 };

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28