/[svn]/ircd-hybrid-8/modules/m_services.c
ViewVC logotype

Contents of /ircd-hybrid-8/modules/m_services.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1218 - (show annotations)
Fri Sep 16 08:42:03 2011 UTC (9 years, 5 months ago) by michael
File MIME type: text/x-chdr
File size: 10896 byte(s)
- add helpserv/statserv service aliases

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 *
4 * Copyright (C) 1999 by the Bahamut Development Team.
5 * Copyright (C) 2011 by the Hybrid Development Team.
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
23 /*! \file m_services.c
24 * \brief Provides service aliases
25 * \version $Id$
26 */
27
28 #include "stdinc.h"
29 #include "handlers.h"
30 #include "client.h"
31 #include "ircd.h"
32 #include "channel_mode.h"
33 #include "numeric.h"
34 #include "s_conf.h"
35 #include "s_serv.h"
36 #include "send.h"
37 #include "msg.h"
38 #include "parse.h"
39 #include "modules.h"
40 #include "irc_string.h"
41 #include "s_user.h"
42 #include "hash.h"
43
44
45 static void m_botserv(struct Client *, struct Client *, int, char *[]);
46 static void m_chanserv(struct Client *, struct Client *, int, char *[]);
47 static void m_memoserv(struct Client *, struct Client *, int, char *[]);
48 static void m_nickserv(struct Client *, struct Client *, int, char *[]);
49 static void m_operserv(struct Client *, struct Client *, int, char *[]);
50 static void m_statserv(struct Client *, struct Client *, int, char *[]);
51 static void m_helpserv(struct Client *, struct Client *, int, char *[]);
52 static void m_identify(struct Client *, struct Client *, int, char *[]);
53
54 struct Message ms_msgtab = {
55 "MS", 0, 0, 0, 1, MFLG_SLOW, 0,
56 {m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore}
57 };
58
59 struct Message ns_msgtab = {
60 "NS", 0, 0, 0, 1, MFLG_SLOW, 0,
61 {m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore}
62 };
63
64 struct Message os_msgtab = {
65 "OS", 0, 0, 0, 1, MFLG_SLOW, 0,
66 {m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore}
67 };
68
69 struct Message bs_msgtab = {
70 "BS", 0, 0, 0, 1, MFLG_SLOW, 0,
71 {m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore}
72 };
73
74 struct Message cs_msgtab = {
75 "CS", 0, 0, 0, 1, MFLG_SLOW, 0,
76 {m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore}
77 };
78
79 struct Message ss_msgtab = {
80 "SS", 0, 0, 0, 1, MFLG_SLOW, 0,
81 {m_unregistered, m_statserv, m_ignore, m_ignore, m_statserv, m_ignore}
82 };
83
84 struct Message hs_msgtab = {
85 "HS", 0, 0, 0, 1, MFLG_SLOW, 0,
86 {m_unregistered, m_helpserv, m_ignore, m_ignore, m_helpserv, m_ignore}
87 };
88
89 struct Message botserv_msgtab = {
90 "BOTSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
91 {m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore}
92 };
93
94 struct Message chanserv_msgtab = {
95 "CHANSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
96 {m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore}
97 };
98
99 struct Message memoserv_msgtab = {
100 "MEMOSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
101 {m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore}
102 };
103
104 struct Message nickserv_msgtab = {
105 "NICKSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
106 {m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore}
107 };
108
109 struct Message operserv_msgtab = {
110 "OPERSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
111 {m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore}
112 };
113
114 struct Message statserv_msgtab = {
115 "STATSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
116 {m_unregistered, m_statserv, m_ignore, m_ignore, m_statserv, m_ignore}
117 };
118
119 struct Message helpserv_msgtab = {
120 "HELPSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
121 {m_unregistered, m_helpserv, m_ignore, m_ignore, m_helpserv, m_ignore}
122 };
123
124 struct Message identify_msgtab = {
125 "IDENTIFY", 0, 0, 0, 1, MFLG_SLOW, 0,
126 {m_unregistered, m_identify, m_ignore, m_ignore, m_identify, m_ignore}
127 };
128
129 void
130 _modinit(void)
131 {
132 mod_add_cmd(&botserv_msgtab);
133 mod_add_cmd(&chanserv_msgtab);
134 mod_add_cmd(&memoserv_msgtab);
135 mod_add_cmd(&nickserv_msgtab);
136 mod_add_cmd(&operserv_msgtab);
137 mod_add_cmd(&statserv_msgtab);
138 mod_add_cmd(&helpserv_msgtab);
139 mod_add_cmd(&identify_msgtab);
140 mod_add_cmd(&bs_msgtab);
141 mod_add_cmd(&ns_msgtab);
142 mod_add_cmd(&cs_msgtab);
143 mod_add_cmd(&ms_msgtab);
144 mod_add_cmd(&os_msgtab);
145 mod_add_cmd(&ss_msgtab);
146 mod_add_cmd(&hs_msgtab);
147 }
148
149 void
150 _moddeinit(void)
151 {
152 mod_del_cmd(&botserv_msgtab);
153 mod_del_cmd(&chanserv_msgtab);
154 mod_del_cmd(&memoserv_msgtab);
155 mod_del_cmd(&nickserv_msgtab);
156 mod_del_cmd(&operserv_msgtab);
157 mod_del_cmd(&statserv_msgtab);
158 mod_del_cmd(&helpserv_msgtab);
159 mod_del_cmd(&identify_msgtab);
160 mod_del_cmd(&bs_msgtab);
161 mod_del_cmd(&ns_msgtab);
162 mod_del_cmd(&cs_msgtab);
163 mod_del_cmd(&ms_msgtab);
164 mod_del_cmd(&os_msgtab);
165 mod_del_cmd(&ss_msgtab);
166 mod_del_cmd(&hs_msgtab);
167 }
168
169 const char *_version = "$Revision$";
170
171 /*
172 * XXX: Each services alias handler is currently ugly copy&paste.
173 * Configureable aliases will get implemented.
174 */
175
176 static void
177 m_nickserv(struct Client *client_p, struct Client *source_p,
178 int parc, char *parv[])
179 {
180 struct Client *target_p = NULL;
181
182 assert(client_p && source_p);
183 assert(client_p == source_p);
184
185 if (EmptyString(parv[1]))
186 {
187 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
188 me.name, source_p->name);
189 return;
190 }
191
192 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
193 {
194 sendto_one(target_p, ":%s PRIVMSG NickServ@%s :%s",
195 source_p->name, ConfigFileEntry.service_name, parv[1]);
196 return;
197 }
198
199 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
200 me.name, source_p->name, "NickServ");
201 }
202
203 static void
204 m_chanserv(struct Client *client_p, struct Client *source_p,
205 int parc, char *parv[])
206 {
207 struct Client *target_p = NULL;
208
209 assert(client_p && source_p);
210 assert(client_p == source_p);
211
212 if (EmptyString(parv[1]))
213 {
214 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
215 me.name, source_p->name);
216 return;
217 }
218
219 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
220 {
221 sendto_one(target_p, ":%s PRIVMSG ChanServ@%s :%s",
222 source_p->name, ConfigFileEntry.service_name, parv[1]);
223 return;
224 }
225
226 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
227 me.name, source_p->name, "ChanServ");
228 }
229
230 static void
231 m_memoserv(struct Client *client_p, struct Client *source_p,
232 int parc, char *parv[])
233 {
234 struct Client *target_p = NULL;
235
236 assert(client_p && source_p);
237 assert(client_p == source_p);
238
239 if (EmptyString(parv[1]))
240 {
241 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
242 me.name, source_p->name);
243 return;
244 }
245
246 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
247 {
248 sendto_one(target_p, ":%s PRIVMSG MemoServ@%s :%s",
249 source_p->name, ConfigFileEntry.service_name, parv[1]);
250 return;
251 }
252
253 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
254 me.name, source_p->name, "MemoServ");
255 }
256
257 static void
258 m_operserv(struct Client *client_p, struct Client *source_p,
259 int parc, char *parv[])
260 {
261 struct Client *target_p = NULL;
262
263 assert(client_p && source_p);
264 assert(client_p == source_p);
265
266 if (EmptyString(parv[1]))
267 {
268 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
269 me.name, source_p->name);
270 return;
271 }
272
273 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
274 {
275 sendto_one(target_p, ":%s PRIVMSG OperServ@%s :%s",
276 source_p->name, ConfigFileEntry.service_name, parv[1]);
277 return;
278 }
279
280 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
281 me.name, source_p->name, "OperServ");
282 }
283
284 static void
285 m_statserv(struct Client *client_p, struct Client *source_p,
286 int parc, char *parv[])
287 {
288 struct Client *target_p = NULL;
289
290 assert(client_p && source_p);
291 assert(client_p == source_p);
292
293 if (EmptyString(parv[1]))
294 {
295 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
296 me.name, source_p->name);
297 return;
298 }
299
300 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
301 {
302 sendto_one(target_p, ":%s PRIVMSG StatServ@%s :%s",
303 source_p->name, ConfigFileEntry.service_name, parv[1]);
304 return;
305 }
306
307 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
308 me.name, source_p->name, "StatServ");
309 }
310
311 static void
312 m_helpserv(struct Client *client_p, struct Client *source_p,
313 int parc, char *parv[])
314 {
315 struct Client *target_p = NULL;
316
317 assert(client_p && source_p);
318 assert(client_p == source_p);
319
320 if (EmptyString(parv[1]))
321 {
322 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
323 me.name, source_p->name);
324 return;
325 }
326
327 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
328 {
329 sendto_one(target_p, ":%s PRIVMSG HelpServ@%s :%s",
330 source_p->name, ConfigFileEntry.service_name, parv[1]);
331 return;
332 }
333
334 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
335 me.name, source_p->name, "HelpServ");
336 }
337
338 static void
339 m_botserv(struct Client *client_p, struct Client *source_p,
340 int parc, char *parv[])
341 {
342 struct Client *target_p = NULL;
343
344 assert(client_p && source_p);
345 assert(client_p == source_p);
346
347 if (EmptyString(parv[1]))
348 {
349 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
350 me.name, source_p->name);
351 return;
352 }
353
354 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
355 {
356 sendto_one(target_p, ":%s PRIVMSG BotServ@%s :%s",
357 source_p->name, ConfigFileEntry.service_name, parv[1]);
358 return;
359 }
360
361 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
362 me.name, source_p->name, "BotServ");
363 }
364
365 static void
366 m_identify(struct Client *client_p, struct Client *source_p,
367 int parc, char *parv[])
368 {
369 struct Client *target_p = NULL;
370
371 if (EmptyString(parv[1]))
372 {
373 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
374 me.name, source_p->name);
375 return;
376 }
377
378 if (IsChanPrefix(*parv[1]))
379 {
380 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
381 sendto_one(target_p, ":%s PRIVMSG ChanServ@%s :IDENTIFY %s",
382 source_p->name, ConfigFileEntry.service_name, parv[1]);
383 else
384 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
385 me.name, source_p->name, "ChanServ");
386 }
387 else
388 {
389 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
390 sendto_one(target_p, ":%s PRIVMSG NickServ@%s :IDENTIFY %s",
391 source_p->name, ConfigFileEntry.service_name, parv[1]);
392 else
393 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
394 me.name, source_p->name, "NickServ");
395 }
396 }

Properties

Name Value
svn:keywords Id Revision

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