From b930f9a2fc7060738cabc00a5fe5845ec193d752 Mon Sep 17 00:00:00 2001
From: Bram Matthys
(Note: also see here about the standard alias files UnrealIRCd has)
The alias block [standard alias] allows you to forward a command to a user, @@ -1982,8 +1983,9 @@ alias <name> { forward to, alias::target can be left out. The alias::type specifies the type of alias, valid types are services (the user is on the services server), stats (the user is on the stats server), normal (the user is a normal user on - any server), and channel (the target is a channel name). The alias block also has another - purpose which is explained below.
+ any server), and channel (the target is a channel name). If alias::spamfilter (optional) + is set to 'yes', then the spamfilters will be checked (default is 'no').Syntax [command alias]:
alias <name> {
@@ -1996,6 +1998,7 @@ alias <name> {
...
};
type command;
+ spamfilter <yes|no>;
};
When the alias block is used in this format, it allows you a much broader range of usage. For example you can create aliases such as /identify. The alias:: diff --git a/include/struct.h b/include/struct.h index a80289fb8..9d33b7f82 100644 --- a/include/struct.h +++ b/include/struct.h @@ -1314,6 +1314,7 @@ struct _configitem_alias { ConfigItem_alias_format *format; char *alias, *nick; AliasType type; + unsigned int spamfilter:1; }; struct _configitem_alias_format { diff --git a/src/s_conf.c b/src/s_conf.c index a27ebd94d..6c98bb2fa 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -7933,7 +7933,8 @@ int _conf_alias(ConfigFile *conf, ConfigEntry *ce) else if (!strcmp(cep->ce_vardata, "command")) alias->type = ALIAS_COMMAND; } - + else if (!strcmp(cep->ce_varname, "spamfilter")) + alias->spamfilter = config_checkval(cep->ce_vardata, CFG_YESNO); } if (BadPtr(alias->nick) && alias->type != ALIAS_COMMAND) { ircstrdup(alias->nick, alias->alias); @@ -8110,6 +8111,8 @@ int _test_alias(ConfigFile *conf, ConfigEntry *ce) { errors++; } } + else if (!strcmp(cep->ce_varname, "spamfilter")) + ; else { config_error_unknown(cep->ce_fileptr->cf_filename, cep->ce_varlinenum, "alias", cep->ce_varname); diff --git a/src/s_svs.c b/src/s_svs.c index 02354e194..585f4aa47 100644 --- a/src/s_svs.c +++ b/src/s_svs.c @@ -220,9 +220,12 @@ void strrangetok(char *in, char *out, char tok, short first, short last) { out[j] = 0; } -int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { - ConfigItem_alias *alias; - aClient *acptr; +int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) +{ +ConfigItem_alias *alias; +aClient *acptr; +int ret; + if (parc < 2 || *parv[1] == '\0') { sendto_one(sptr, err_str(ERR_NOTEXTTOSEND), me.name, parv[0]); @@ -238,9 +241,13 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { if (alias->type == ALIAS_SERVICES) { if (SERVICES_NAME && (acptr = find_person(alias->nick, NULL))) + { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_USERMSG, alias->nick, 0)) < 0) + return ret; sendto_one(acptr, ":%s %s %s@%s :%s", parv[0], IsToken(acptr->from) ? TOK_PRIVATE : MSG_PRIVATE, alias->nick, SERVICES_NAME, parv[1]); + } else sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, parv[0], alias->nick); @@ -248,9 +255,13 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { else if (alias->type == ALIAS_STATS) { if (STATS_SERVER && (acptr = find_person(alias->nick, NULL))) + { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_USERMSG, alias->nick, 0)) < 0) + return ret; sendto_one(acptr, ":%s %s %s@%s :%s", parv[0], IsToken(acptr->from) ? TOK_PRIVATE : MSG_PRIVATE, alias->nick, STATS_SERVER, parv[1]); + } else sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, parv[0], alias->nick); @@ -259,6 +270,8 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { { if ((acptr = find_person(alias->nick, NULL))) { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_USERMSG, alias->nick, 0)) < 0) + return ret; if (MyClient(acptr)) sendto_one(acptr, ":%s!%s@%s PRIVMSG %s :%s", parv[0], sptr->user->username, GetHost(sptr), @@ -279,6 +292,8 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { { if (!can_send(sptr, chptr, parv[1], 0)) { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_CHANMSG, chptr->chname, 0)) < 0) + return ret; sendto_channelprefix_butone_tok(sptr, sptr, chptr, PREFIX_ALL, @@ -355,27 +370,35 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { if (format->type == ALIAS_SERVICES) { if (SERVICES_NAME && (acptr = find_person(format->nick, NULL))) + { + if (alias->spamfilter && (ret = dospamfilter(sptr, output, SPAMF_USERMSG, format->nick, 0)) < 0) + return ret; sendto_one(acptr, ":%s %s %s@%s :%s", parv[0], IsToken(acptr->from) ? TOK_PRIVATE : MSG_PRIVATE, format->nick, SERVICES_NAME, output); - else + } else sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, parv[0], format->nick); } else if (format->type == ALIAS_STATS) { if (STATS_SERVER && (acptr = find_person(format->nick, NULL))) + { + if (alias->spamfilter && (ret = dospamfilter(sptr, output, SPAMF_USERMSG, format->nick, 0)) < 0) + return ret; sendto_one(acptr, ":%s %s %s@%s :%s", parv[0], IsToken(acptr->from) ? TOK_PRIVATE : MSG_PRIVATE, format->nick, STATS_SERVER, output); - else - sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, - parv[0], format->nick); + } else + sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, + parv[0], format->nick); } else if (format->type == ALIAS_NORMAL) { if ((acptr = find_person(format->nick, NULL))) { + if (alias->spamfilter && (ret = dospamfilter(sptr, output, SPAMF_USERMSG, format->nick, 0)) < 0) + return ret; if (MyClient(acptr)) sendto_one(acptr, ":%s!%s@%s PRIVMSG %s :%s", parv[0], sptr->user->username, IsHidden(sptr) ? sptr->user->virthost : sptr->user->realhost, @@ -396,6 +419,8 @@ int m_alias(aClient *cptr, aClient *sptr, int parc, char *parv[], char *cmd) { { if (!can_send(sptr, chptr, parv[1], 0)) { + if (alias->spamfilter && (ret = dospamfilter(sptr, parv[1], SPAMF_CHANMSG, chptr->chname, 0)) < 0) + return ret; sendto_channelprefix_butone_tok(sptr, sptr, chptr, PREFIX_ALL, MSG_PRIVATE,