/* msg_channel() * * inputs - flag privmsg or notice * - pointer to command "PRIVMSG" or "NOTICE" * - pointer to source_p * - pointer to channel * output - NONE * side effects - message given channel */ static void msg_channel(int p_or_n, const char *command, struct Client *source_p, struct Channel *chptr, const char *text) { int result = 0; /* Chanops and voiced can flood their own channel with impunity */ if ((result = can_send(chptr, source_p, NULL, text)) < 0) { if (result == CAN_SEND_OPV || !flood_attack_channel(p_or_n, source_p, chptr)) sendto_channel_butone(source_p, source_p, chptr, 0, "%s %s :%s", command, chptr->name, text); } else { if (p_or_n != NOTICE) { if (result == ERR_NOCTRLSONCHAN) sendto_one_numeric(source_p, &me, ERR_NOCTRLSONCHAN, chptr->name, text); else if (result == ERR_NEEDREGGEDNICK) sendto_one_numeric(source_p, &me, ERR_NEEDREGGEDNICK, chptr->name); else sendto_one_numeric(source_p, &me, ERR_CANNOTSENDTOCHAN, chptr->name); } } }
/* msg_channel_flags() * * inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC * say NOTICE must not auto reply * - pointer to source_p * - pointer to channel * - flags * - pointer to text to send * output - NONE * side effects - message given channel either chanop or voice */ static void msg_channel(int p_or_n, struct Client *source_p, struct Channel *chptr, unsigned int flags, const char *text) { unsigned int type = 0; const char *prefix = ""; if (flags & CHFL_VOICE) { type = CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE; prefix = "+"; } else if (flags & CHFL_HALFOP) { type = CHFL_CHANOP | CHFL_HALFOP; prefix = "%"; } else if (flags & CHFL_CHANOP) { type = CHFL_CHANOP; prefix = "@"; } /* Chanops and voiced can flood their own channel with impunity */ int ret = can_send(chptr, source_p, NULL, text, p_or_n == NOTICE); if (ret < 0) { if (ret == CAN_SEND_OPV || !flood_attack_channel(p_or_n, source_p, chptr)) sendto_channel_butone(source_p, source_p, chptr, type, "%s %s%s :%s", command[p_or_n], prefix, chptr->name, text); } else if (p_or_n != NOTICE) sendto_one_numeric(source_p, &me, ret, chptr->name, text); }
/* msg_channel_flags() * * 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 * - pointer to channel * - flags * - pointer to text to send * output - NONE * side effects - message given channel either chanop or voice */ static void msg_channel(int p_or_n, const char *command, struct Client *source_p, struct Channel *chptr, unsigned int flags, const char *text) { int result = 0; unsigned int type = 0; const char *prefix = ""; if (flags & CHFL_VOICE) { type = CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE; prefix = "+"; } else if (flags & CHFL_HALFOP) { type = CHFL_CHANOP | CHFL_HALFOP; prefix = "%"; } else if (flags & CHFL_CHANOP) { type = CHFL_CHANOP; prefix = "@"; } /* Chanops and voiced can flood their own channel with impunity */ if ((result = can_send(chptr, source_p, NULL, text)) < 0) { if (result == CAN_SEND_OPV || !flood_attack_channel(p_or_n, source_p, chptr)) sendto_channel_butone(source_p, source_p, chptr, type, "%s %s%s :%s", command, prefix, chptr->name, text); } else { if (p_or_n != NOTICE) { if (result == ERR_NOCTRLSONCHAN) sendto_one_numeric(source_p, &me, ERR_NOCTRLSONCHAN, chptr->name, text); else if (result == ERR_NOCTCP) sendto_one_numeric(source_p, &me, ERR_NOCTCP, chptr->name, text); else if (result == ERR_NEEDREGGEDNICK) sendto_one_numeric(source_p, &me, ERR_NEEDREGGEDNICK, chptr->name); else sendto_one_numeric(source_p, &me, ERR_CANNOTSENDTOCHAN, chptr->name); } } }
/* msg_channel() * * inputs - flag privmsg or notice * - pointer to command "PRIVMSG" or "NOTICE" * - pointer to client_p * - pointer to source_p * - pointer to channel * output - NONE * side effects - message given channel */ static void msg_channel(int p_or_n, const char *command, struct Client *client_p, struct Client *source_p, struct Channel *chptr, char *text) { int result; if(MyClient(source_p)) { /* idle time shouldnt be reset by notices --fl */ if(p_or_n != NOTICE) source_p->localClient->last = CurrentTime; } #ifndef STATIC_MODULES execute_callback(channel_message, source_p, chptr, text); #endif /* chanops and voiced can flood their own channel with impunity */ if((result = can_send(chptr, source_p, NULL, text, p_or_n)) > 0) { if(result == CAN_SEND_OPV || !flood_attack_channel(p_or_n, source_p, chptr, chptr->chname)) { sendto_channel_butone(client_p, source_p, chptr, command, ":%s", text); } } else { if(p_or_n != NOTICE) { if(result == CAN_SEND_NOREGNICK) sendto_one(source_p, form_str(ERR_NEEDREGGEDNICK), ID_or_name(&me, client_p), ID_or_name(source_p, client_p), chptr->chname, "speak in"); else if(result == CAN_SEND_NOCTRLS) sendto_one(source_p, form_str(ERR_NOCTRLSONCHAN), ID_or_name(&me, client_p), ID_or_name(source_p, client_p), chptr->chname, text); else if(result == CAN_SEND_NOCTCP) sendto_one(source_p, form_str(ERR_NOCTCP), ID_or_name(&me, client_p), ID_or_name(source_p, client_p), chptr->chname, "channel", text); else sendto_one(source_p, form_str(ERR_CANNOTSENDTOCHAN), ID_or_name(&me, client_p), ID_or_name(source_p, client_p), chptr->chname); } } }
static int m_displaymsg(struct Client *source_p, const char *channel, int underline, int action, const char *nick, const char *text) { struct Channel *chptr; struct membership *msptr; char nick2[NICKLEN+1]; char nick3[NICKLEN+1]; char text2[BUFSIZE]; if((chptr = find_channel(channel)) == NULL) { sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), channel); return 0; } if(!(msptr = find_channel_membership(chptr, source_p))) { sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), chptr->chname); return 0; } if(!(chptr->mode.mode & chmode_flags['N'])) { sendto_one_numeric(source_p, 573, "%s :Roleplay commands are not enabled on this channel.", chptr->chname); return 0; } if(!can_send(chptr, source_p, msptr)) { sendto_one_numeric(source_p, 573, "%s :Cannot send to channel.", chptr->chname); return 0; } /* enforce flood stuff on roleplay commands */ if(flood_attack_channel(0, source_p, chptr, chptr->chname)) return 0; /* enforce target change on roleplay commands */ if(!is_chanop_voiced(msptr) && !IsOper(source_p) && !add_channel_target(source_p, chptr)) { sendto_one(source_p, form_str(ERR_TARGCHANGE), me.name, source_p->name, chptr->chname); return 0; } rb_strlcpy(nick3, nick, sizeof(nick3)); if(underline) snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3)); else snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3)); /* don't allow nicks to be empty after stripping * this prevents nastiness like fake factions, etc. */ if(EmptyString(nick3)) { sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname); return 0; } if(action) snprintf(text2, sizeof(text2), "\1ACTION %s\1", text); else snprintf(text2, sizeof(text2), "%s", text); sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%[email protected] PRIVMSG %s :%s (%s)", nick2, source_p->name, channel, text2, source_p->name); sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s :%s", channel, nick2, text2); return 0; }
/* * msg_channel * * inputs - flag privmsg or notice * - pointer to command "PRIVMSG" or "NOTICE" * - pointer to client_p * - pointer to source_p * - pointer to channel * output - NONE * side effects - message given channel */ static void msg_channel(int p_or_n, char *command, struct Client *client_p, struct Client *source_p, struct Channel *chptr, char *text) { struct Channel *vchan = NULL; char *chname = NULL; int result; chname = RootChan(chptr)->chname; #ifdef VCHANS if (HasVchans(chptr)) vchan = map_vchan(chptr, source_p); #endif if (!vchan) vchan = chptr; if (MyClient(source_p)) { /* idle time shouldnt be reset by notices --fl */ if ((p_or_n != NOTICE) && source_p->user) source_p->user->last = CurrentTime; } /* chanops and voiced can flood their own channel with impunity */ if ((result = can_send(vchan, source_p))) { if (result == CAN_SEND_NOTREG) { if (p_or_n != NOTICE) sendto_one(source_p, form_str(source_p,ERR_CANNOTSENDNOTREG), me.name, source_p->name, chname); return; } if (result == CAN_SEND_OPV || !flood_attack_channel(p_or_n, source_p, vchan, chname)) { dlink_node *ptr; struct Ban *banptr; char strbuf[BUFSIZE+1], buf[TOPICLEN+1]; char *word, *subst, *p = buf; int drop = 0; if (MyClient(source_p) && IsPerson(source_p)) if (!is_chan_op(vchan, source_p) && NoRepeatChannel(vchan)) if (check_repeat(source_p, vchan, text)) { sendto_one(source_p, form_str(source_p,ERR_NOREPEATING), me.name, source_p->name, chname); return; } if (NoColorChannel(vchan)) /*strip_color(text);*/ text = strip_color(text, 0); strncpy(strbuf, text, BUFSIZE)[BUFSIZE] = 0; if (MyClient(source_p) && IsPerson(source_p)) if (!is_chan_op(vchan, source_p)) for (ptr = vchan->substlist.head; ptr; ptr = ptr->next, p = buf) { banptr = ptr->data; strncpy(buf, banptr->banstr, TOPICLEN)[TOPICLEN] = 0; while (*p) if (*p++ == '$') *(p-1) = ' '; subst = strchr(buf, '/'); if (subst) { *subst++ = 0; word = buf; if (strstr(strbuf, word) && !irccmp(subst, "&")) drop = 1; replace(strbuf, word, subst, BUFSIZE); strbuf[BUFSIZE] = 0; } } if (!drop) { if (PaceChannel(vchan) && (vchan->msgs < MAX_PACEMSG)) add_pace_msg(vchan, client_p, source_p, command, strbuf); else sendto_channel_butone(client_p, source_p, vchan, command, ":%s", strbuf); } } } else { if (p_or_n != NOTICE) sendto_one(source_p, form_str(source_p,ERR_CANNOTSENDTOCHAN), me.name, source_p->name, chname); } }