… | |
… | |
3 | * Rights to this code are documented in doc/pod/license.pod. |
3 | * Rights to this code are documented in doc/pod/license.pod. |
4 | * |
4 | * |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
6 | */ |
6 | */ |
7 | |
7 | |
8 | static char const rcsid[] = "$Id: ptasks.C,v 1.6 2007/08/30 19:56:26 pippijn Exp $"; |
8 | static char const rcsid[] = "$Id: ptasks.C,v 1.7 2007/09/04 11:13:26 pippijn Exp $"; |
9 | |
9 | |
10 | #include "atheme.h" |
10 | #include "atheme.h" |
11 | #include <account/myuser.h> |
11 | #include <account/myuser.h> |
12 | #include <account/mynick.h> |
12 | #include <account/mynick.h> |
13 | #include <account/kline.h> |
13 | #include <account/kline.h> |
… | |
… | |
376 | } |
376 | } |
377 | } |
377 | } |
378 | } |
378 | } |
379 | |
379 | |
380 | void |
380 | void |
|
|
381 | handle_channel_message (sourceinfo_t *si, char *target, bool is_notice, char *message) |
|
|
382 | { |
|
|
383 | char *vec[3]; |
|
|
384 | node_t *n; |
|
|
385 | |
|
|
386 | /* Call hook here */ |
|
|
387 | channel_t *c = channel_find (target); |
|
|
388 | /* No such channel, ignore... */ |
|
|
389 | if (c == NULL) |
|
|
390 | return; |
|
|
391 | c->callback.message (c, si->su, message); |
|
|
392 | |
|
|
393 | vec[0] = target; |
|
|
394 | vec[1] = message; |
|
|
395 | vec[2] = NULL; |
|
|
396 | |
|
|
397 | LIST_FOREACH (n, c->members.head) |
|
|
398 | { |
|
|
399 | chanuser_t *cu = static_cast<chanuser_t *> (n->data); |
|
|
400 | |
|
|
401 | if (!is_internal_client (cu->user)) |
|
|
402 | continue; |
|
|
403 | |
|
|
404 | si->service = find_service (cu->user->nick); |
|
|
405 | |
|
|
406 | if (si->service == NULL) |
|
|
407 | continue; |
|
|
408 | |
|
|
409 | if (is_notice) |
|
|
410 | si->service->notice_handler (si, 2, vec); |
|
|
411 | else |
|
|
412 | si->service->handler (si, 2, vec); |
|
|
413 | } |
|
|
414 | } |
|
|
415 | |
|
|
416 | void |
381 | handle_message (sourceinfo_t *si, char *target, bool is_notice, char *message) |
417 | handle_message (sourceinfo_t *si, char *target, bool is_notice, char *message) |
382 | { |
418 | { |
383 | char *vec[3]; |
419 | char *vec[3]; |
384 | |
420 | |
385 | /* message from server, ignore */ |
421 | /* message from server, ignore */ |
386 | if (si->su == NULL) |
422 | if (si->su == NULL) |
387 | return; |
423 | return; |
388 | |
424 | |
389 | /* If target is a channel and fantasy commands are enabled, |
425 | /* if this is a channel, handle it differently. */ |
390 | * this will return chanserv |
426 | if (*target == '#') |
391 | */ |
427 | { |
|
|
428 | handle_channel_message (si, target, is_notice, message); |
|
|
429 | return; |
|
|
430 | } |
|
|
431 | |
392 | si->service = find_service (target); |
432 | si->service = find_service (target); |
393 | |
|
|
394 | if (*target == '#') |
|
|
395 | { |
|
|
396 | /* Call hook here */ |
|
|
397 | channel_t *c = channel_find (target); |
|
|
398 | /* No such channel, ignore... */ |
|
|
399 | if (c == NULL) |
|
|
400 | return; |
|
|
401 | c->callback.message (c, si->su, message); |
|
|
402 | } |
|
|
403 | |
433 | |
404 | if (si->service == NULL) |
434 | if (si->service == NULL) |
405 | { |
435 | { |
406 | if (!is_notice && (isalnum (target[0]) || strchr ("[\\]^_`{|}~", target[0]))) |
436 | if (!is_notice && (isalnum (target[0]) || strchr ("[\\]^_`{|}~", target[0]))) |
407 | { |
437 | { |
… | |
… | |
416 | } |
446 | } |
417 | |
447 | |
418 | /* Run it through flood checks. Channel commands are checked |
448 | /* Run it through flood checks. Channel commands are checked |
419 | * separately. |
449 | * separately. |
420 | */ |
450 | */ |
421 | if (si->service->me != NULL && *target != '#' && floodcheck (si->su, si->service->me)) |
451 | if (si->service->me != NULL && floodcheck (si->su, si->service->me)) |
422 | return; |
452 | return; |
423 | |
453 | |
424 | if (!is_notice && config_options.secure && *target != '#' && irccasecmp (target, si->service->disp)) |
454 | if (!is_notice && config_options.secure && irccasecmp (target, si->service->disp)) |
425 | { |
455 | { |
426 | notice (si->service->me->nick, si->su->nick, "For security reasons, \2/msg %s\2 has been disabled." |
456 | notice (si->service->me->nick, si->su->nick, "For security reasons, \2/msg %s\2 has been disabled." |
427 | " Use \2/%s%s <command>\2 to send a command.", |
457 | " Use \2/%s%s <command>\2 to send a command.", |
428 | si->service->me->nick, |
458 | si->service->me->nick, |
429 | (ircd->uses_rcommand ? "" : "msg "), |
459 | ircd->uses_rcommand ? "" : "msg ", |
430 | si->service->disp); |
460 | si->service->disp); |
431 | return; |
461 | return; |
432 | } |
462 | } |
433 | |
463 | |
434 | vec[0] = target; |
464 | vec[0] = target; |