unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

sendsno.c (2482B)

      1 /*
      2  *   Unreal Internet Relay Chat Daemon, src/modules/sendsno.c
      3  *   (C) 2000-2001 Carsten V. Munk and the UnrealIRCd Team
      4  *   Moved to modules by Fish (Justin Hammond)
      5  *
      6  *   This program is free software; you can redistribute it and/or modify
      7  *   it under the terms of the GNU General Public License as published by
      8  *   the Free Software Foundation; either version 1, or (at your option)
      9  *   any later version.
     10  *
     11  *   This program is distributed in the hope that it will be useful,
     12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14  *   GNU General Public License for more details.
     15  *
     16  *   You should have received a copy of the GNU General Public License
     17  *   along with this program; if not, write to the Free Software
     18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     19  */
     20 
     21 #include "unrealircd.h"
     22 
     23 CMD_FUNC(cmd_sendsno);
     24 
     25 #define MSG_SENDSNO   "SENDSNO"
     26 
     27 ModuleHeader MOD_HEADER
     28   = {
     29 	"sendsno",	/* Name of module */
     30 	"5.0", /* Version */
     31 	"command /sendsno", /* Short description of module */
     32 	"UnrealIRCd Team",
     33 	"unrealircd-6",
     34     };
     35 
     36 /* This is called on module init, before Server Ready */
     37 MOD_INIT()
     38 {
     39 	CommandAdd(modinfo->handle, MSG_SENDSNO, cmd_sendsno, MAXPARA, CMD_SERVER);
     40 	MARK_AS_OFFICIAL_MODULE(modinfo);
     41 	return MOD_SUCCESS;
     42 }
     43 
     44 /* Is first run when server is 100% ready */
     45 MOD_LOAD()
     46 {
     47 	return MOD_SUCCESS;
     48 }
     49 
     50 /* Called when module is unloaded */
     51 MOD_UNLOAD()
     52 {
     53 	return MOD_SUCCESS;
     54 }
     55 
     56 /*
     57 ** cmd_sendsno - Written by Syzop, bit based on SENDUMODE from Stskeeps
     58 **      parv[1] = target snomask
     59 **      parv[2] = message text
     60 ** Servers can use this to:
     61 **   :server.unreal.net SENDSNO e :Hiiiii
     62 */
     63 CMD_FUNC(cmd_sendsno)
     64 {
     65 	MessageTag *mtags = NULL;
     66 	const char *sno, *msg, *p;
     67 	Client *acptr;
     68 
     69 	if ((parc < 3) || BadPtr(parv[2]))
     70 	{
     71 		sendnumeric(client, ERR_NEEDMOREPARAMS, "SENDSNO");
     72 		return;
     73 	}
     74 	sno = parv[1];
     75 	msg = parv[2];
     76 
     77 	new_message(client, recv_mtags, &mtags);
     78 
     79 	/* Forward to others... */
     80 	sendto_server(client, 0, 0, mtags, ":%s SENDSNO %s :%s", client->id, parv[1], parv[2]);
     81 
     82 	list_for_each_entry(acptr, &oper_list, special_node)
     83 	{
     84 		if (acptr->user->snomask)
     85 		{
     86 			char found = 0;
     87 			for (p = sno; *p; p++)
     88 			{
     89 				if (strchr(acptr->user->snomask, *p))
     90 				{
     91 					found = 1;
     92 					break;
     93 				}
     94 			}
     95 			if (found)
     96 				sendto_one(acptr, mtags, ":%s NOTICE %s :%s", client->name, acptr->name, msg);
     97 		}
     98 	}
     99 
    100 	free_message_tags(mtags);
    101 }