unrealircd

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

sreply.c (2412B)

      1 /*
      2  *   Unreal Internet Relay Chat Daemon, src/modules/sreply.c
      3  *   (C) 2022 Valware and the UnrealIRCd Team
      4  * 
      5  *   Allows services to send Standard Replies in response to non-privmsg commands:
      6  *   https://ircv3.net/specs/extensions/standard-replies
      7  *
      8  *   This program is free software; you can redistribute it and/or modify
      9  *   it under the terms of the GNU General Public License as published by
     10  *   the Free Software Foundation; either version 1, or (at your option)
     11  *   any later version.
     12  *
     13  *   This program is distributed in the hope that it will be useful,
     14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16  *   GNU General Public License for more details.
     17  *
     18  *   You should have received a copy of the GNU General Public License
     19  *   along with this program; if not, write to the Free Software
     20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     21  */
     22 
     23 #include "unrealircd.h"
     24 
     25 CMD_FUNC(cmd_sreply);
     26 
     27 ModuleHeader MOD_HEADER
     28   = {
     29 	"sreply",	/* Name of module */
     30 	"1.0", /* Version */
     31 	"Server command SREPLY", /* 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, "SREPLY", cmd_sreply, 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_sreply
     58  * @param parv[1]		Nick|UID
     59  * @param parv[2]		"F", "W" or "N" for FAIL, WARN and NOTE.
     60  * @param parv[3]		The rest of the message
     61 */
     62 CMD_FUNC(cmd_sreply)
     63 {
     64 	Client *target;
     65 
     66 	if (parc < 4)
     67 		return;
     68 
     69 	target = find_user(parv[1], NULL);
     70 	if (!target && !(target = find_server_by_uid(parv[1])))
     71 		return;
     72 
     73 	if (!MyUser(target))
     74 	{
     75 		/* Target is a remote user/server */
     76 		sendto_one(target, recv_mtags, ":%s SREPLY %s %s :%s", client->name, parv[1], parv[2], parv[3]);
     77 		return;
     78 	}
     79 
     80 	/* For a locally connected user... */
     81 	if (!strcmp(parv[2],"F"))
     82 		sendto_one(target, recv_mtags, ":%s FAIL %s", client->name, parv[3]);
     83 	else if (!strcmp(parv[2],"W"))
     84 		sendto_one(target, recv_mtags, ":%s WARN %s", client->name, parv[3]);
     85 	else if (!strcmp(parv[2],"N"))
     86 		sendto_one(target, recv_mtags, ":%s NOTE %s", client->name, parv[3]);
     87 }