1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-29 18:06:38 +02:00

Add CAP echo-message.

This commit is contained in:
Bram Matthys
2019-08-13 18:36:25 +02:00
parent 912eea52d7
commit 4c8fe6e8d9
5 changed files with 104 additions and 6 deletions
+2 -1
View File
@@ -200,12 +200,13 @@ loadmodule "extbans/partmsg"; /* +b ~p (hide part/quit message) */
loadmodule "message-tags"; /* add tags to messages, required for various IRCv3 features */
loadmodule "batch"; /* also required for several IRCv3 features */
loadmodule "account-tag"; /* adds services account information to messages */
loadmodule "labeled-response"; /* help clients with correlating requests to responses */
loadmodule "link-security"; /* link-security announce */
loadmodule "message-ids"; /* adds unique msgid to various messages */
loadmodule "plaintext-policy"; /* plaintext-policy announce */
loadmodule "server-time"; /* adds server timestamp to various messages */
loadmodule "sts"; /* strict transport policy (set::tls::sts-policy) */
loadmodule "echo-message"; /* shows clients if their messages are altered/filtered */
loadmodule "labeled-response"; /* help clients with correlating requests to responses (EXPERIMENTAL) */
/*** Other ***/
+1 -1
View File
@@ -957,7 +957,7 @@ int hooktype_stats(aClient *sptr, char *str);
int hooktype_local_join(aClient *cptr, aClient *sptr, aChannel *chptr, char *parv[]);
int hooktype_configtest(ConfigFile *cfptr, ConfigEntry *ce, int section, int *errors);
int hooktype_configrun(ConfigFile *cfptr, ConfigEntry *ce, int section);
int hooktype_usermsg(aClient *sptr, aClient *to, char *text, int notice);
int hooktype_usermsg(aClient *sptr, aClient *to, MessageTag *mtags, char *text, int notice);
int hooktype_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice);
int hooktype_local_part(aClient *cptr, aClient *sptr, aChannel *chptr, char *comment);
int hooktype_local_kick(aClient *cptr, aClient *sptr, aClient *victim, aChannel *chptr, char *comment);
+6 -1
View File
@@ -68,7 +68,8 @@ R_MODULES= \
rmtkl.so \
message-tags.so batch.so \
account-tag.so labeled-response.so link-security.so \
message-ids.so plaintext-policy.so server-time.so sts.so
message-ids.so plaintext-policy.so server-time.so sts.so \
echo-message.so
MODULES=cloak.so $(R_MODULES)
MODULEFLAGS=@MODULEFLAGS@
@@ -599,6 +600,10 @@ sts.so: sts.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o sts.so sts.c
echo-message.so: echo-message.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o echo-message.so echo-message.c
#############################################################################
# capabilities
#############################################################################
+93
View File
@@ -0,0 +1,93 @@
/*
* IRC - Internet Relay Chat, src/modules/echo-message.c
* (C) 2019 Syzop & The UnrealIRCd Team
*
* See file AUTHORS in IRC package for additional names of
* the programmers.
*
* This program is free software; 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 1, 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 "unrealircd.h"
ModuleHeader MOD_HEADER(echo_message)
= {
"echo-message",
"5.0",
"Batch CAP",
"3.2-b8-1",
NULL
};
/* Variables */
long CAP_ECHO_MESSAGE = 0L;
/* Forward declarations */
int em_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice);
int em_usermsg(aClient *sptr, aClient *to, MessageTag *mtags, char *text, int notice);
MOD_INIT(echo_message)
{
ClientCapabilityInfo cap;
ClientCapability *c;
MessageTagHandlerInfo mtag;
MARK_AS_OFFICIAL_MODULE(modinfo);
memset(&cap, 0, sizeof(cap));
cap.name = "echo-message";
c = ClientCapabilityAdd(modinfo->handle, &cap, &CAP_ECHO_MESSAGE);
HookAdd(modinfo->handle, HOOKTYPE_CHANMSG, 0, em_chanmsg);
HookAdd(modinfo->handle, HOOKTYPE_USERMSG, 0, em_usermsg);
return MOD_SUCCESS;
}
MOD_LOAD(echo_message)
{
return MOD_SUCCESS;
}
MOD_UNLOAD(echo_message)
{
return MOD_SUCCESS;
}
int em_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice)
{
if (MyClient(sptr))
{
sendto_prefix_one(sptr, sptr, mtags, ":%s %s %s :%s",
sptr->name,
notice ? "NOTICE" : "PRIVMSG",
chptr->chname, /* FIXME: should use target buffer that may include @ and such */
text);
}
return 0;
}
int em_usermsg(aClient *sptr, aClient *to, MessageTag *mtags, char *text, int notice)
{
if (MyClient(sptr))
{
sendto_prefix_one(sptr, sptr, mtags, ":%s %s %s :%s",
sptr->name,
notice ? "NOTICE" : "PRIVMSG",
to->name,
text);
}
return 0;
}
+2 -3
View File
@@ -1,5 +1,5 @@
/*
* Unreal Internet Relay Chat Daemon, src/modules/m_message.c
* Unreal Internet Relay Chat Daemon, src/modules/message.c
* (C) 2000-2001 Carsten V. Munk and the UnrealIRCd Team
* Moved to modules by Fish (Justin Hammond)
*
@@ -142,8 +142,6 @@ int ret;
if (!*text)
return CANPRIVMSG_CONTINUE;
RunHook4(HOOKTYPE_USERMSG, sptr, acptr, *text, notice);
return CANPRIVMSG_SEND;
} else {
/* Silenced */
@@ -430,6 +428,7 @@ int m_message(aClient *cptr, aClient *sptr, MessageTag *recv_mtags, int parc, ch
newcmd,
(MyClient(acptr) ? acptr->name : nick),
text);
RunHook5(HOOKTYPE_USERMSG, sptr, acptr, mtags, text, notice);
free_mtags(mtags);
continue;
} else