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.33 by root, Wed Sep 19 21:56:30 2007 UTC

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