ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_away.c
Revision: 1834
Committed: Fri Apr 19 19:50:27 2013 UTC (13 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 5040 byte(s)
Log Message:
- Revert to -r1831

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

Properties

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