ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/branches/newio/modules/m_away.c
Revision: 2417
Committed: Sun Jul 21 18:11:50 2013 UTC (10 years, 8 months ago) by michael
Content type: text/x-csrc
File size: 4971 byte(s)
Log Message:
- Change command message handlers to int type

File Contents

# Content
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 int
45 m_away(struct Client *client_p, struct Client *source_p,
46 int parc, char *parv[])
47 {
48 if (parc < 2 || EmptyString(parv[1]))
49 {
50 /* Marking as not away */
51 if (source_p->away[0])
52 {
53 source_p->away[0] = '\0';
54 /* we now send this only if they were away before --is */
55 sendto_server(client_p, CAP_TS6, NOCAPS,
56 ":%s AWAY", ID(source_p));
57 sendto_server(client_p, NOCAPS, CAP_TS6,
58 ":%s AWAY", source_p->name);
59 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
60 ":%s!%s@%s AWAY",
61 source_p->name, source_p->username,
62 source_p->host);
63 }
64
65 sendto_one(source_p, form_str(RPL_UNAWAY),
66 me.name, source_p->name);
67 return 0;
68 }
69
70 if ((CurrentTime - source_p->localClient->last_away) < ConfigFileEntry.pace_wait)
71 {
72 sendto_one(source_p, form_str(RPL_LOAD2HI),
73 me.name, source_p->name);
74 return 0;
75 }
76
77 source_p->localClient->last_away = CurrentTime;
78 sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, source_p->name);
79
80 if (!strncmp(source_p->away, parv[1], sizeof(source_p->away) - 1))
81 return 0;
82
83 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
84
85 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
86 ":%s!%s@%s AWAY :%s",
87 source_p->name, source_p->username,
88 source_p->host, source_p->away);
89 sendto_server(client_p, CAP_TS6, NOCAPS,
90 ":%s AWAY :%s", ID(source_p), source_p->away);
91 sendto_server(client_p, NOCAPS, CAP_TS6,
92 ":%s AWAY :%s", source_p->name, source_p->away);
93 return 0;
94 }
95
96 static int
97 ms_away(struct Client *client_p, struct Client *source_p,
98 int parc, char *parv[])
99 {
100 if (parc < 2 || EmptyString(parv[1]))
101 {
102 /* Marking as not away */
103 if (source_p->away[0])
104 {
105 source_p->away[0] = '\0';
106 /* we now send this only if they were away before --is */
107 sendto_server(client_p, CAP_TS6, NOCAPS,
108 ":%s AWAY", ID(source_p));
109 sendto_server(client_p, NOCAPS, CAP_TS6,
110 ":%s AWAY", source_p->name);
111 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
112 ":%s!%s@%s AWAY",
113 source_p->name, source_p->username,
114 source_p->host);
115 }
116
117 return 0;
118 }
119
120 if (!strncmp(source_p->away, parv[1], sizeof(source_p->away) - 1))
121 return 0;
122
123 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
124
125 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
126 ":%s!%s@%s AWAY :%s",
127 source_p->name, source_p->username,
128 source_p->host, source_p->away);
129 sendto_server(client_p, CAP_TS6, NOCAPS,
130 ":%s AWAY :%s", ID(source_p), source_p->away);
131 sendto_server(client_p, NOCAPS, CAP_TS6,
132 ":%s AWAY :%s", source_p->name, source_p->away);
133 return 0;
134 }
135
136 static struct Message away_msgtab =
137 {
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 {
158 .node = { NULL, NULL, NULL },
159 .name = NULL,
160 .version = "$Revision$",
161 .handle = NULL,
162 .modinit = module_init,
163 .modexit = module_exit,
164 .flags = 0
165 };

Properties

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