/************************************************************************ * IRC - Internet Relay Chat, modules/m_silence.c * * Copyright (C) 2000-2003 TR-IRCD Development * * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Co Center * * See file AUTHORS in IRC package for additional names of * the programmers. * * This program is free softwmare; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "struct.h" #include "common.h" #include "sys.h" #include "numeric.h" #include "msg.h" #include "channel.h" #include "h.h" static char *token = TOK1_SILENCE; static struct Message _msgtab[] = { {MSG_SILENCE, 0, MAXPARA, M_SLOW, 0L, m_unregistered, m_silence, m_silence, m_silence, m_ignore} }; #ifndef STATIC_MODULES char *_version = "$Revision: 1.3 $"; void _modinit(void) { mod_add_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = _msgtab; } void _moddeinit(void) { mod_del_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = NULL; } #else void m_silence_init(void) { mod_add_cmd(_msgtab); tok1_msgtab[(u_char) *token].msg = _msgtab; } #endif /* * m_silence * * parv[0] = sender prefix * * From local client: * * parv[1] = mask (NULL sends the list) * * From remote client: * * parv[1] = nick that must be silenced * * parv[2] = mask */ int m_silence(aClient *cptr, aClient *sptr, int parc, char *parv[]) { dlink_node *lp; aClient *acptr = NULL; char c, *cp; if (MyClient(sptr)) { acptr = sptr; if (parc < 2 || *parv[1] == '\0' || (acptr = find_person(parv[1]))) { if (!(acptr->user)) return 0; for (lp = acptr->user->silence.head; lp; lp = lp->next) { cp = lp->data; send_me_numeric(sptr, RPL_SILELIST, acptr->name, cp); } send_me_numeric(sptr, RPL_ENDOFSILELIST); return 0; } cp = parv[1]; c = *cp; if (c == '-' || c == '+') cp++; else if (!(strchr(cp, '@') || strchr(cp, '.') || strchr(cp, '!') || strchr(cp, '*'))) { send_me_numeric(sptr, ERR_NOSUCHNICK, parv[1]); return 0; } else c = '+'; cp = pretty_mask(cp); if ((c == '-' && !del_silence(sptr, cp)) || (c != '-' && !add_silence(sptr, cp))) { sendto_one(sptr, ":%C %s %c%s", sptr, MSG_SILENCE, c, cp); if (c == '-') sendto_serv_butone(NULL, sptr, TOK1_SILENCE, "* -%s", cp); } } else if (parc < 3 || *parv[2] == '\0') { send_me_numeric(sptr, ERR_NEEDMOREPARAMS, MSG_SILENCE); return -1; } else if ((c = *parv[2]) == '-' || (acptr = find_person(parv[1]))) { if (c == '-') { if (!del_silence(sptr, parv[2] + 1)) sendto_serv_butone(cptr, sptr, TOK1_SILENCE, "%s :%s", parv[1], parv[2]); } else { (void) add_silence(sptr, parv[2]); if (!MyClient(acptr)) sendto_one_server(acptr, sptr, TOK1_SILENCE, "%s :%s", parv[1], parv[2]); } } else { send_me_numeric(sptr, ERR_NOSUCHNICK, parv[1]); return 0; } return 0; }