static int m_cmessage(int p_or_n, const char *command, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *target_p; struct Channel *chptr; struct membership *msptr; if(!IsFloodDone(source_p)) flood_endgrace(source_p); if((target_p = find_named_person(parv[1])) == NULL) { if(p_or_n != NOTICE) sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), parv[1]); return 0; } if((chptr = find_channel(parv[2])) == NULL) { if(p_or_n != NOTICE) sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), parv[2]); return 0; } if((msptr = find_channel_membership(chptr, source_p)) == NULL) { if(p_or_n != NOTICE) sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), chptr->chname); return 0; } if(!is_chanop_voiced(msptr)) { if(p_or_n != NOTICE) sendto_one(source_p, form_str(ERR_VOICENEEDED), me.name, source_p->name, chptr->chname); return 0; } if(!IsMember(target_p, chptr)) { if(p_or_n != NOTICE) sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, form_str(ERR_USERNOTINCHANNEL), target_p->name, chptr->chname); return 0; } if(MyClient(target_p) && (IsSetCallerId(target_p) || (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])) && !accept_message(source_p, target_p) && !IsOper(source_p)) { if (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0]) { if (p_or_n != NOTICE) sendto_one_numeric(source_p, ERR_NONONREG, form_str(ERR_NONONREG), target_p->name); return 0; } if(p_or_n != NOTICE) sendto_one_numeric(source_p, ERR_TARGUMODEG, form_str(ERR_TARGUMODEG), target_p->name); if((target_p->localClient->last_caller_id_time + ConfigFileEntry.caller_id_wait) < rb_current_time()) { if(p_or_n != NOTICE) sendto_one_numeric(source_p, RPL_TARGNOTIFY, form_str(RPL_TARGNOTIFY), target_p->name); sendto_one(target_p, form_str(RPL_UMODEGMSG), me.name, target_p->name, source_p->name, source_p->username, source_p->host); target_p->localClient->last_caller_id_time = rb_current_time(); } return 0; } if(p_or_n != NOTICE) source_p->localClient->last = rb_current_time(); sendto_anywhere(target_p, source_p, command, ":%s", parv[3]); return 0; }
/* * msg_client * * inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC * say NOTICE must not auto reply * - pointer to command, "PRIVMSG" or "NOTICE" * - pointer to source_p source (struct Client *) * - pointer to target_p target (struct Client *) * - pointer to text * output - NONE * side effects - message given channel either chanop or voice */ static void msg_client(int p_or_n, char *command, struct Client *source_p, struct Client *target_p, char *text) { if (MyClient(source_p)) { /* reset idle time for message only if its not to self * and its not a notice */ if ((p_or_n != NOTICE) && (source_p != target_p) && source_p->user) source_p->user->last = CurrentTime; if (IsSetSSLaccept(target_p)) { #ifdef HAVE_LIBCRYPTO int fd = source_p->localClient->fd; fde_t *F = (fd > -1)? &fd_table[fd] : NULL; if (F && !F->ssl) { #endif sendto_one(source_p, form_str(source_p,ERR_SSLACCEPTONLY), me.name, source_p->name, target_p->name); return; #ifdef HAVE_LIBCRYPTO } #endif } } if (MyConnect(source_p) && (p_or_n != NOTICE) && target_p->user && target_p->user->away) sendto_one(source_p, form_str(source_p,RPL_AWAY), me.name, source_p->name, target_p->name, target_p->user->away); if (MyClient(target_p)) { if (IsSetRegAccept(target_p) && !(source_p->svsflags & FLAGS_SVS_IDENT)) { if (p_or_n != NOTICE) sendto_one(source_p, form_str(source_p,ERR_REGACCEPTONLY), me.name, source_p->name, target_p->name); return; } if (ConfigFileEntry.spam_wait && (p_or_n != NOTICE) && ((target_p->localClient->last_join_time + ConfigFileEntry.spam_wait > CurrentTime) || (target_p->localClient->last_leave_time + ConfigFileEntry.spam_wait > CurrentTime))) { sendto_anywhere(source_p, target_p, "NOTICE %s :*** I'm joining/leaving a chan, please try again in a few seconds.", source_p->name); return; } if (!IsServer(source_p) && IsSetCallerId(target_p)) { /* Here is the anti-flood bot/spambot code -db */ if (accept_message(source_p, target_p) || (source_p == target_p) || find_z_conf((char *)source_p->user->server)) { sendto_one(target_p, ":%s!%s@%s %s %s :%s", source_p->name, source_p->username, source_p->host, command, target_p->name, translate(target_p, text)); } else { /* check for accept, flag recipient incoming message */ if (p_or_n != NOTICE) sendto_anywhere(source_p, target_p, "NOTICE %s :*** I'm in +g mode (server side ignore).", source_p->name); if ((target_p->localClient->last_caller_id_time + ConfigFileEntry.caller_id_wait) < CurrentTime) { if (p_or_n != NOTICE) sendto_anywhere(source_p, target_p, "NOTICE %s :*** I've been informed you messaged me.", source_p->name); sendto_one(target_p, ":%s NOTICE %s :*** Client %s [%s@%s] is messaging you and you are +g", me.name, target_p->name, source_p->name, source_p->username, source_p->host); target_p->localClient->last_caller_id_time = CurrentTime; } /* Only so opers can watch for floods */ (void)flood_attack_client(p_or_n, source_p, target_p); } } else { /* If the client is remote, we dont perform a special check for * flooding.. as we wouldnt block their message anyway.. this means * we dont give warnings.. we then check if theyre opered * (to avoid flood warnings), lastly if theyre our client * and flooding -- fl */ if (!MyClient(source_p) || IsOper(source_p) || (MyClient(source_p) && !flood_attack_client(p_or_n, source_p, target_p))) sendto_anywhere(target_p, source_p, "%s %s :%s", command, target_p->name, translate(target_p, text)); } } else /* The target is a remote user.. same things apply -- fl */ if (!MyClient(source_p) || IsOper(source_p) || (MyClient(source_p) && !flood_attack_client(p_or_n, source_p, target_p))) sendto_anywhere(target_p, source_p, "%s %s :%s", command, target_p->name, text); return; }