]>
Commit | Line | Data |
---|---|---|
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 | * | |
24 | * $Id: m_away.c 254 2005-09-21 23:35:12Z nenolod $ | |
25 | */ | |
26 | ||
27 | #include "stdinc.h" | |
28 | #include "client.h" | |
29 | #include "irc_string.h" | |
30 | #include "ircd.h" | |
31 | #include "numeric.h" | |
32 | #include "send.h" | |
33 | #include "msg.h" | |
34 | #include "parse.h" | |
35 | #include "modules.h" | |
36 | #include "s_conf.h" | |
37 | #include "s_serv.h" | |
38 | #include "packet.h" | |
39 | ||
40 | ||
41 | static int m_away(struct Client *, struct Client *, int, const char **); | |
42 | ||
43 | struct Message away_msgtab = { | |
44 | "AWAY", 0, 0, 0, MFLG_SLOW, | |
45 | {mg_unreg, {m_away, 0}, {m_away, 0}, mg_ignore, mg_ignore, {m_away, 0}} | |
46 | }; | |
47 | ||
48 | mapi_clist_av1 away_clist[] = { &away_msgtab, NULL }; | |
49 | DECLARE_MODULE_AV1(away, NULL, NULL, away_clist, NULL, NULL, "$Revision: 254 $"); | |
50 | ||
51 | /*********************************************************************** | |
52 | * m_away() - Added 14 Dec 1988 by jto. | |
53 | * Not currently really working, I don't like this | |
54 | * call at all... | |
55 | * | |
56 | * ...trying to make it work. I don't like it either, | |
57 | * but perhaps it's worth the load it causes to net. | |
58 | * This requires flooding of the whole net like NICK, | |
59 | * USER, MODE, etc messages... --msa | |
60 | * | |
61 | * The above comments have long since irrelvant, but | |
62 | * are kept for historical purposes now ;) | |
63 | ***********************************************************************/ | |
64 | ||
65 | /* | |
66 | ** m_away | |
67 | ** parv[0] = sender prefix | |
68 | ** parv[1] = away message | |
69 | */ | |
70 | static int | |
71 | m_away(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
72 | { | |
73 | char *away; | |
74 | char *awy2; | |
75 | ||
76 | if(MyClient(source_p) && !IsFloodDone(source_p)) | |
77 | flood_endgrace(source_p); | |
78 | ||
79 | if(!IsClient(source_p)) | |
80 | return 0; | |
81 | ||
82 | away = source_p->user->away; | |
83 | ||
84 | if(parc < 2 || EmptyString(parv[1])) | |
85 | { | |
86 | /* Marking as not away */ | |
87 | if(away) | |
88 | { | |
89 | /* we now send this only if they were away before --is */ | |
90 | sendto_server(client_p, NULL, CAP_TS6, NOCAPS, | |
91 | ":%s AWAY", use_id(source_p)); | |
92 | sendto_server(client_p, NULL, NOCAPS, CAP_TS6, | |
93 | ":%s AWAY", source_p->name); | |
94 | MyFree(away); | |
95 | source_p->user->away = NULL; | |
96 | } | |
97 | if(MyConnect(source_p)) | |
98 | sendto_one(source_p, form_str(RPL_UNAWAY), | |
99 | me.name, source_p->name); | |
100 | return 0; | |
101 | } | |
102 | ||
103 | /* Marking as away */ | |
104 | ||
105 | if(MyConnect(source_p)) | |
106 | { | |
107 | if(!IsOper(source_p) && | |
108 | (CurrentTime - source_p->localClient->last_away) < ConfigFileEntry.pace_wait) | |
109 | { | |
110 | sendto_one(source_p, form_str(RPL_LOAD2HI), | |
111 | me.name, source_p->name, "AWAY"); | |
112 | return 0; | |
113 | } | |
114 | ||
115 | source_p->localClient->last_away = CurrentTime; | |
116 | } | |
117 | ||
118 | awy2 = LOCAL_COPY(parv[1]); | |
119 | if(strlen(awy2) > AWAYLEN) | |
120 | awy2[AWAYLEN] = '\0'; | |
121 | ||
122 | /* we now send this only if they weren't away already --is */ | |
123 | if(!away) | |
124 | { | |
125 | sendto_server(client_p, NULL, CAP_TS6, NOCAPS, | |
126 | ":%s AWAY :%s", use_id(source_p), awy2); | |
127 | sendto_server(client_p, NULL, NOCAPS, CAP_TS6, | |
128 | ":%s AWAY :%s", source_p->name, awy2); | |
129 | } | |
130 | else | |
131 | MyFree(away); | |
132 | ||
133 | DupString(away, awy2); | |
134 | ||
135 | source_p->user->away = away; | |
136 | ||
137 | if(MyConnect(source_p)) | |
138 | sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, source_p->name); | |
139 | ||
140 | return 0; | |
141 | } |