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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines