unrealircd

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

echo-message.c (2857B)

      1 /*
      2  *   IRC - Internet Relay Chat, src/modules/echo-message.c
      3  *   (C) 2019 Syzop & The UnrealIRCd Team
      4  *
      5  *   See file AUTHORS in IRC package for additional names of
      6  *   the programmers.
      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 ModuleHeader MOD_HEADER
     26   = {
     27 	"echo-message",
     28 	"5.0",
     29 	"echo-message CAP",
     30 	"UnrealIRCd Team",
     31 	"unrealircd-6",
     32 	};
     33 
     34 /* Variables */
     35 long CAP_ECHO_MESSAGE = 0L;
     36 
     37 /* Forward declarations */
     38 int em_chanmsg(Client *client, Channel *channel, int sendflags, const char *prefix, const char *target, MessageTag *mtags, const char *text, SendType sendtype);
     39 int em_usermsg(Client *client, Client *to, MessageTag *mtags, const char *text, SendType sendtype);
     40 
     41 MOD_INIT()
     42 {
     43 	ClientCapabilityInfo cap;
     44 
     45 	MARK_AS_OFFICIAL_MODULE(modinfo);
     46 
     47 	memset(&cap, 0, sizeof(cap));
     48 	cap.name = "echo-message";
     49 	ClientCapabilityAdd(modinfo->handle, &cap, &CAP_ECHO_MESSAGE);
     50 
     51 	HookAdd(modinfo->handle, HOOKTYPE_CHANMSG, 0, em_chanmsg);
     52 	HookAdd(modinfo->handle, HOOKTYPE_USERMSG, 0, em_usermsg);
     53 
     54 	return MOD_SUCCESS;
     55 }
     56 
     57 MOD_LOAD()
     58 {
     59 	return MOD_SUCCESS;
     60 }
     61 
     62 MOD_UNLOAD()
     63 {
     64 	return MOD_SUCCESS;
     65 }
     66 
     67 int em_chanmsg(Client *client, Channel *channel, int sendflags, const char *prefix, const char *target, MessageTag *mtags, const char *text, SendType sendtype)
     68 {
     69 	if (MyUser(client) && HasCapabilityFast(client, CAP_ECHO_MESSAGE))
     70 	{
     71 		if (sendtype != SEND_TYPE_TAGMSG)
     72 		{
     73 			sendto_prefix_one(client, client, mtags, ":%s %s %s :%s",
     74 				client->name,
     75 				sendtype_to_cmd(sendtype),
     76 				target,
     77 				text);
     78 		} else {
     79 			sendto_prefix_one(client, client, mtags, ":%s %s %s",
     80 				client->name,
     81 				sendtype_to_cmd(sendtype),
     82 				target);
     83 		}
     84 	}
     85 	return 0;
     86 }
     87 
     88 int em_usermsg(Client *client, Client *to, MessageTag *mtags, const char *text, SendType sendtype)
     89 {
     90 	if (MyUser(client) && HasCapabilityFast(client, CAP_ECHO_MESSAGE))
     91 	{
     92 		if (sendtype != SEND_TYPE_TAGMSG)
     93 		{
     94 			sendto_prefix_one(client, client, mtags, ":%s %s %s :%s",
     95 				client->name,
     96 				sendtype_to_cmd(sendtype),
     97 				to->name,
     98 				text);
     99 		} else {
    100 			sendto_prefix_one(client, client, mtags, ":%s %s %s",
    101 				client->name,
    102 				sendtype_to_cmd(sendtype),
    103 				to->name);
    104 		}
    105 	}
    106 	return 0;
    107 }