ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/chat.ext
(Generate patch)

Comparing deliantra/server/ext/chat.ext (file contents):
Revision 1.6 by pippijn, Wed Feb 28 19:25:27 2007 UTC vs.
Revision 1.51 by root, Sun Jul 19 18:15:07 2009 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines