2 * ircd-ratbox: A slightly useful ircd.
3 * m_message.c: Sends a (PRIVMSG|NOTICE) message to a user or channel.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 * $Id: m_message.c 3173 2007-01-31 23:57:18Z jilles $
44 #include "s_newconf.h"
47 #include "inline/stringops.h"
49 static int m_message(int, const char *, struct Client
*, struct Client
*, int, const char **);
50 static int m_privmsg(struct Client
*, struct Client
*, int, const char **);
51 static int m_notice(struct Client
*, struct Client
*, int, const char **);
53 static void expire_tgchange(void *unused
);
54 static struct ev_entry
*expire_tgchange_event
;
59 expire_tgchange_event
= rb_event_addish("expire_tgchange", expire_tgchange
, NULL
, 300);
60 expire_tgchange(NULL
);
67 rb_event_delete(expire_tgchange_event
);
70 struct Message privmsg_msgtab
= {
71 "PRIVMSG", 0, 0, 0, MFLG_SLOW
| MFLG_UNREG
,
72 {mg_unreg
, {m_privmsg
, 0}, {m_privmsg
, 0}, mg_ignore
, mg_ignore
, {m_privmsg
, 0}}
74 struct Message notice_msgtab
= {
75 "NOTICE", 0, 0, 0, MFLG_SLOW
,
76 {mg_unreg
, {m_notice
, 0}, {m_notice
, 0}, {m_notice
, 0}, mg_ignore
, {m_notice
, 0}}
79 mapi_clist_av1 message_clist
[] = { &privmsg_msgtab
, ¬ice_msgtab
, NULL
};
81 DECLARE_MODULE_AV1(message
, modinit
, moddeinit
, message_clist
, NULL
, NULL
, "$Revision: 3173 $");
90 static int build_target_list(int p_or_n
, const char *command
,
91 struct Client
*client_p
,
92 struct Client
*source_p
, const char *nicks_channels
, const char *text
);
94 static int flood_attack_client(int p_or_n
, struct Client
*source_p
, struct Client
*target_p
);
96 /* Fifteen seconds should be plenty for a client to reply a ctcp */
97 #define LARGE_CTCP_TIME 15
100 #define ENTITY_CHANNEL 1
101 #define ENTITY_CHANNEL_OPMOD 2
102 #define ENTITY_CHANOPS_ON_CHANNEL 3
103 #define ENTITY_CLIENT 4
105 static struct entity targets
[512];
106 static int ntargets
= 0;
108 static int duplicate_ptr(void *);
110 static void msg_channel(int p_or_n
, const char *command
,
111 struct Client
*client_p
,
112 struct Client
*source_p
, struct Channel
*chptr
, const char *text
);
114 static void msg_channel_opmod(int p_or_n
, const char *command
,
115 struct Client
*client_p
,
116 struct Client
*source_p
, struct Channel
*chptr
,
119 static void msg_channel_flags(int p_or_n
, const char *command
,
120 struct Client
*client_p
,
121 struct Client
*source_p
,
122 struct Channel
*chptr
, int flags
, const char *text
);
124 static void msg_client(int p_or_n
, const char *command
,
125 struct Client
*source_p
, struct Client
*target_p
, const char *text
);
127 static void handle_special(int p_or_n
, const char *command
,
128 struct Client
*client_p
, struct Client
*source_p
, const char *nick
,
137 ** Another massive cleanup Nov, 2000
138 ** (I don't think there is a single line left from 6/91. Maybe.)
139 ** m_privmsg and m_notice do basically the same thing.
140 ** in the original 2.8.2 code base, they were the same function
141 ** "m_message.c." When we did the great cleanup in conjuncton with bleep
142 ** of ircu fame, we split m_privmsg.c and m_notice.c.
143 ** I don't see the point of that now. Its harder to maintain, its
144 ** easier to introduce bugs into one version and not the other etc.
145 ** Really, the penalty of an extra function call isn't that big a deal folks.
154 m_privmsg(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
156 return m_message(PRIVMSG
, "PRIVMSG", client_p
, source_p
, parc
, parv
);
160 m_notice(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
162 return m_message(NOTICE
, "NOTICE", client_p
, source_p
, parc
, parv
);
166 * inputs - flag privmsg or notice
167 * - pointer to command "PRIVMSG" or "NOTICE"
168 * - pointer to client_p
169 * - pointer to source_p
170 * - pointer to channel
173 m_message(int p_or_n
,
175 struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
179 if(parc
< 2 || EmptyString(parv
[1]))
182 sendto_one(source_p
, form_str(ERR_NORECIPIENT
), me
.name
,
183 source_p
->name
, command
);
187 if(parc
< 3 || EmptyString(parv
[2]))
190 sendto_one(source_p
, form_str(ERR_NOTEXTTOSEND
), me
.name
, source_p
->name
);
194 /* Finish the flood grace period if theyre not messaging themselves
195 * as some clients (ircN) do this as a "lag check"
197 if(MyClient(source_p
) && !IsFloodDone(source_p
) && irccmp(source_p
->name
, parv
[1]))
198 flood_endgrace(source_p
);
200 if(build_target_list(p_or_n
, command
, client_p
, source_p
, parv
[1], parv
[2]) < 0)
205 for(i
= 0; i
< ntargets
; i
++)
207 switch (targets
[i
].type
)
210 msg_channel(p_or_n
, command
, client_p
, source_p
,
211 (struct Channel
*) targets
[i
].ptr
, parv
[2]);
214 case ENTITY_CHANNEL_OPMOD
:
215 msg_channel_opmod(p_or_n
, command
, client_p
, source_p
,
216 (struct Channel
*) targets
[i
].ptr
, parv
[2]);
219 case ENTITY_CHANOPS_ON_CHANNEL
:
220 msg_channel_flags(p_or_n
, command
, client_p
, source_p
,
221 (struct Channel
*) targets
[i
].ptr
,
222 targets
[i
].flags
, parv
[2]);
226 msg_client(p_or_n
, command
, source_p
,
227 (struct Client
*) targets
[i
].ptr
, parv
[2]);
238 * inputs - pointer to given client_p (server)
239 * - pointer to given source (oper/client etc.)
240 * - pointer to list of nicks/channels
241 * - pointer to table to place results
242 * - pointer to text (only used if source_p is an oper)
243 * output - number of valid entities
244 * side effects - target_table is modified to contain a list of
245 * pointers to channels or clients
246 * if source client is an oper
247 * all the classic old bizzare oper privmsg tricks
248 * are parsed and sent as is, if prefixed with $
254 build_target_list(int p_or_n
, const char *command
, struct Client
*client_p
,
255 struct Client
*source_p
, const char *nicks_channels
, const char *text
)
258 char *p
, *nick
, *target_list
;
259 struct Channel
*chptr
= NULL
;
260 struct Client
*target_p
;
262 target_list
= LOCAL_COPY(nicks_channels
); /* skip strcpy for non-lazyleafs */
266 for(nick
= rb_strtok_r(target_list
, ",", &p
); nick
; nick
= rb_strtok_r(NULL
, ",", &p
))
270 * channels are privmsg'd a lot more than other clients, moved up
271 * here plain old channel msg?
274 if(IsChanPrefix(*nick
))
276 /* ignore send of local channel to a server (should not happen) */
277 if(IsServer(client_p
) && *nick
== '&')
280 if((chptr
= find_channel(nick
)) != NULL
)
282 if(!duplicate_ptr(chptr
))
284 if(ntargets
>= ConfigFileEntry
.max_targets
)
286 sendto_one(source_p
, form_str(ERR_TOOMANYTARGETS
),
287 me
.name
, source_p
->name
, nick
);
290 targets
[ntargets
].ptr
= (void *) chptr
;
291 targets
[ntargets
++].type
= ENTITY_CHANNEL
;
295 /* non existant channel */
296 else if(p_or_n
!= NOTICE
)
297 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
,
298 form_str(ERR_NOSUCHNICK
), nick
);
303 if(MyClient(source_p
))
304 target_p
= find_named_person(nick
);
306 target_p
= find_person(nick
);
308 /* look for a privmsg to another client */
311 if(!duplicate_ptr(target_p
))
313 if(ntargets
>= ConfigFileEntry
.max_targets
)
315 sendto_one(source_p
, form_str(ERR_TOOMANYTARGETS
),
316 me
.name
, source_p
->name
, nick
);
319 targets
[ntargets
].ptr
= (void *) target_p
;
320 targets
[ntargets
].type
= ENTITY_CLIENT
;
321 targets
[ntargets
++].flags
= 0;
326 /* @#channel or +#channel message ? */
330 /* allow %+@ if someone wants to do that */
335 else if(*nick
== '+')
336 type
|= CHFL_CHANOP
| CHFL_VOICE
;
345 if(EmptyString(nick
))
347 sendto_one(source_p
, form_str(ERR_NORECIPIENT
),
348 me
.name
, source_p
->name
, command
);
352 /* At this point, nick+1 should be a channel name i.e. #foo or &foo
353 * if the channel is found, fine, if not report an error
356 if((chptr
= find_channel(nick
)) != NULL
)
358 struct membership
*msptr
;
360 msptr
= find_channel_membership(chptr
, source_p
);
362 if(!IsServer(source_p
) && !IsService(source_p
) && !is_chanop_voiced(msptr
))
364 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
365 get_id(&me
, source_p
),
366 get_id(source_p
, source_p
),
371 if(!duplicate_ptr(chptr
))
373 if(ntargets
>= ConfigFileEntry
.max_targets
)
375 sendto_one(source_p
, form_str(ERR_TOOMANYTARGETS
),
376 me
.name
, source_p
->name
, nick
);
379 targets
[ntargets
].ptr
= (void *) chptr
;
380 targets
[ntargets
].type
= ENTITY_CHANOPS_ON_CHANNEL
;
381 targets
[ntargets
++].flags
= type
;
384 else if(p_or_n
!= NOTICE
)
386 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
,
387 form_str(ERR_NOSUCHNICK
), nick
);
393 if(IsServer(client_p
) && *nick
== '=' && nick
[1] == '#')
396 if((chptr
= find_channel(nick
)) != NULL
)
398 if(!duplicate_ptr(chptr
))
400 if(ntargets
>= ConfigFileEntry
.max_targets
)
402 sendto_one(source_p
, form_str(ERR_TOOMANYTARGETS
),
403 me
.name
, source_p
->name
, nick
);
406 targets
[ntargets
].ptr
= (void *) chptr
;
407 targets
[ntargets
++].type
= ENTITY_CHANNEL_OPMOD
;
411 /* non existant channel */
412 else if(p_or_n
!= NOTICE
)
413 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
,
414 form_str(ERR_NOSUCHNICK
), nick
);
419 if(strchr(nick
, '@') || (IsOper(source_p
) && (*nick
== '$')))
421 handle_special(p_or_n
, command
, client_p
, source_p
, nick
, text
);
425 /* no matching anything found - error if not NOTICE */
428 /* dont give this numeric when source is local,
429 * because its misleading --anfl
431 if(!MyClient(source_p
) && IsDigit(*nick
))
432 sendto_one(source_p
, ":%s %d %s * :Target left IRC. "
433 "Failed to deliver: [%.20s]",
434 get_id(&me
, source_p
), ERR_NOSUCHNICK
,
435 get_id(source_p
, source_p
), text
);
437 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
,
438 form_str(ERR_NOSUCHNICK
), nick
);
448 * inputs - pointer to check
449 * - pointer to table of entities
450 * - number of valid entities so far
451 * output - YES if duplicate pointer in table, NO if not.
452 * note, this does the canonize using pointers
453 * side effects - NONE
456 duplicate_ptr(void *ptr
)
459 for(i
= 0; i
< ntargets
; i
++)
460 if(targets
[i
].ptr
== ptr
)
468 * inputs - flag privmsg or notice
469 * - pointer to command "PRIVMSG" or "NOTICE"
470 * - pointer to client_p
471 * - pointer to source_p
472 * - pointer to channel
474 * side effects - message given channel
476 * XXX - We need to rework this a bit, it's a tad ugly. --nenolod
479 msg_channel(int p_or_n
, const char *command
,
480 struct Client
*client_p
, struct Client
*source_p
, struct Channel
*chptr
,
486 if(MyClient(source_p
))
488 /* idle time shouldnt be reset by notices --fl */
490 source_p
->localClient
->last
= rb_current_time();
493 if(chptr
->mode
.mode
& MODE_NOCOLOR
)
495 rb_strlcpy(text2
, text
, BUFSIZE
);
498 if (EmptyString(text
))
500 /* could be empty after colour stripping and
501 * that would cause problems later */
503 sendto_one(source_p
, form_str(ERR_NOTEXTTOSEND
), me
.name
, source_p
->name
);
508 /* chanops and voiced can flood their own channel with impunity */
509 if((result
= can_send(chptr
, source_p
, NULL
)))
511 if(result
!= CAN_SEND_OPV
&& MyClient(source_p
) &&
513 !add_channel_target(source_p
, chptr
))
515 sendto_one(source_p
, form_str(ERR_TARGCHANGE
),
516 me
.name
, source_p
->name
, chptr
->chname
);
519 if(result
== CAN_SEND_OPV
||
520 !flood_attack_channel(p_or_n
, source_p
, chptr
, chptr
->chname
))
522 if (p_or_n
!= NOTICE
&& *text
== '\001' &&
523 strncasecmp(text
+ 1, "ACTION ", 7))
525 if (chptr
->mode
.mode
& MODE_NOCTCP
)
527 sendto_one_numeric(source_p
, ERR_CANNOTSENDTOCHAN
,
528 form_str(ERR_CANNOTSENDTOCHAN
), chptr
->chname
);
531 else if (rb_dlink_list_length(&chptr
->locmembers
) > (unsigned)(GlobalSetOptions
.floodcount
/ 2))
532 source_p
->large_ctcp_sent
= rb_current_time();
534 sendto_channel_flags(client_p
, ALL_MEMBERS
, source_p
, chptr
,
535 "%s %s :%s", command
, chptr
->chname
, text
);
538 else if(chptr
->mode
.mode
& MODE_OPMODERATE
&&
539 (!(chptr
->mode
.mode
& MODE_NOPRIVMSGS
) ||
540 IsMember(source_p
, chptr
)))
542 if(MyClient(source_p
) && !IsOper(source_p
) &&
543 !add_channel_target(source_p
, chptr
))
545 sendto_one(source_p
, form_str(ERR_TARGCHANGE
),
546 me
.name
, source_p
->name
, chptr
->chname
);
549 if(!flood_attack_channel(p_or_n
, source_p
, chptr
, chptr
->chname
))
551 sendto_channel_opmod(client_p
, source_p
, chptr
,
558 sendto_one_numeric(source_p
, ERR_CANNOTSENDTOCHAN
,
559 form_str(ERR_CANNOTSENDTOCHAN
), chptr
->chname
);
565 * inputs - flag privmsg or notice
566 * - pointer to command "PRIVMSG" or "NOTICE"
567 * - pointer to client_p
568 * - pointer to source_p
569 * - pointer to channel
571 * side effects - message given channel ops
573 * XXX - We need to rework this a bit, it's a tad ugly. --nenolod
576 msg_channel_opmod(int p_or_n
, const char *command
,
577 struct Client
*client_p
, struct Client
*source_p
,
578 struct Channel
*chptr
, const char *text
)
582 if(chptr
->mode
.mode
& MODE_NOCOLOR
)
584 rb_strlcpy(text2
, text
, BUFSIZE
);
587 if (EmptyString(text
))
589 /* could be empty after colour stripping and
590 * that would cause problems later */
592 sendto_one(source_p
, form_str(ERR_NOTEXTTOSEND
), me
.name
, source_p
->name
);
597 if(chptr
->mode
.mode
& MODE_OPMODERATE
&&
598 (!(chptr
->mode
.mode
& MODE_NOPRIVMSGS
) ||
599 IsMember(source_p
, chptr
)))
601 if(!flood_attack_channel(p_or_n
, source_p
, chptr
, chptr
->chname
))
603 sendto_channel_opmod(client_p
, source_p
, chptr
,
610 sendto_one_numeric(source_p
, ERR_CANNOTSENDTOCHAN
,
611 form_str(ERR_CANNOTSENDTOCHAN
), chptr
->chname
);
618 * inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
619 * say NOTICE must not auto reply
620 * - pointer to command, "PRIVMSG" or "NOTICE"
621 * - pointer to client_p
622 * - pointer to source_p
623 * - pointer to channel
625 * - pointer to text to send
627 * side effects - message given channel either chanop or voice
630 msg_channel_flags(int p_or_n
, const char *command
, struct Client
*client_p
,
631 struct Client
*source_p
, struct Channel
*chptr
, int flags
, const char *text
)
636 if(flags
& CHFL_VOICE
)
638 type
= ONLY_CHANOPSVOICED
;
647 if(MyClient(source_p
))
649 /* idletime shouldnt be reset by notice --fl */
651 source_p
->localClient
->last
= rb_current_time();
654 sendto_channel_flags(client_p
, type
, source_p
, chptr
, "%s %c%s :%s",
655 command
, c
, chptr
->chname
, text
);
659 expire_tgchange(void *unused
)
662 rb_dlink_node
*ptr
, *next_ptr
;
664 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, tgchange_list
.head
)
668 if(target
->expiry
< rb_current_time())
670 rb_dlinkDelete(ptr
, &tgchange_list
);
671 rb_patricia_remove(tgchange_tree
, target
->pnode
);
681 * inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
682 * say NOTICE must not auto reply
683 * - pointer to command, "PRIVMSG" or "NOTICE"
684 * - pointer to source_p source (struct Client *)
685 * - pointer to target_p target (struct Client *)
688 * side effects - message given channel either chanop or voice
691 msg_client(int p_or_n
, const char *command
,
692 struct Client
*source_p
, struct Client
*target_p
, const char *text
)
694 int do_floodcount
= 0;
696 if(MyClient(source_p
))
699 * XXX: Controversial? Allow target users to send replies
700 * through a +g. Rationale is that people can presently use +g
701 * as a way to taunt users, e.g. harass them and hide behind +g
702 * as a way of griefing. --nenolod
704 if(p_or_n
!= NOTICE
&& IsSetCallerId(source_p
) &&
705 !accept_message(target_p
, source_p
) &&
708 if(rb_dlink_list_length(&source_p
->localClient
->allow_list
) <
709 ConfigFileEntry
.max_accept
)
711 rb_dlinkAddAlloc(target_p
, &source_p
->localClient
->allow_list
);
712 rb_dlinkAddAlloc(source_p
, &target_p
->on_allow_list
);
716 sendto_one_numeric(source_p
, ERR_OWNMODE
,
717 form_str(ERR_OWNMODE
),
718 target_p
->name
, "+g");
723 /* reset idle time for message only if its not to self
724 * and its not a notice */
726 source_p
->localClient
->last
= rb_current_time();
728 /* auto cprivmsg/cnotice */
729 do_floodcount
= !IsOper(source_p
) &&
730 !find_allowing_channel(source_p
, target_p
);
732 /* target change stuff, dont limit ctcp replies as that
733 * would allow people to start filling up random users
734 * targets just by ctcping them
736 if((p_or_n
!= NOTICE
|| *text
!= '\001') &&
737 ConfigFileEntry
.target_change
&& do_floodcount
)
739 if(!add_target(source_p
, target_p
))
741 sendto_one(source_p
, form_str(ERR_TARGCHANGE
),
742 me
.name
, source_p
->name
, target_p
->name
);
747 if (do_floodcount
&& p_or_n
== NOTICE
&& *text
== '\001' &&
748 target_p
->large_ctcp_sent
+ LARGE_CTCP_TIME
>= rb_current_time())
752 flood_attack_client(p_or_n
, source_p
, target_p
))
755 else if(source_p
->from
== target_p
->from
)
757 sendto_realops_snomask(SNO_DEBUG
, L_ALL
,
758 "Send message to %s[%s] dropped from %s(Fake Dir)",
759 target_p
->name
, target_p
->from
->name
, source_p
->name
);
763 if(MyConnect(source_p
) && (p_or_n
!= NOTICE
) && target_p
->user
&& target_p
->user
->away
)
764 sendto_one_numeric(source_p
, RPL_AWAY
, form_str(RPL_AWAY
),
765 target_p
->name
, target_p
->user
->away
);
767 if(MyClient(target_p
))
769 /* XXX Controversial? allow opers always to send through a +g */
770 if(!IsServer(source_p
) && (IsSetCallerId(target_p
) ||
771 (IsSetRegOnlyMsg(target_p
) && !source_p
->user
->suser
[0])))
773 /* Here is the anti-flood bot/spambot code -db */
774 if(accept_message(source_p
, target_p
) || IsOper(source_p
))
776 add_reply_target(target_p
, source_p
);
777 sendto_one(target_p
, ":%s!%s@%s %s %s :%s",
780 source_p
->host
, command
, target_p
->name
, text
);
782 else if (IsSetRegOnlyMsg(target_p
) && !source_p
->user
->suser
[0])
784 if (p_or_n
!= NOTICE
)
785 sendto_one_numeric(source_p
, ERR_NONONREG
,
786 form_str(ERR_NONONREG
),
791 /* check for accept, flag recipient incoming message */
794 sendto_one_numeric(source_p
, ERR_TARGUMODEG
,
795 form_str(ERR_TARGUMODEG
),
799 if((target_p
->localClient
->last_caller_id_time
+
800 ConfigFileEntry
.caller_id_wait
) < rb_current_time())
803 sendto_one_numeric(source_p
, RPL_TARGNOTIFY
,
804 form_str(RPL_TARGNOTIFY
),
807 add_reply_target(target_p
, source_p
);
808 sendto_one(target_p
, form_str(RPL_UMODEGMSG
),
809 me
.name
, target_p
->name
, source_p
->name
,
810 source_p
->username
, source_p
->host
);
812 target_p
->localClient
->last_caller_id_time
= rb_current_time();
818 add_reply_target(target_p
, source_p
);
819 sendto_anywhere(target_p
, source_p
, command
, ":%s", text
);
823 sendto_anywhere(target_p
, source_p
, command
, ":%s", text
);
829 * flood_attack_client
830 * inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
831 * say NOTICE must not auto reply
832 * - pointer to source Client
833 * - pointer to target Client
834 * output - 1 if target is under flood attack
835 * side effects - check for flood attack on target target_p
838 flood_attack_client(int p_or_n
, struct Client
*source_p
, struct Client
*target_p
)
842 /* Services could get many messages legitimately and
843 * can be messaged without rate limiting via aliases
844 * and msg user@server.
847 if(GlobalSetOptions
.floodcount
&& IsClient(source_p
) && source_p
!= target_p
&& !IsService(target_p
))
849 if((target_p
->first_received_message_time
+ 1) < rb_current_time())
851 delta
= rb_current_time() - target_p
->first_received_message_time
;
852 target_p
->received_number_of_privmsgs
-= delta
;
853 target_p
->first_received_message_time
= rb_current_time();
854 if(target_p
->received_number_of_privmsgs
<= 0)
856 target_p
->received_number_of_privmsgs
= 0;
857 target_p
->flood_noticed
= 0;
861 if((target_p
->received_number_of_privmsgs
>=
862 GlobalSetOptions
.floodcount
) || target_p
->flood_noticed
)
864 if(target_p
->flood_noticed
== 0)
866 sendto_realops_snomask(SNO_BOTS
, L_NETWIDE
,
867 "Possible Flooder %s[%s@%s] on %s target: %s",
868 source_p
->name
, source_p
->username
,
870 source_p
->servptr
->name
, target_p
->name
);
871 target_p
->flood_noticed
= 1;
872 /* add a bit of penalty */
873 target_p
->received_number_of_privmsgs
+= 2;
875 if(MyClient(source_p
) && (p_or_n
!= NOTICE
))
877 ":%s NOTICE %s :*** Message to %s throttled due to flooding",
878 me
.name
, source_p
->name
, target_p
->name
);
882 target_p
->received_number_of_privmsgs
++;
891 * inputs - server pointer
893 * - nick stuff to grok for opers
894 * - text to send if grok
896 * side effects - all the traditional oper type messages are parsed here.
897 * i.e. "/msg #some.host."
898 * However, syntax has been changed.
899 * previous syntax "/msg #some.host.mask"
900 * now becomes "/msg $#some.host.mask"
901 * previous syntax of: "/msg $some.server.mask" remains
902 * This disambiguates the syntax.
905 handle_special(int p_or_n
, const char *command
, struct Client
*client_p
,
906 struct Client
*source_p
, const char *nick
, const char *text
)
908 struct Client
*target_p
;
912 /* user[%host]@server addressed?
913 * NOTE: users can send to user@server, but not user%host@server
916 if((server
= strchr(nick
, '@')) != NULL
)
918 if((target_p
= find_server(source_p
, server
+ 1)) == NULL
)
920 sendto_one_numeric(source_p
, ERR_NOSUCHSERVER
,
921 form_str(ERR_NOSUCHSERVER
), server
+ 1);
925 if(!IsOper(source_p
))
927 if(strchr(nick
, '%') || (strncmp(nick
, "opers", 5) == 0))
929 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
,
930 form_str(ERR_NOSUCHNICK
), nick
);
935 /* somewhere else.. */
938 sendto_one(target_p
, ":%s %s %s :%s",
939 get_id(source_p
, target_p
), command
, nick
, text
);
943 /* Check if someones msg'ing opers@our.server */
944 if(strncmp(nick
, "opers@", 6) == 0)
946 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "To opers: From: %s: %s",
947 source_p
->name
, text
);
951 /* This was not very useful except for bypassing certain
952 * restrictions. Note that we still allow sending to
953 * remote servers this way, for messaging pseudoservers
954 * securely whether they have a service{} block or not.
957 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
,
958 form_str(ERR_NOSUCHNICK
), nick
);
963 * the following two cases allow masks in NOTICEs
966 * Armin, 8Jun90 (gruner@informatik.tu-muenchen.de)
968 if(IsOper(source_p
) && *nick
== '$')
970 if((*(nick
+ 1) == '$' || *(nick
+ 1) == '#'))
972 else if(MyOper(source_p
))
975 ":%s NOTICE %s :The command %s %s is no longer supported, please use $%s",
976 me
.name
, source_p
->name
, command
, nick
, nick
);
980 if(MyClient(source_p
) && !IsOperMassNotice(source_p
))
982 sendto_one(source_p
, form_str(ERR_NOPRIVS
),
983 me
.name
, source_p
->name
, "mass_notice");
987 if((s
= strrchr(nick
, '.')) == NULL
)
989 sendto_one_numeric(source_p
, ERR_NOTOPLEVEL
,
990 form_str(ERR_NOTOPLEVEL
), nick
);
994 if(*s
== '.' || *s
== '*' || *s
== '?')
996 if(*s
== '*' || *s
== '?')
998 sendto_one_numeric(source_p
, ERR_WILDTOPLEVEL
,
999 form_str(ERR_WILDTOPLEVEL
), nick
);
1003 sendto_match_butone(IsServer(client_p
) ? client_p
: NULL
, source_p
,
1005 (*nick
== '#') ? MATCH_HOST
: MATCH_SERVER
,
1006 "%s $%s :%s", command
, nick
, text
);
1007 if (p_or_n
!= NOTICE
&& *text
== '\001')
1008 source_p
->large_ctcp_sent
= rb_current_time();