void server_relay_channel_message(struct Client* sptr, const char* name, const char* text) { struct Channel* chptr; assert(0 != sptr); assert(0 != name); assert(0 != text); if (0 == (chptr = FindChannel(name))) { /* * XXX - do we need to send this back from a remote server? */ send_reply(sptr, ERR_NOSUCHCHANNEL, name); return; } /* * This first: Almost never a server/service * Servers may have channel services, need to check for it here */ if (client_can_send_to_channel(sptr, chptr) || IsChannelService(sptr)) { sendcmdto_channel_butone(sptr, CMD_PRIVATE, chptr, cli_from(sptr), SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text); } else send_reply(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname); }
/* * m_wallvoices - local generic message handler */ int m_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Channel *chptr; assert(0 != cptr); assert(cptr == sptr); ClrFlag(sptr, FLAG_TS8); if (parc < 2 || EmptyString(parv[1])) return send_reply(sptr, ERR_NORECIPIENT, "WALLVOICES"); if (parc < 3 || EmptyString(parv[parc - 1])) return send_reply(sptr, ERR_NOTEXTTOSEND); if (IsChannelName(parv[1]) && (chptr = FindChannel(parv[1]))) { if (client_can_send_to_channel(sptr, chptr, 0)) { if ((chptr->mode.mode & MODE_NOPRIVMSGS) && check_target_limit(sptr, chptr, chptr->chname, 0)) return 0; RevealDelayedJoinIfNeeded(sptr, chptr); sendcmdto_channel_butone(sptr, CMD_WALLVOICES, chptr, cptr, SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, "%H :+ %s", chptr, parv[parc - 1]); } else send_reply(sptr, ERR_CANNOTSENDTOCHAN, parv[1]); } else send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]); return 0; }
/** Handle a local user's attempt to get or set a channel topic. * * \a parv has the following elements: * \li \a parv[1] is the channel name * \li \a parv[\a parc - 1] is the topic (if \a parc > 2) * * See @ref m_functions for discussion of the arguments. * @param[in] cptr Client that sent us the message. * @param[in] sptr Original source of message. * @param[in] parc Number of arguments. * @param[in] parv Argument vector. */ int m_topic(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Channel *chptr; char *topic = 0, *name, *p = 0; if (parc < 2) return need_more_params(sptr, "TOPIC"); if (parc > 2) topic = parv[parc - 1]; for (; (name = ircd_strtok(&p, parv[1], ",")); parv[1] = 0) { chptr = 0; /* Does the channel exist */ if (!IsChannelName(name) || !(chptr = FindChannel(name))) { send_reply(sptr,ERR_NOSUCHCHANNEL,name); continue; } /* Trying to check a topic outside a secret channel */ if ((topic || SecretChannel(chptr)) && !find_channel_member(sptr, chptr)) { send_reply(sptr, ERR_NOTONCHANNEL, chptr->chname); continue; } /* only asking for topic */ if (!topic) { if (chptr->topic[0] == '\0') send_reply(sptr, RPL_NOTOPIC, chptr->chname); else { send_reply(sptr, RPL_TOPIC, chptr->chname, chptr->topic); send_reply(sptr, RPL_TOPICWHOTIME, chptr->chname, chptr->topic_nick, chptr->topic_time); } } #if defined(DDB) || defined(SERVICES) else if ((chptr->mode.mode & MODE_TOPICLIMIT) && !(is_chan_owner(sptr, chptr) || is_chan_op(sptr, chptr))) #else else if ((chptr->mode.mode & MODE_TOPICLIMIT) && !is_chan_op(sptr, chptr)) #endif send_reply(sptr, ERR_CHANOPRIVSNEEDED, chptr->chname); else if (!client_can_send_to_channel(sptr, chptr, 1)) send_reply(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname); else do_settopic(sptr,cptr,chptr,topic,0); } return 0; }
/** Handle a WALLVOICES message from a local client. * * \a parv has the following elements: * \li \a parv[1] is the name of the channel to which to send * \li \a parv[\a parc - 1] is the message to send * * See @ref m_functions for discussion of the arguments. * @param[in] cptr Client that sent us the message. * @param[in] sptr Original source of message. * @param[in] parc Number of arguments. * @param[in] parv Argument vector. */ int m_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Channel *chptr; const char *ch; assert(0 != cptr); assert(cptr == sptr); if (parc < 2 || EmptyString(parv[1])) return send_reply(sptr, ERR_NORECIPIENT, "WALLVOICES"); if (parc < 3 || EmptyString(parv[parc - 1])) return send_reply(sptr, ERR_NOTEXTTOSEND); if (IsChannelName(parv[1]) && (chptr = FindChannel(parv[1]))) { if (client_can_send_to_channel(sptr, chptr, 0) && !(chptr->mode.mode & MODE_NONOTICE)) { if ((chptr->mode.mode & MODE_NOPRIVMSGS) && check_target_limit(sptr, chptr, chptr->chname, 0)) return 0; #if 0 /* +cC checks */ if (chptr->mode.mode & MODE_NOCOLOUR) for (ch=parv[parc - 1];*ch;ch++) if (*ch==2 || *ch==3 || *ch==22 || *ch==27 || *ch==31) { return 0; } if ((chptr->mode.mode & MODE_NOCTCP) && ircd_strncmp(parv[parc - 1],"\001ACTION ",8)) for (ch=parv[parc - 1];*ch;) if (*ch++==1) { return 0; } #endif RevealDelayedJoinIfNeeded(sptr, chptr); sendcmdto_channel(sptr, CMD_WALLVOICES, chptr, cptr, SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, "%H :+ %s", chptr, parv[parc - 1]); } else send_reply(sptr, ERR_CANNOTSENDTOCHAN, parv[1]); } else send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]); return 0; }
void server_relay_channel_notice(struct Client* sptr, const char* name, const char* text) { struct Channel* chptr; assert(0 != sptr); assert(0 != name); assert(0 != text); if (0 == (chptr = FindChannel(name))) return; /* * This first: Almost never a server/service * Servers may have channel services, need to check for it here */ if (client_can_send_to_channel(sptr, chptr) || IsChannelService(sptr)) { sendcmdto_channel_butone(sptr, CMD_NOTICE, chptr, cli_from(sptr), SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text); } }
/* * ms_wallvoices - server message handler */ int ms_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Channel *chptr; assert(0 != cptr); assert(0 != sptr); if (parc < 3 || !IsUser(sptr)) return 0; if (!IsLocalChannel(parv[1]) && (chptr = FindChannel(parv[1]))) { if (client_can_send_to_channel(sptr, chptr, 1)) { sendcmdto_channel_butone(sptr, CMD_WALLVOICES, chptr, cptr, SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, "%H :%s", chptr, parv[parc - 1]); } else send_reply(sptr, ERR_CANNOTSENDTOCHAN, parv[1]); } return 0; }
void relay_channel_notice(struct Client* sptr, const char* name, const char* text) { struct Channel* chptr; assert(0 != sptr); assert(0 != name); assert(0 != text); if (0 == (chptr = FindChannel(name))) return; /* * This first: Almost never a server/service */ if (!client_can_send_to_channel(sptr, chptr)) return; if ((chptr->mode.mode & MODE_NOPRIVMSGS) && check_target_limit(sptr, chptr, chptr->chname, 0)) return; sendcmdto_channel_butone(sptr, CMD_NOTICE, chptr, cli_from(sptr), SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text); }
void relay_channel_message(struct Client* sptr, const char* name, const char* text) { struct Channel* chptr; struct Membership *member; assert(0 != sptr); assert(0 != name); assert(0 != text); if (0 == (chptr = FindChannel(name))) { send_reply(sptr, ERR_NOSUCHCHANNEL, name); return; } /* * This first: Almost never a server/service */ if (!client_can_send_to_channel(sptr, chptr) && !(cli_flags(sptr) & FLAGS_CHSERV)) { send_reply(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname); return; } /* Los ctcps empiezan con el ASCII numero 1 */ if ((strlen(text) > 1) && (chptr->rhmode.mode & RHMODE_NOCTCP) && (text[0] == 1) && (strncasecmp(text+1, ACTION_STR, ACTION_STR_LEN))) { member = find_member_link(chptr, sptr); if (!member || (!es_representante(sptr) && !IsPreoper(sptr) && !IsVoicedOrOpped(member))) { send_reply(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname); return; } } if ((chptr->mode.mode & MODE_NOPRIVMSGS) && check_target_limit(sptr, chptr, chptr->chname, 0)) return; /* Parseo de los colores en el texto a un canal si tiene +c */ if (MyUser(sptr) && !es_representante(sptr)) { int flags = 0; char *texto_procesado; if (chptr->rhmode.mode & (RHMODE_NOCOLOR | RHMODE_BADWORDS)) member = find_member_link(chptr, sptr); if (chptr->rhmode.mode & RHMODE_NOCOLOR) { if (member && !IsVoicedOrOpped(member)) { int len = strlen(text); correct_colors((char *)text); if (len != strlen(text)) { send_reply(sptr, ERR_NOCOLORSCHAN, chptr->chname); } } } if (chptr->rhmode.mode & RHMODE_BADWORDS) { if (member) { if (!(member->status & (CHFL_CHANOP | CHFL_OWNER | CHFL_HALFOP))) flags = (BADWORDS_CHANNEL | BADWORDS_CHANPRIO); } else flags = (BADWORDS_CHANNEL | BADWORDS_CHANPRIO); } else flags = (BADWORDS_CHANPRIO); if ((texto_procesado = process_badwords(text, flags)) != NULL) { sendcmdto_channel_butone(sptr, CMD_PRIVATE, chptr, cli_from(sptr), SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, texto_procesado); return; } } sendcmdto_channel_butone(sptr, CMD_PRIVATE, chptr, cli_from(sptr), SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text); }