unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
sendumode.c (2494B)
1 /* 2 * Unreal Internet Relay Chat Daemon, src/modules/sendumode.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_sendumode); 24 25 /* Place includes here */ 26 #define MSG_SENDUMODE "SENDUMODE" 27 #define MSG_SMO "SMO" 28 29 ModuleHeader MOD_HEADER 30 = { 31 "sendumode", /* Name of module */ 32 "5.0", /* Version */ 33 "command /sendumode", /* Short description of module */ 34 "UnrealIRCd Team", 35 "unrealircd-6", 36 }; 37 38 /* This is called on module init, before Server Ready */ 39 MOD_INIT() 40 { 41 CommandAdd(modinfo->handle, MSG_SENDUMODE, cmd_sendumode, MAXPARA, CMD_SERVER); 42 CommandAdd(modinfo->handle, MSG_SMO, cmd_sendumode, MAXPARA, CMD_SERVER); 43 MARK_AS_OFFICIAL_MODULE(modinfo); 44 return MOD_SUCCESS; 45 } 46 47 /* Is first run when server is 100% ready */ 48 MOD_LOAD() 49 { 50 return MOD_SUCCESS; 51 } 52 53 /* Called when module is unloaded */ 54 MOD_UNLOAD() 55 { 56 return MOD_SUCCESS; 57 } 58 59 /** SENDUMODE - Send to usermode command (S2S traffic only). 60 * parv[1] = target user modes 61 * parv[2] = message text 62 * For example: 63 * :server SENDUMODE o :Serious problem: blablabla 64 */ 65 CMD_FUNC(cmd_sendumode) 66 { 67 MessageTag *mtags = NULL; 68 Client *acptr; 69 const char *message; 70 const char *p; 71 int i; 72 long umode_s = 0; 73 74 message = (parc > 3) ? parv[3] : parv[2]; 75 76 if (parc < 3) 77 { 78 sendnumeric(client, ERR_NEEDMOREPARAMS, "SENDUMODE"); 79 return; 80 } 81 82 new_message(client, recv_mtags, &mtags); 83 84 sendto_server(client, 0, 0, mtags, ":%s SENDUMODE %s :%s", client->id, parv[1], message); 85 86 umode_s = set_usermode(parv[1]); 87 88 list_for_each_entry(acptr, &oper_list, special_node) 89 { 90 if (acptr->umodes & umode_s) 91 sendto_one(acptr, mtags, ":%s NOTICE %s :%s", client->name, acptr->name, message); 92 } 93 94 free_message_tags(mtags); 95 }