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