1 |
/** |
2 |
* ircd_loveserv.C: LoveServ implementation. |
3 |
* |
4 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
5 |
* Rights to this code are as documented in COPYING. |
6 |
* |
7 |
* |
8 |
* Portions of this file were derived from sources bearing the following license: |
9 |
* Copyright © 2006 William Pitcock, et al. |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: ircd_loveserv.C,v 1.4 2007-09-16 18:54:43 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#include "atheme.h" |
16 |
#include <ermyth/module.h> |
17 |
|
18 |
/* CONFIG SECTION */ |
19 |
#define LS_HOST "services.int" |
20 |
|
21 |
static char const rcsid[] = "$Id: ircd_loveserv.C,v 1.4 2007-09-16 18:54:43 pippijn Exp $"; |
22 |
|
23 |
REGISTER_MODULE ("contrib/ircd_loveserv", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
24 |
|
25 |
service_t *loveserv; |
26 |
list_t ls_cmdtree; |
27 |
|
28 |
static void |
29 |
_ls_admirer (char *origin) |
30 |
{ |
31 |
user_t *u; |
32 |
char *target = strtok (NULL, " "); |
33 |
|
34 |
if (target == NULL) |
35 |
{ |
36 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "ADMIRER"); |
37 |
notice (loveserv->name, origin, "Syntax: ADMIRER <target>"); |
38 |
return; |
39 |
} |
40 |
|
41 |
if ((u = user_find_named (target)) == NULL) |
42 |
{ |
43 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
44 |
return; |
45 |
} |
46 |
|
47 |
notice (loveserv->name, origin, "They have been told that they have a secret admirer. :)"); |
48 |
notice (loveserv->name, target, "You have a secret admirer ;)"); |
49 |
} |
50 |
|
51 |
command_t const ls_admirer = { "ADMIRER", "Tell somebody they have a secret admirer.", AC_NONE, _ls_admirer }; |
52 |
|
53 |
static void |
54 |
_ls_rose (char *origin) |
55 |
{ |
56 |
user_t *u; |
57 |
char *target = strtok (NULL, " "); |
58 |
|
59 |
if (target == NULL) |
60 |
{ |
61 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "ROSE"); |
62 |
notice (loveserv->name, origin, "Syntax: ROSE <target>"); |
63 |
return; |
64 |
} |
65 |
|
66 |
if ((u = user_find_named (target)) == NULL) |
67 |
{ |
68 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
69 |
return; |
70 |
} |
71 |
|
72 |
notice (loveserv->name, origin, "Your rose has been sent! :)"); |
73 |
notice (loveserv->name, target, "%s has sent you a pretty rose: \00303--<--<--<{\00304@", origin); |
74 |
} |
75 |
|
76 |
command_t const ls_rose = { "ROSE", "Sends a rose to somebody.", AC_NONE, _ls_rose }; |
77 |
|
78 |
static void |
79 |
_ls_chocolate (char *origin) |
80 |
{ |
81 |
user_t *u; |
82 |
char *target = strtok (NULL, " "); |
83 |
|
84 |
if (target == NULL) |
85 |
{ |
86 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "CHOCOLATE"); |
87 |
notice (loveserv->name, origin, "Syntax: CHOCOLATE <target>"); |
88 |
return; |
89 |
} |
90 |
|
91 |
if ((u = user_find_named (target)) == NULL) |
92 |
{ |
93 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
94 |
return; |
95 |
} |
96 |
|
97 |
notice (loveserv->name, origin, "Your chocolates have been sent! :)"); |
98 |
notice (loveserv->name, target, "%s would like you to have this YUMMY box of chocolates.", origin); |
99 |
} |
100 |
|
101 |
command_t const ls_chocolate = { "CHOCOLATE", "Sends chocolates to somebody.", AC_NONE, _ls_chocolate }; |
102 |
|
103 |
static void |
104 |
_ls_candy (char *origin) |
105 |
{ |
106 |
user_t *u; |
107 |
char *target = strtok (NULL, " "); |
108 |
|
109 |
if (target == NULL) |
110 |
{ |
111 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "CANDY"); |
112 |
notice (loveserv->name, origin, "Syntax: CANDY <target>"); |
113 |
return; |
114 |
} |
115 |
|
116 |
if ((u = user_find_named (target)) == NULL) |
117 |
{ |
118 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
119 |
return; |
120 |
} |
121 |
|
122 |
notice (loveserv->name, origin, "Your bag of candy has been sent! :)"); |
123 |
notice (loveserv->name, target, "%s would like you to have this bag of heart-shaped candies.", origin); |
124 |
} |
125 |
|
126 |
command_t const ls_candy = { "CANDY", "Sends a bag of candy to somebody.", AC_NONE, _ls_candy }; |
127 |
|
128 |
static void |
129 |
_ls_hug (char *origin) |
130 |
{ |
131 |
user_t *u; |
132 |
char *target = strtok (NULL, " "); |
133 |
|
134 |
if (target == NULL) |
135 |
{ |
136 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "HUG"); |
137 |
notice (loveserv->name, origin, "Syntax: HUG <target>"); |
138 |
return; |
139 |
} |
140 |
|
141 |
if ((u = user_find_named (target)) == NULL) |
142 |
{ |
143 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
144 |
return; |
145 |
} |
146 |
|
147 |
notice (loveserv->name, origin, "You have virtually hugged %s!", target); |
148 |
notice (loveserv->name, target, "%s has sent you a \002BIG WARM HUG\002.", origin); |
149 |
} |
150 |
|
151 |
command_t const ls_hug = { "HUG", "Reach out and hug somebody.", AC_NONE, _ls_hug }; |
152 |
|
153 |
static void |
154 |
_ls_kiss (char *origin) |
155 |
{ |
156 |
user_t *u; |
157 |
char *target = strtok (NULL, " "); |
158 |
|
159 |
if (target == NULL) |
160 |
{ |
161 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "KISS"); |
162 |
notice (loveserv->name, origin, "Syntax: KISS <target>"); |
163 |
return; |
164 |
} |
165 |
|
166 |
if ((u = user_find_named (target)) == NULL) |
167 |
{ |
168 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
169 |
return; |
170 |
} |
171 |
|
172 |
notice (loveserv->name, origin, "You have virtually kissed %s!", target); |
173 |
notice (loveserv->name, target, "%s has sent you a \00304kiss\003.", origin); |
174 |
} |
175 |
|
176 |
command_t const ls_kiss = { "KISS", "Kiss somebody.", AC_NONE, _ls_kiss }; |
177 |
|
178 |
static void |
179 |
_ls_lovenote (char *origin) |
180 |
{ |
181 |
user_t *u; |
182 |
char *target = strtok (NULL, " "); |
183 |
char *note = strtok (NULL, ""); |
184 |
|
185 |
if (target == NULL || note == NULL) |
186 |
{ |
187 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "LOVENOTE"); |
188 |
notice (loveserv->name, origin, "Syntax: LOVENOTE <target> <message>"); |
189 |
return; |
190 |
} |
191 |
|
192 |
if ((u = user_find_named (target)) == NULL) |
193 |
{ |
194 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
195 |
return; |
196 |
} |
197 |
|
198 |
notice (loveserv->name, origin, "Your love-note to %s has been sent.", target); |
199 |
notice (loveserv->name, target, "%s has sent you a love-note which reads: %s", origin, note); |
200 |
} |
201 |
|
202 |
command_t const ls_lovenote = { "LOVENOTE", "Sends a lovenote to somebody.", AC_NONE, _ls_lovenote }; |
203 |
|
204 |
static void |
205 |
_ls_apology (char *origin) |
206 |
{ |
207 |
user_t *u; |
208 |
char *target = strtok (NULL, " "); |
209 |
char *note = strtok (NULL, ""); |
210 |
|
211 |
if (target == NULL || note == NULL) |
212 |
{ |
213 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "APOLOGY"); |
214 |
notice (loveserv->name, origin, "Syntax: APOLOGY <target> <message>"); |
215 |
return; |
216 |
} |
217 |
|
218 |
if ((u = user_find_named (target)) == NULL) |
219 |
{ |
220 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
221 |
return; |
222 |
} |
223 |
|
224 |
notice (loveserv->name, origin, "Your apology to %s has been sent.", target); |
225 |
notice (loveserv->name, target, "%s would like to apologize for: %s", origin, note); |
226 |
} |
227 |
|
228 |
command_t const ls_apology = { "APOLOGY", "Sends an apology to somebody.", AC_NONE, _ls_apology }; |
229 |
|
230 |
static void |
231 |
_ls_thankyou (char *origin) |
232 |
{ |
233 |
user_t *u; |
234 |
char *target = strtok (NULL, " "); |
235 |
char *note = strtok (NULL, ""); |
236 |
|
237 |
if (target == NULL || note == NULL) |
238 |
{ |
239 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "THANKYOU"); |
240 |
notice (loveserv->name, origin, "Syntax: THANKYOU <target> <message>"); |
241 |
return; |
242 |
} |
243 |
|
244 |
if ((u = user_find_named (target)) == NULL) |
245 |
{ |
246 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
247 |
return; |
248 |
} |
249 |
|
250 |
notice (loveserv->name, origin, "Your thank-you note to %s has been sent.", target); |
251 |
notice (loveserv->name, target, "%s would like to thank you for: %s", origin, note); |
252 |
} |
253 |
|
254 |
command_t const ls_thankyou = { "THANKYOU", "Sends a thank-you note to somebody.", AC_NONE, _ls_thankyou }; |
255 |
|
256 |
static void |
257 |
_ls_spank (char *origin) |
258 |
{ |
259 |
user_t *u; |
260 |
char *target = strtok (NULL, " "); |
261 |
|
262 |
if (target == NULL) |
263 |
{ |
264 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "SPANK"); |
265 |
notice (loveserv->name, origin, "Syntax: SPANK <target>"); |
266 |
return; |
267 |
} |
268 |
|
269 |
if ((u = user_find_named (target)) == NULL) |
270 |
{ |
271 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
272 |
return; |
273 |
} |
274 |
|
275 |
notice (loveserv->name, origin, "You have virtually spanked %s!", target); |
276 |
notice (loveserv->name, target, "%s has given you a virtual playful spanking.", origin); |
277 |
} |
278 |
|
279 |
command_t const ls_spank = { "SPANK", "Gives somebody a spanking.", AC_NONE, _ls_spank }; |
280 |
|
281 |
static void |
282 |
_ls_chocobo (char *origin) /* silly */ |
283 |
{ |
284 |
user_t *u; |
285 |
char *target = strtok (NULL, " "); |
286 |
|
287 |
if (target == NULL) |
288 |
{ |
289 |
notice (loveserv->name, origin, STR_INSUFFICIENT_PARAMS, "CHOCOBO"); |
290 |
notice (loveserv->name, origin, "Syntax: CHOCOBO <target>"); |
291 |
return; |
292 |
} |
293 |
|
294 |
if ((u = user_find_named (target)) == NULL) |
295 |
{ |
296 |
notice (loveserv->name, origin, "As much as I'd love to do this, you need to specify a person who really exists!"); |
297 |
return; |
298 |
} |
299 |
|
300 |
notice (loveserv->name, origin, "Your chocobo has been sent to %s.", target); |
301 |
notice (loveserv->name, target, "%s would like you to have this chocobo. \00308Kweh!\003", origin); |
302 |
} |
303 |
|
304 |
command_t const ls_chocobo = { "CHOCOBO", "Sends a chocobo to somebody.", AC_NONE, _ls_chocobo }; |
305 |
|
306 |
static void |
307 |
_ls_help (char *origin) |
308 |
{ |
309 |
command_help (loveserv->name, origin, &ls_cmdtree); |
310 |
} |
311 |
|
312 |
command_t const ls_help = { "HELP", "Displays contextual help information.", AC_NONE, _ls_help }; |
313 |
|
314 |
static void |
315 |
ls_handler (char *origin, int parc, char *parv[]) |
316 |
{ |
317 |
char *cmd; |
318 |
char orig[BUFSIZE]; |
319 |
|
320 |
/* this should never happen */ |
321 |
if (parv[0][0] == '&') |
322 |
{ |
323 |
slog (LG_ERROR, "services(): got parv with local channel: %s", parv[0]); |
324 |
return; |
325 |
} |
326 |
|
327 |
/* make a copy of the original for debugging */ |
328 |
strlcpy (orig, parv[parc - 1], BUFSIZE); |
329 |
|
330 |
/* lets go through this to get the command */ |
331 |
cmd = strtok (parv[parc - 1], " "); |
332 |
|
333 |
if (!cmd) |
334 |
return; |
335 |
|
336 |
/* take the command through the hash table */ |
337 |
command_exec (loveserv, origin, cmd, &ls_cmdtree); |
338 |
} |
339 |
|
340 |
command_t const *ls_commands[] = { |
341 |
&ls_admirer, |
342 |
&ls_rose, |
343 |
&ls_chocolate, |
344 |
&ls_candy, |
345 |
&ls_hug, |
346 |
&ls_kiss, |
347 |
&ls_lovenote, |
348 |
&ls_apology, |
349 |
&ls_thankyou, |
350 |
&ls_spank, |
351 |
&ls_chocobo, |
352 |
&ls_help, |
353 |
NULL |
354 |
}; |
355 |
|
356 |
bool |
357 |
_modinit (module *m) |
358 |
{ |
359 |
loveserv = add_service ("LoveServ", "LoveServ", LS_HOST, "LoveServ, etc.", ls_handler); |
360 |
|
361 |
command_add_many (ls_commands, &ls_cmdtree); |
362 |
|
363 |
return true; |
364 |
} |
365 |
|
366 |
void |
367 |
_moddeinit () |
368 |
{ |
369 |
command_delete_many (ls_commands, &ls_cmdtree); |
370 |
|
371 |
del_service (loveserv); |
372 |
} |
373 |
|
374 |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
375 |
* vim:ts=8 |
376 |
* vim:sw=8 |
377 |
* vim:noexpandtab |
378 |
*/ |