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.46 by root, Thu Dec 18 02:49:22 2008 UTC

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