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.21 by root, Fri Jul 20 16:11:10 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines