1 | #! perl |
1 | #! perl # depends=irc mandatory |
2 | #CONVERSION: PARTIAL |
|
|
3 | |
2 | |
4 | # implement a replacement for the built-in say/chat/shout/tell/reply commands |
3 | # implement a replacement for the built-in say/chat/shout/tell commands |
5 | # adds ignore/unignore functionality |
4 | # adds ignore/unignore functionality |
6 | |
5 | |
7 | use NPC_Dialogue; |
6 | use NPC_Dialogue; |
8 | use POSIX (); # for strftime only |
7 | use POSIX (); # for strftime only |
|
|
8 | |
|
|
9 | sub tell_channel($) { |
|
|
10 | my ($target) = @_; |
|
|
11 | |
|
|
12 | { |
|
|
13 | id => "tell-$target", |
|
|
14 | title => "$target", |
|
|
15 | reply => "tell $target ", |
|
|
16 | tooltip => "Private messages from/to $target", |
|
|
17 | } |
|
|
18 | } |
|
|
19 | |
|
|
20 | sub send_msg($$$$$) { |
|
|
21 | my ($pl, $channel, $msg, $flags, $sound) = @_; |
|
|
22 | $pl->play_sound (cf::sound::find $sound) if defined $sound; |
|
|
23 | $pl->send_msg ($channel, $msg, $flags); |
|
|
24 | () |
|
|
25 | } |
9 | |
26 | |
10 | sub clean_timeouts($) { |
27 | sub clean_timeouts($) { |
11 | my ($player) = @_; |
28 | my ($player) = @_; |
12 | my $NOW = time; |
29 | my $NOW = time; |
13 | |
30 | |
14 | for my $hash (@$player{qw(ext_ignore_shout ext_ignore_tell)}) { |
31 | for my $hash (@$player{qw(ext_ignore_shout ext_ignore_tell)}) { |
15 | while (my ($k, $v) = each %$hash) { |
32 | while (my ($k, $v) = each %$hash) { |
16 | if ($v < $NOW) { |
33 | if ($v < $NOW) { |
17 | $player->message ("Your ignore on $k has expired.", cf::NDI_GREEN | cf::NDI_UNIQUE); |
34 | $player->message ("Your ignore on $k has expired.", cf::NDI_GREEN); |
18 | delete $hash->{$k}; |
35 | delete $hash->{$k}; |
19 | } elsif (!cf::player::exists $k) { |
36 | } elsif (!cf::player::exists $k) { |
20 | $player->message ("Your ignore on $k is no longer valid (no such user).", cf::NDI_GREEN | cf::NDI_UNIQUE); |
37 | $player->message ("Your ignore on $k is no longer valid (no such user).", cf::NDI_GREEN); |
21 | delete $hash->{$k}; |
38 | delete $hash->{$k}; |
22 | } |
39 | } |
23 | } |
40 | } |
24 | } |
41 | } |
25 | } |
42 | } |
26 | |
43 | |
|
|
44 | # send_irc ($format, @args, $msg) |
|
|
45 | # make sure the last argument is the message! |
|
|
46 | sub send_irc { |
|
|
47 | my ($format, @args) = @_; |
|
|
48 | my $msg = pop @args; |
|
|
49 | for (split /\n/, $msg) { |
|
|
50 | ext::irc::do_notice (sprintf $format, @args, $_) |
|
|
51 | } |
|
|
52 | } |
|
|
53 | |
27 | cf::player->attach ( |
54 | cf::player->attach ( |
28 | prio => -1000, |
55 | prio => -1000, |
29 | on_login => sub { |
56 | on_login => sub { |
30 | my ($pl) = @_; |
57 | my ($pl) = @_; |
31 | |
58 | |
32 | clean_timeouts $pl->ob; |
59 | clean_timeouts $pl->ob; |
|
|
60 | |
|
|
61 | $pl->send_msg ($cf::SAY_CHANNEL); |
|
|
62 | $pl->send_msg ($cf::CHAT_CHANNEL); |
33 | }, |
63 | }, |
34 | ); |
64 | ); |
35 | |
65 | |
|
|
66 | # TODO: remove once safe |
36 | cf::register_command listen => sub { |
67 | cf::register_command listen => sub { |
|
|
68 | }; |
|
|
69 | |
|
|
70 | cf::register_command cointoss => sub { |
37 | my ($who, $msg) = @_; |
71 | my ($ob, $msg) = @_; |
38 | my $player = cf::player::find_active $who->name; |
|
|
39 | |
72 | |
40 | if ($msg ne "") { |
73 | my $pl = $ob->contr; |
41 | my $prev_listen = $player->listening; |
74 | my $name = $ob->name; |
42 | $player->listening ($msg); |
75 | |
43 | if ($prev_listen == $player->listening) { |
76 | my $coin = int rand 2 ? "Heads" : "Tails"; |
44 | $who->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); |
77 | |
45 | } else { |
78 | send_msg $_, $cf::SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say" |
46 | $who->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); |
79 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
|
|
80 | |
|
|
81 | $pl->send_msg ($cf::SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); |
|
|
82 | }; |
|
|
83 | |
|
|
84 | cf::register_command orcknuckle => sub { |
|
|
85 | my ($ob, $msg) = @_; |
|
|
86 | |
|
|
87 | my $pl = $ob->contr; |
|
|
88 | my $name = $ob->name; |
|
|
89 | |
|
|
90 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
|
|
91 | my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); |
|
|
92 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
|
|
93 | |
|
|
94 | send_msg $_, $cf::SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say" |
|
|
95 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
|
|
96 | |
|
|
97 | $pl->send_msg ($cf::SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); |
|
|
98 | }; |
|
|
99 | |
|
|
100 | my $emotes = { |
|
|
101 | growl => { |
|
|
102 | noparams => { |
|
|
103 | other => "<self> growls.", |
|
|
104 | self => "Grrrrrrrrr....", |
47 | } |
105 | }, |
48 | } else { |
106 | params => { |
49 | $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
107 | }, |
|
|
108 | self => { |
|
|
109 | }, |
50 | } |
110 | }, |
|
|
111 | giggle => { |
|
|
112 | noparams => { |
|
|
113 | other => "<self> giggles.", |
|
|
114 | self => "You giggle.", |
|
|
115 | }, |
|
|
116 | params => { |
|
|
117 | }, |
|
|
118 | self => { |
|
|
119 | }, |
|
|
120 | }, |
|
|
121 | shiver => { |
|
|
122 | noparams => { |
|
|
123 | other => "<self> shivers uncomfortably.", |
|
|
124 | self => "Brrrrrrrrr.", |
|
|
125 | }, |
|
|
126 | params => { |
|
|
127 | }, |
|
|
128 | self => { |
|
|
129 | }, |
|
|
130 | }, |
|
|
131 | chuckle => { |
|
|
132 | noparams => { |
|
|
133 | other => "<self> chuckles politely.", |
|
|
134 | self => "You chuckle politely", |
|
|
135 | }, |
|
|
136 | params => { |
|
|
137 | }, |
|
|
138 | self => { |
|
|
139 | }, |
|
|
140 | }, |
|
|
141 | sigh => { |
|
|
142 | noparams => { |
|
|
143 | other => "<self> sighs loudly.", |
|
|
144 | self => "You sigh.", |
|
|
145 | }, |
|
|
146 | params => { |
|
|
147 | }, |
|
|
148 | self => { |
|
|
149 | }, |
|
|
150 | }, |
|
|
151 | scream => { |
|
|
152 | noparams => { |
|
|
153 | other => "<self> screams at the top of his lungs!", |
|
|
154 | self => "ARRRRRRRRRRGH!!!!!", |
|
|
155 | }, |
|
|
156 | params => { |
|
|
157 | }, |
|
|
158 | self => { |
|
|
159 | }, |
|
|
160 | }, |
|
|
161 | puke => { |
|
|
162 | noparams => { |
|
|
163 | other => "<self> pukes.", |
|
|
164 | self => "Bleaaaaaghhhhhhh!", |
|
|
165 | }, |
|
|
166 | params => { |
|
|
167 | target => "<self> pukes on your clothes!", |
|
|
168 | other => "<self> pukes on <other>.", |
|
|
169 | self => "You puke on <other>.", |
|
|
170 | }, |
|
|
171 | self => { |
|
|
172 | other => "<self> pukes on his clothes.", |
|
|
173 | self => "You puke on yourself.", |
|
|
174 | }, |
|
|
175 | }, |
|
|
176 | strut => { |
|
|
177 | noparams => { |
|
|
178 | other => "<self> struts proudly.", |
|
|
179 | self => "Strut your stuff.", |
|
|
180 | }, |
|
|
181 | params => { |
|
|
182 | }, |
|
|
183 | self => { |
|
|
184 | }, |
|
|
185 | }, |
|
|
186 | cringe => { |
|
|
187 | noparams => { |
|
|
188 | other => "<self> cringes in terror!", |
|
|
189 | self => "You cringe in terror.", |
|
|
190 | }, |
|
|
191 | params => { |
|
|
192 | target => "<self> cringes away from <other> in mortal terror.", |
|
|
193 | self => "You cringe away from <other>.", |
|
|
194 | }, |
|
|
195 | self => { |
|
|
196 | }, |
|
|
197 | }, |
|
|
198 | hiccup => { |
|
|
199 | noparams => { |
|
|
200 | other => "<self> hiccups.", |
|
|
201 | self => "*HIC*", |
|
|
202 | }, |
|
|
203 | params => { |
|
|
204 | }, |
|
|
205 | self => { |
|
|
206 | }, |
|
|
207 | }, |
|
|
208 | clap => { |
|
|
209 | noparams => { |
|
|
210 | other => "<self> gives a round of applause.", |
|
|
211 | self => "Clap, clap, clap.", |
|
|
212 | }, |
|
|
213 | params => { |
|
|
214 | }, |
|
|
215 | self => { |
|
|
216 | }, |
|
|
217 | }, |
|
|
218 | kiss => { |
|
|
219 | noparams => { |
|
|
220 | other => "<self> makes a weird facial contortion", |
|
|
221 | self => "All the lonely people..", |
|
|
222 | }, |
|
|
223 | params => { |
|
|
224 | target => "<self> kisses you.", |
|
|
225 | other => "<self> kisses <other>.", |
|
|
226 | self => "You kiss <other>.", |
|
|
227 | }, |
|
|
228 | self => { |
|
|
229 | }, |
|
|
230 | }, |
|
|
231 | smother => { |
|
|
232 | noparams => { |
|
|
233 | other => "<self> makes weird facial contortions", |
|
|
234 | self => "All the lonely people..", |
|
|
235 | }, |
|
|
236 | params => { |
|
|
237 | target => "<self> smothers you with kisses.", |
|
|
238 | other => "<self> smothers <other> with kisses.", |
|
|
239 | self => "You smother <other> with kisses.", |
|
|
240 | }, |
|
|
241 | self => { |
|
|
242 | }, |
|
|
243 | }, |
|
|
244 | wink => { |
|
|
245 | noparams => { |
|
|
246 | other => "<self> winks suggestively.", |
|
|
247 | self => "Have you got something in your eye?", |
|
|
248 | }, |
|
|
249 | params => { |
|
|
250 | target => "<self> winks at you.", |
|
|
251 | other => "<self> winks at <other>.", |
|
|
252 | self => "You wink suggestively at <other>.", |
|
|
253 | }, |
|
|
254 | self => { |
|
|
255 | other => "<self> winks at himself - something strange is going on...", |
|
|
256 | self => "You wink at yourself?? What are you up to?", |
|
|
257 | }, |
|
|
258 | }, |
|
|
259 | pout => { |
|
|
260 | noparams => { |
|
|
261 | other => "<self> pouts.", |
|
|
262 | self => "Aww, don't take it so hard.", |
|
|
263 | }, |
|
|
264 | params => { |
|
|
265 | }, |
|
|
266 | self => { |
|
|
267 | }, |
|
|
268 | }, |
|
|
269 | cackle => { |
|
|
270 | noparams => { |
|
|
271 | other => "<self> throws back his head and cackles with insane glee!", |
|
|
272 | self => "You cackle gleefully.", |
|
|
273 | }, |
|
|
274 | params => { |
|
|
275 | }, |
|
|
276 | self => { |
|
|
277 | }, |
|
|
278 | }, |
|
|
279 | sniff => { |
|
|
280 | noparams => { |
|
|
281 | other => "<self> sniffs sadly.", |
|
|
282 | self => "You sniff sadly. *SNIFF*", |
|
|
283 | }, |
|
|
284 | params => { |
|
|
285 | target => "<self> sniffs you.", |
|
|
286 | other => "<self> sniffs <other>", |
|
|
287 | self => "You sniff <other>.", |
|
|
288 | }, |
|
|
289 | self => { |
|
|
290 | other => "<self> sniffs himself.", |
|
|
291 | self => "You sniff yourself.", |
|
|
292 | }, |
|
|
293 | }, |
|
|
294 | nod => { |
|
|
295 | noparams => { |
|
|
296 | other => "<self> nods solemnly.", |
|
|
297 | self => "You nod solemnly.", |
|
|
298 | }, |
|
|
299 | params => { |
|
|
300 | target => "<self> nods solemnly to you.", |
|
|
301 | other => "<self> nods solemnly to <other>.", |
|
|
302 | self => "You nod solemnly to <other>.", |
|
|
303 | }, |
|
|
304 | self => { |
|
|
305 | }, |
|
|
306 | }, |
|
|
307 | frown => { |
|
|
308 | noparams => { |
|
|
309 | other => "<self> frowns.", |
|
|
310 | self => "What's bothering you?", |
|
|
311 | }, |
|
|
312 | params => { |
|
|
313 | target => "<self> frowns darkly at you.", |
|
|
314 | other => "<self> frowns darkly at <other>.", |
|
|
315 | self => "You frown darkly at <other>.", |
|
|
316 | }, |
|
|
317 | self => { |
|
|
318 | other => "<self> frowns at himself.", |
|
|
319 | self => "You frown at yourself.", |
|
|
320 | }, |
|
|
321 | }, |
|
|
322 | snicker => { |
|
|
323 | noparams => { |
|
|
324 | other => "<self> snickers softly.", |
|
|
325 | self => "You snicker softly.", |
|
|
326 | }, |
|
|
327 | params => { |
|
|
328 | }, |
|
|
329 | self => { |
|
|
330 | }, |
|
|
331 | }, |
|
|
332 | shrug => { |
|
|
333 | noparams => { |
|
|
334 | other => "<self> shrugs helplessly.", |
|
|
335 | self => "You shrug.", |
|
|
336 | }, |
|
|
337 | params => { |
|
|
338 | target => "<self> shrugs at you.", |
|
|
339 | other => "<self> shrugs at <other>.", |
|
|
340 | self => "You shrug at <other>.", |
|
|
341 | }, |
|
|
342 | self => { |
|
|
343 | }, |
|
|
344 | }, |
|
|
345 | bleed => { |
|
|
346 | noparams => { |
|
|
347 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
|
|
348 | self => "You bleed all over your nice new armour.", |
|
|
349 | }, |
|
|
350 | params => { |
|
|
351 | target => "<self> slashes his wrist and bleeds all over you.", |
|
|
352 | other => "<self> slashes his wrist and bleeds all over <other>.", |
|
|
353 | self => "You slash your wrist and bleed all over <other>", |
|
|
354 | }, |
|
|
355 | self => { |
|
|
356 | other => "<self> performs some satanic ritual while wiping his blood on himself.", |
|
|
357 | self => "Very impressive! You wipe your blood all over yourself.", |
|
|
358 | }, |
|
|
359 | }, |
|
|
360 | twiddle => { |
|
|
361 | noparams => { |
|
|
362 | other => "<self> patiently twiddles his thumbs.", |
|
|
363 | self => "You patiently twiddle your thumbs.", |
|
|
364 | }, |
|
|
365 | params => { |
|
|
366 | }, |
|
|
367 | self => { |
|
|
368 | }, |
|
|
369 | }, |
|
|
370 | spit => { |
|
|
371 | noparams => { |
|
|
372 | other => "<self> spits over his left shoulder.", |
|
|
373 | self => "You spit over your left shoulder.", |
|
|
374 | }, |
|
|
375 | params => { |
|
|
376 | target => "<self> spits in your face!", |
|
|
377 | other => "<self> spits in <other>'s face.", |
|
|
378 | self => "You spit on <other>.", |
|
|
379 | }, |
|
|
380 | self => { |
|
|
381 | other => "<self> drools all over himself.", |
|
|
382 | self => "You drool all over yourself.", |
|
|
383 | }, |
|
|
384 | }, |
|
|
385 | glare => { |
|
|
386 | noparams => { |
|
|
387 | other => "<self> glares around him.", |
|
|
388 | self => "You glare at nothing in particular.", |
|
|
389 | }, |
|
|
390 | params => { |
|
|
391 | target => "<self> glares icily at you, you feel cold to your bones.", |
|
|
392 | other => "<self> glares at <other>.", |
|
|
393 | self => "You glare icily at <other>.", |
|
|
394 | }, |
|
|
395 | self => { |
|
|
396 | other => "<self> glares at his feet, what is bothering him?", |
|
|
397 | self => "You glare icily at your feet, they are suddenly very cold.", |
|
|
398 | }, |
|
|
399 | }, |
|
|
400 | bow => { |
|
|
401 | noparams => { |
|
|
402 | other => "<self> bows deeply.", |
|
|
403 | self => "You bow deeply.", |
|
|
404 | }, |
|
|
405 | params => { |
|
|
406 | target => "<self> bows before you.", |
|
|
407 | other => "<self> bows before <other>.", |
|
|
408 | self => "You bow before <other>.", |
|
|
409 | }, |
|
|
410 | self => { |
|
|
411 | other => "<self> folds up like a jackknife and kisses his own toes.", |
|
|
412 | self => "You kiss your toes.", |
|
|
413 | }, |
|
|
414 | }, |
|
|
415 | dance => { |
|
|
416 | noparams => { |
|
|
417 | other => "<self> expresses himself through interpretive dance.", |
|
|
418 | self => "You dance with glee.", |
|
|
419 | }, |
|
|
420 | params => { |
|
|
421 | target => "<self> grabs you, and begins dancing!", |
|
|
422 | other => "Yipe! <self> and <other> are doing the Macarena!", |
|
|
423 | self => "You grab <other> and begin doing the Cha-Cha!", |
|
|
424 | }, |
|
|
425 | self => { |
|
|
426 | other => "<self> embraces himself and begins to dance!", |
|
|
427 | self => "You skip and dance around by yourself.", |
|
|
428 | }, |
|
|
429 | }, |
|
|
430 | snore => { |
|
|
431 | noparams => { |
|
|
432 | other => "<self> snores loudly.", |
|
|
433 | self => "Zzzzzzzzzzzzzzz.", |
|
|
434 | }, |
|
|
435 | params => { |
|
|
436 | }, |
|
|
437 | self => { |
|
|
438 | }, |
|
|
439 | }, |
|
|
440 | blush => { |
|
|
441 | noparams => { |
|
|
442 | other => "<self> blushes.", |
|
|
443 | self => "Your cheeks are burning.", |
|
|
444 | }, |
|
|
445 | params => { |
|
|
446 | }, |
|
|
447 | self => { |
|
|
448 | }, |
|
|
449 | }, |
|
|
450 | snap => { |
|
|
451 | noparams => { |
|
|
452 | other => "<self> snaps his fingers.", |
|
|
453 | self => "PRONTO! you snap your fingers.", |
|
|
454 | }, |
|
|
455 | params => { |
|
|
456 | }, |
|
|
457 | self => { |
|
|
458 | }, |
|
|
459 | }, |
|
|
460 | wave => { |
|
|
461 | noparams => { |
|
|
462 | other => "<self> waves happily.", |
|
|
463 | self => "You wave.", |
|
|
464 | }, |
|
|
465 | params => { |
|
|
466 | target => "<self> waves goodbye to you. Have a good journey.", |
|
|
467 | other => "<self> waves goodbye to <other>.", |
|
|
468 | self => "You wave goodbye to <other>.", |
|
|
469 | }, |
|
|
470 | self => { |
|
|
471 | other => "<self> waves goodbye to himself.", |
|
|
472 | self => "Are you going on adventures as well??", |
|
|
473 | }, |
|
|
474 | }, |
|
|
475 | smile => { |
|
|
476 | noparams => { |
|
|
477 | other => "<self> smiles happily.", |
|
|
478 | self => "You smile happily.", |
|
|
479 | }, |
|
|
480 | params => { |
|
|
481 | target => "<self> smiles at you.", |
|
|
482 | other => "<self> beams a smile at <other>.", |
|
|
483 | self => "You smile at <other>.", |
|
|
484 | }, |
|
|
485 | self => { |
|
|
486 | }, |
|
|
487 | }, |
|
|
488 | sneeze => { |
|
|
489 | noparams => { |
|
|
490 | other => "<self> sneezes.", |
|
|
491 | self => "Gesundheit!", |
|
|
492 | }, |
|
|
493 | params => { |
|
|
494 | target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.", |
|
|
495 | other => "<self> sneezes on <other> and a film of snot covers him.", |
|
|
496 | self => "You sneeze at <other> and a film of snot shoots onto him.", |
|
|
497 | }, |
|
|
498 | self => { |
|
|
499 | other => "<self> sneezes, and covers himself in a slimy substance.", |
|
|
500 | self => "You sneeze on yourself, what a mess!", |
|
|
501 | }, |
|
|
502 | }, |
|
|
503 | bounce => { |
|
|
504 | noparams => { |
|
|
505 | other => "<self> bounces around.", |
|
|
506 | self => "BOIINNNNNNGG!", |
|
|
507 | }, |
|
|
508 | params => { |
|
|
509 | target => "<self> bounces around the room with you.", |
|
|
510 | other => "<self> bounces around the room with <other>.", |
|
|
511 | self => "You bounce around the room with <other>.", |
|
|
512 | }, |
|
|
513 | self => { |
|
|
514 | }, |
|
|
515 | }, |
|
|
516 | shake => { |
|
|
517 | noparams => { |
|
|
518 | other => "<self> shakes his head.", |
|
|
519 | self => "You shake your head.", |
|
|
520 | }, |
|
|
521 | params => { |
|
|
522 | target => "<self> shakes your hand.", |
|
|
523 | other => "<self> shakes <other>'s hand.", |
|
|
524 | self => "You shake <other>'s hand.", |
|
|
525 | }, |
|
|
526 | self => { |
|
|
527 | other => "<self> shakes and quivers like a bowlful of jelly.", |
|
|
528 | self => "You are shaken by yourself.", |
|
|
529 | }, |
|
|
530 | }, |
|
|
531 | lick => { |
|
|
532 | noparams => { |
|
|
533 | other => "<self> licks his mouth and smiles.", |
|
|
534 | self => "You lick your mouth and smile.", |
|
|
535 | }, |
|
|
536 | params => { |
|
|
537 | target => "<self> licks you.", |
|
|
538 | other => "<self> licks <other>.", |
|
|
539 | self => "You lick <other>.", |
|
|
540 | }, |
|
|
541 | self => { |
|
|
542 | other => "<self> licks himself - YUCK.", |
|
|
543 | self => "You lick yourself.", |
|
|
544 | }, |
|
|
545 | }, |
|
|
546 | flip => { |
|
|
547 | noparams => { |
|
|
548 | other => "<self> flips head over heels.", |
|
|
549 | self => "You flip head over heels.", |
|
|
550 | }, |
|
|
551 | params => { |
|
|
552 | }, |
|
|
553 | self => { |
|
|
554 | }, |
|
|
555 | }, |
|
|
556 | think => { |
|
|
557 | noparams => { |
|
|
558 | other => "<self> closes his eyes and thinks really hard.", |
|
|
559 | self => "Anything in particular that you'd care to think about?", |
|
|
560 | }, |
|
|
561 | params => { |
|
|
562 | }, |
|
|
563 | self => { |
|
|
564 | }, |
|
|
565 | }, |
|
|
566 | yawn => { |
|
|
567 | noparams => { |
|
|
568 | other => "<self> yawns sleepily.", |
|
|
569 | self => "You open up your yap and let out a big breeze of stale air.", |
|
|
570 | }, |
|
|
571 | params => { |
|
|
572 | }, |
|
|
573 | self => { |
|
|
574 | }, |
|
|
575 | }, |
|
|
576 | laugh => { |
|
|
577 | noparams => { |
|
|
578 | other => "<self> falls down laughing.", |
|
|
579 | self => "You fall down laughing.", |
|
|
580 | }, |
|
|
581 | params => { |
|
|
582 | target => "<self> looks at you and falls down on the ground laughing.", |
|
|
583 | other => "<self> looks at <other> and falls down on the ground laughing.", |
|
|
584 | self => "You take one look at <other> and fall down laughing.", |
|
|
585 | }, |
|
|
586 | self => { |
|
|
587 | other => "<self> is laughing at something.", |
|
|
588 | self => "Laugh at yourself all you want, the others won't understand.", |
|
|
589 | }, |
|
|
590 | }, |
|
|
591 | burp => { |
|
|
592 | noparams => { |
|
|
593 | other => "<self> burps loudly.", |
|
|
594 | self => "You burp loudly.", |
|
|
595 | }, |
|
|
596 | params => { |
|
|
597 | }, |
|
|
598 | self => { |
|
|
599 | }, |
|
|
600 | }, |
|
|
601 | gasp => { |
|
|
602 | noparams => { |
|
|
603 | other => "<self> gasps in astonishment.", |
|
|
604 | self => "You gasp in astonishment.", |
|
|
605 | }, |
|
|
606 | params => { |
|
|
607 | }, |
|
|
608 | self => { |
|
|
609 | }, |
|
|
610 | }, |
|
|
611 | smirk => { |
|
|
612 | noparams => { |
|
|
613 | other => "<self> smirks.", |
|
|
614 | self => "You smirk.", |
|
|
615 | }, |
|
|
616 | params => { |
|
|
617 | }, |
|
|
618 | self => { |
|
|
619 | }, |
|
|
620 | }, |
|
|
621 | cry => { |
|
|
622 | noparams => { |
|
|
623 | other => "<self> bursts into tears.", |
|
|
624 | self => "Waaaaaaahhh..", |
|
|
625 | }, |
|
|
626 | params => { |
|
|
627 | target => "<self> cries on your shoulder.", |
|
|
628 | other => "<self> cries on <other>'s shoulder.", |
|
|
629 | self => "You cry on <other>'s shoulder.", |
|
|
630 | }, |
|
|
631 | self => { |
|
|
632 | other => "<self> sobs quietly to himself.", |
|
|
633 | self => "You cry to yourself.", |
|
|
634 | }, |
|
|
635 | }, |
|
|
636 | sulk => { |
|
|
637 | noparams => { |
|
|
638 | other => "<self> sulks in the corner.", |
|
|
639 | self => "You sulk.", |
|
|
640 | }, |
|
|
641 | params => { |
|
|
642 | }, |
|
|
643 | self => { |
|
|
644 | }, |
|
|
645 | }, |
|
|
646 | whistle => { |
|
|
647 | noparams => { |
|
|
648 | other => "<self> whistles appreciatively.", |
|
|
649 | self => "You whistle appreciatively.", |
|
|
650 | }, |
|
|
651 | params => { |
|
|
652 | target => "<self> whistles at <other>.", |
|
|
653 | self => "You whistle at <other>.", |
|
|
654 | }, |
|
|
655 | self => { |
|
|
656 | other => "<self> whistles to himself in boredom.", |
|
|
657 | self => "You whistle while you work.", |
|
|
658 | }, |
|
|
659 | }, |
|
|
660 | groan => { |
|
|
661 | noparams => { |
|
|
662 | other => "<self> groans loudly.", |
|
|
663 | self => "You groan loudly.", |
|
|
664 | }, |
|
|
665 | params => { |
|
|
666 | }, |
|
|
667 | self => { |
|
|
668 | }, |
|
|
669 | }, |
|
|
670 | cough => { |
|
|
671 | noparams => { |
|
|
672 | other => "<self> coughs loudly.", |
|
|
673 | self => "Yuck, try to cover your mouth next time!", |
|
|
674 | }, |
|
|
675 | params => { |
|
|
676 | }, |
|
|
677 | self => { |
|
|
678 | }, |
|
|
679 | }, |
|
|
680 | grin => { |
|
|
681 | noparams => { |
|
|
682 | other => "<self> grins evilly.", |
|
|
683 | self => "You grin evilly.", |
|
|
684 | }, |
|
|
685 | params => { |
|
|
686 | target => "<self> grins evilly at you.", |
|
|
687 | other => "<self> grins evilly at <other>.", |
|
|
688 | self => "You grin at <other>.", |
|
|
689 | }, |
|
|
690 | self => { |
|
|
691 | }, |
|
|
692 | }, |
|
|
693 | }; |
|
|
694 | |
|
|
695 | for my $emotion (keys %$emotes) { |
|
|
696 | cf::register_command $emotion => sub { |
|
|
697 | my ($ob, $tname) = @_; |
|
|
698 | |
|
|
699 | my $pl = $ob->contr; |
|
|
700 | |
|
|
701 | cf::async { |
|
|
702 | my $name = $ob->name; |
|
|
703 | $Coro::current->{desc} = "emote handler for $name"; |
|
|
704 | |
|
|
705 | if ($tname eq $name) { |
|
|
706 | my %emote = %{ $emotes->{$emotion}->{self} || {} }; |
|
|
707 | |
|
|
708 | $emote{other} ||= "You look away from <self>."; |
|
|
709 | $emote{self} ||= "My god! Is that LEGAL?"; |
|
|
710 | |
|
|
711 | $emote{other} =~ s/<self>/$name/; |
|
|
712 | |
|
|
713 | send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
|
|
714 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; |
|
|
715 | |
|
|
716 | $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
|
|
717 | } elsif ($tname) { |
|
|
718 | my $target = cf::player::find $tname |
|
|
719 | or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat"; |
|
|
720 | |
|
|
721 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
|
|
722 | |
|
|
723 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
|
|
724 | $emote{self} ||= "You are still nuts."; |
|
|
725 | $emote{target} ||= "You get the distinct feeling that <self> is nuts."; |
|
|
726 | |
|
|
727 | $emote{self} =~ s/<other>/$tname/; |
|
|
728 | $emote{target} =~ s/<self>/$name/; |
|
|
729 | $emote{other} =~ s/<other>/$tname/; |
|
|
730 | $emote{other} =~ s/<self>/$name/; |
|
|
731 | |
|
|
732 | send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
|
|
733 | for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; |
|
|
734 | |
|
|
735 | send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY, "msg_shout"; |
|
|
736 | $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
|
|
737 | } else { |
|
|
738 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
|
|
739 | |
|
|
740 | $emote{other} ||= "<self> dances with glee."; |
|
|
741 | $emote{self} ||= "You are a nut."; |
|
|
742 | |
|
|
743 | $emote{other} =~ s/<self>/$name/; |
|
|
744 | |
|
|
745 | send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
|
|
746 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; |
|
|
747 | |
|
|
748 | $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
|
|
749 | } |
|
|
750 | }; |
|
|
751 | }; |
|
|
752 | } |
|
|
753 | |
|
|
754 | cf::register_command me => sub { |
|
|
755 | my ($pl, $msg) = @_; |
|
|
756 | |
|
|
757 | my $name = $pl->name; |
|
|
758 | |
|
|
759 | send_msg $_, $cf::SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" |
|
|
760 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
51 | }; |
761 | }; |
52 | |
762 | |
53 | cf::register_command say => sub { |
763 | cf::register_command say => sub { |
54 | my ($who, $msg) = @_; |
764 | my ($ob, $msg) = @_; |
55 | |
765 | |
56 | utf8::decode $msg; |
766 | utf8::decode $msg; |
57 | |
767 | |
58 | return if $who->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
768 | return if $ob->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
59 | |
769 | |
60 | if ($msg) { |
770 | if ($msg) { |
61 | my $name = $who->name; |
771 | my $name = $ob->name; |
62 | |
|
|
63 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
64 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
|
|
65 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
772 | my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; |
66 | utf8::decode $msg; |
773 | |
|
|
774 | send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" |
|
|
775 | for grep $_ != $ob->contr, @plonmap; |
|
|
776 | $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); |
67 | |
777 | |
68 | # npcs, magic_ears etc. |
778 | # npcs, magic_ears etc. |
69 | # first find all objects and theirt-level inventories |
779 | # first find all objects and their first-level inventories |
70 | # within a 5x5 square # that have something resembling |
780 | # within a 5x5 square that have something resembling |
71 | # dialogue or support on_say. |
781 | # dialogue or support on_say. |
72 | my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); |
782 | my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); |
73 | |
783 | |
74 | for my $npc ( |
784 | for my $npc ( |
75 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $who->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
785 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || $_->has_dialogue, |
76 | map +($_, $_->inv), |
786 | map +($_, $_->inv), |
77 | grep $_, |
787 | grep $_, |
78 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
788 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
79 | 0..24 |
789 | 0..24 |
80 | ) { |
790 | ) { |
81 | # if some listener teleported us somewhere else, stop right here |
791 | # if some listener teleported us somewhere else, stop right here |
82 | last unless $map->path == $who->map->path; |
792 | last unless $map->path == $ob->map->path; |
83 | |
793 | |
84 | my $dialog = new NPC_Dialogue ob => $who, npc => $npc; |
794 | my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; |
85 | my ($reply, @kw) = $dialog->tell ($msg); |
795 | my ($reply, @kw) = $dialog->tell ($msg); |
86 | |
796 | |
87 | if (defined $reply) { |
797 | if (defined $reply) { |
88 | if ($npc->type == cf::MAGIC_EAR) { |
798 | if ($npc->type == cf::MAGIC_EAR) { |
89 | if (length $reply) { |
799 | if (length $reply) { |
90 | $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) |
800 | send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" |
91 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
801 | for @plonmap; |
92 | } |
802 | } |
93 | $npc->use_trigger; |
803 | $npc->use_trigger; |
94 | } else { |
804 | } else { |
95 | if (length $reply) { |
805 | if (length $reply) { |
96 | $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) |
806 | send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" |
97 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
807 | for @plonmap; |
98 | } |
808 | } |
99 | } |
809 | } |
100 | } |
810 | } |
101 | |
811 | |
102 | if (@kw) { |
812 | if (@kw) { |
103 | $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) |
813 | $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
104 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
814 | for @plonmap; |
105 | } |
815 | } |
106 | } |
816 | } |
107 | |
817 | |
108 | } else { |
818 | } else { |
109 | $who->message ("What do you want to say?", cf::NDI_UNIQUE); |
819 | $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); |
110 | } |
820 | } |
111 | }; |
821 | }; |
112 | |
822 | |
113 | cf::register_command chat => sub { |
823 | cf::register_command chat => sub { |
114 | my ($who, $msg) = @_; |
824 | my ($ob, $msg) = @_; |
115 | |
825 | |
116 | utf8::decode $msg; |
826 | utf8::decode $msg; |
117 | |
827 | |
|
|
828 | my $pl = $ob->contr; |
|
|
829 | |
118 | return if $who->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
830 | return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
119 | |
831 | |
120 | if ($msg) { |
832 | if ($msg) { |
121 | my $name = $who->name; |
833 | my $name = $ob->name; |
122 | my $NOW = time; |
834 | my $NOW = time; |
123 | |
835 | |
124 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
125 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
836 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
126 | ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); |
837 | send_irc ("[%s] %s", $name, $msg); |
127 | |
838 | |
128 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
839 | send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" |
129 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
840 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
130 | |
841 | |
131 | } else { |
842 | } else { |
132 | $who->message ("Chat what?", cf::NDI_UNIQUE); |
843 | $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
133 | } |
844 | } |
134 | }; |
845 | }; |
135 | |
846 | |
136 | cf::register_command shout => sub { |
847 | cf::register_command shout => sub { |
137 | my ($who, $msg) = @_; |
848 | my ($ob, $msg) = @_; |
138 | |
849 | |
139 | utf8::decode $msg; |
850 | utf8::decode $msg; |
140 | |
851 | |
|
|
852 | my $pl = $ob->contr; |
|
|
853 | |
141 | return if $who->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); |
854 | return if $pl->invoke (cf::EVENT_PLAYER_SHOUT, $msg); |
142 | |
855 | |
143 | if ($msg) { |
856 | if ($msg) { |
144 | my $NOW = time; |
857 | my $NOW = time; |
145 | my $name = $who->name; |
858 | my $name = $ob->name; |
146 | |
859 | |
147 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
860 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
148 | ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); |
861 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
149 | |
862 | |
150 | utf8::encode $msg; # ->message not yet utf8-ified |
863 | send_msg $_, $cf::CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout" |
151 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
|
|
152 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
864 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
153 | |
865 | |
154 | } else { |
866 | } else { |
155 | $who->message ("Shout what?", cf::NDI_UNIQUE); |
867 | $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); |
156 | } |
868 | } |
157 | |
|
|
158 | }; |
869 | }; |
159 | |
870 | |
160 | cf::register_command tell => sub { |
871 | cf::register_command tell => sub { |
161 | my ($who, $args) = @_; |
872 | my ($ob, $args) = @_; |
162 | my ($target, $msg) = split /\s+/, $args, 2; |
873 | my ($target, $msg) = split /\s+/, $args, 2; |
163 | |
874 | |
164 | utf8::decode $msg; |
875 | utf8::decode $msg; |
165 | |
876 | |
166 | return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
877 | my $pl = $ob->contr; |
167 | |
878 | my $ns = $pl->ns |
|
|
879 | or return; |
168 | my $name = $who->name; |
880 | my $name = $ob->name; |
|
|
881 | |
|
|
882 | return if $pl->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
|
|
883 | |
|
|
884 | my $pl_channel = tell_channel $target; |
169 | |
885 | |
170 | if ($target =~ /irc\//) { |
886 | if ($target =~ /irc\//) { |
171 | my (undef, $nick) = split /\//, $target, 2; |
887 | my (undef, $nick) = split /\//, $target, 2; |
172 | $who->message ("You tell $target: $args"); |
888 | $ns->send_msg ($pl_channel => "You tell $target: $args", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
173 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); |
889 | send_irc ("(%s) %s: %s\n", $name, $nick, $msg); |
|
|
890 | |
174 | } elsif (my $other = cf::player::find_active $target) { |
891 | } elsif (my $other = cf::player::find_active $target) { |
|
|
892 | my $other_channel = tell_channel $name; |
175 | |
893 | |
176 | if ($msg) { |
894 | if ($msg) { |
177 | if ($target eq $name) { |
895 | if ($target eq $name) { |
178 | $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
896 | $ns->send_msg ($pl_channel => "You are talking to yourself, you freak!", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
179 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
897 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
180 | $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
898 | $ns->send_msg ($pl_channel => "$target ignores what you say. Give up on it.", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
181 | } else { |
899 | } else { |
182 | utf8::encode $msg; # ->message not yet utf8-ified |
900 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
183 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
901 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
184 | |
902 | |
185 | $who->message ("You tell $target: $msg"); |
903 | $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
186 | $other->ob->message ("$name tells you: $msg"); |
904 | send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell"; |
187 | $other->ob->{ext_last_tell} = $name; |
|
|
188 | } |
905 | } |
189 | } else { |
906 | } else { |
190 | $who->message ("What do you want to tell $target?", cf::NDI_UNIQUE); |
907 | $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
191 | } |
908 | } |
192 | |
909 | |
193 | } else { |
910 | } else { |
194 | $who->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); |
911 | $ns->send_msg ($pl_channel => "No such player. Your message: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
195 | } |
912 | } |
196 | }; |
913 | }; |
197 | |
914 | |
198 | cf::register_command reply => sub { |
915 | cf::register_command ignore => sub { |
199 | my ($who, $args) = @_; |
916 | my ($pl, $args) = @_; |
200 | my $name = $who->name; |
917 | my ($target, $type, $timeout) = split /\s+/, $args; |
201 | |
918 | |
202 | utf8::decode $args; |
919 | if ($args eq "list") { |
|
|
920 | clean_timeouts $pl; |
203 | |
921 | |
204 | return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $who->{ext_last_tell}, $args); |
922 | if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) |
|
|
923 | + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { |
|
|
924 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
|
|
925 | $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); |
|
|
926 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
|
|
927 | $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); |
|
|
928 | $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); |
|
|
929 | } else { |
|
|
930 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
|
|
931 | } |
205 | |
932 | |
206 | if ($who->{ext_last_tell} =~ /irc\//) { |
933 | } elsif ($target && $type) { |
207 | my (undef, $nick) = split /\//, $who->{ext_last_tell}, 2; |
|
|
208 | $who->message ("You tell " . $who->{ext_last_tell} . ": $args"); |
|
|
209 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); |
|
|
210 | } elsif (my $other = cf::player::find_active $who->{ext_last_tell}) { |
|
|
211 | |
934 | |
212 | if ($args) { |
935 | $timeout ne "" or $timeout = 24; |
213 | $other->ob->{ext_ignore_tell}{$name} >= time |
936 | my $absolute_timeout = time + $timeout * 3600; |
214 | or delete $other->ob->{ext_ignore_tell}{$name}; |
|
|
215 | |
937 | |
216 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
938 | if (cf::player::exists $target) { |
217 | utf8::encode $args; # ->message not yet utf8-ified |
939 | if ($type eq "tell") { |
218 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; |
940 | $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY); |
219 | |
941 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
220 | $who->message ("You tell " . $other->ob->name . ": $args"); |
942 | } elsif ($type eq "shout") { |
221 | $other->ob->message ("$name tells you: $args"); |
943 | $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY); |
222 | $who->{ext_last_tell} = $other->ob->name; |
944 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
945 | } elsif ($type eq "all") { |
|
|
946 | $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
947 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
948 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
223 | } else { |
949 | } else { |
224 | $who->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
950 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
225 | } |
951 | } |
226 | } else { |
952 | } else { |
227 | $who->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); |
953 | $pl->message ("No such player: $target", cf::NDI_REPLY); |
228 | } |
954 | } |
229 | |
955 | |
230 | } else { |
956 | } else { |
231 | $who->message ("Can't reply, player left. Your message: $args".$who->{ext_last_tell}, cf::NDI_UNIQUE); |
|
|
232 | } |
|
|
233 | }; |
|
|
234 | |
|
|
235 | cf::register_command ignore => sub { |
|
|
236 | my ($who, $args) = @_; |
|
|
237 | my ($target, $type, $timeout) = split /\s+/, $args; |
|
|
238 | |
|
|
239 | if ($args eq "list") { |
|
|
240 | clean_timeouts $who; |
|
|
241 | |
|
|
242 | if ((my @ignored_tell = sort keys %{$who->{ext_ignore_tell}}) |
|
|
243 | + (my @ignored_shout = sort keys %{$who->{ext_ignore_shout}})) { |
|
|
244 | $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); |
|
|
245 | $who->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE); |
|
|
246 | $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); |
|
|
247 | $who->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE); |
|
|
248 | $who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); |
|
|
249 | } else { |
|
|
250 | $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
|
|
251 | } |
|
|
252 | |
|
|
253 | } elsif ($target && $type) { |
|
|
254 | |
|
|
255 | $timeout ne "" or $timeout = 24; |
|
|
256 | my $absolute_timeout = time + $timeout * 3600; |
|
|
257 | |
|
|
258 | if (cf::player::exists $target) { |
|
|
259 | if ($type eq "tell") { |
|
|
260 | $who->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE); |
|
|
261 | $who->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
262 | } elsif ($type eq "shout") { |
|
|
263 | $who->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE); |
|
|
264 | $who->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
265 | } elsif ($type eq "all") { |
|
|
266 | $who->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE); |
|
|
267 | $who->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
268 | $who->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
269 | } else { |
|
|
270 | $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
|
|
271 | } |
|
|
272 | } else { |
|
|
273 | $who->message ("No such player: $target", cf::NDI_UNIQUE); |
|
|
274 | } |
|
|
275 | |
|
|
276 | } else { |
|
|
277 | $who->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
957 | $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
278 | . "will ignore a player for <timeout> hours.\n" |
958 | . "will ignore a player for <timeout> hours.\n" |
279 | . "Usage: ignore list\n" |
959 | . "Usage: ignore list\n" |
280 | . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); |
960 | . "will show you a list of players currently ignored.", cf::NDI_REPLY); |
281 | } |
961 | } |
282 | }; |
962 | }; |
283 | |
963 | |
284 | cf::register_command unignore => sub { |
964 | cf::register_command unignore => sub { |
285 | my ($who, $args) = @_; |
965 | my ($pl, $args) = @_; |
286 | my ($target, $type) = split /\s+/, $args; |
966 | my ($target, $type) = split /\s+/, $args; |
287 | |
967 | |
288 | if ($args eq "") { |
968 | if ($args eq "") { |
289 | if ($who->{ext_ignore_tell}) { |
969 | if ($pl->{ext_ignore_tell}) { |
290 | $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); |
970 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
291 | $who->message ((join ", ", sort keys %{ $who->{ext_ignore_tell} }), cf::NDI_UNIQUE); |
971 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); |
292 | $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); |
972 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
293 | $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE); |
973 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); |
294 | } else { |
974 | } else { |
295 | $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
975 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
296 | } |
976 | } |
297 | } else { |
977 | } else { |
298 | if (cf::player::exists $target) { |
978 | if (cf::player::exists $target) { |
299 | if ($type eq "tell") { |
979 | if ($type eq "tell") { |
300 | $who->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); |
980 | $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY); |
301 | delete $who->{ext_ignore_tell} {$target}; |
981 | delete $pl->{ext_ignore_tell} {$target}; |
302 | } elsif ($type eq "shout") { |
982 | } elsif ($type eq "shout") { |
303 | $who->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE); |
983 | $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY); |
304 | delete $who->{ext_ignore_shout}{$target}; |
984 | delete $pl->{ext_ignore_shout}{$target}; |
305 | } elsif ($type eq "all") { |
985 | } elsif ($type eq "all") { |
306 | $who->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE); |
986 | $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY); |
307 | delete $who->{ext_ignore_tell} {$target}; |
987 | delete $pl->{ext_ignore_tell} {$target}; |
308 | delete $who->{ext_ignore_shout}{$target}; |
988 | delete $pl->{ext_ignore_shout}{$target}; |
309 | } else { |
989 | } else { |
310 | $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
990 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
311 | } |
991 | } |
312 | } else { |
992 | } else { |
313 | $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
993 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); |
314 | } |
994 | } |
315 | } |
995 | } |
316 | }; |
996 | }; |
317 | |
997 | |
318 | cf::register_command seen => sub { |
|
|
319 | my ($who, $args) = @_; |
|
|
320 | |
|
|
321 | if (my ($login) = $args =~ /(\S+)/) { |
|
|
322 | if ($login eq $who->name) { |
|
|
323 | $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); |
|
|
324 | } elsif (cf::player::find_active $login) { |
|
|
325 | $who->message ("$login is right here on this server!", cf::NDI_UNIQUE); |
|
|
326 | } elsif (cf::player::exists $login |
|
|
327 | and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { |
|
|
328 | my $time = (stat _)[9]; |
|
|
329 | |
|
|
330 | $who->message ("$login was last seen here " |
|
|
331 | . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) |
|
|
332 | . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); |
|
|
333 | } else { |
|
|
334 | $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE); |
|
|
335 | } |
|
|
336 | } else { |
|
|
337 | $who->message ("Usage: seen <player>", cf::NDI_UNIQUE); |
|
|
338 | } |
|
|
339 | }; |
|
|
340 | |
|
|