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