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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines