Skip to content

Commit

Permalink
extensions/invite_notify: make the NOTICE optional, configurable
Browse files Browse the repository at this point in the history
This adds a configuration option that determines whether the NOTICE is
sent to clients that do not support the IRCv3 invite-notify capability.

Requested by LiberaChat MGM.
  • Loading branch information
aaronmdjones authored and spb committed Nov 8, 2023
1 parent 642c73d commit 4d12e65
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/ircd.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ channel {
displayed_usercount = 3;
strip_topic_colors = no;
opmod_send_statusmsg = no;
invite_notify_notice = yes;
};

serverhide {
Expand Down
5 changes: 5 additions & 0 deletions doc/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,11 @@ channel {

/* ip_bans_through_vhost: should channel IP bans see through dynamic spoofed hosts? */
ip_bans_through_vhost = yes;

/* invite_notify_notice: when using extensions/invite_notify, should
* we send a NOTICE to clients that don't support IRCv3 invite-notify
*/
invite_notify_notice = yes;
};


Expand Down
11 changes: 8 additions & 3 deletions extensions/invite_notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <client.h>
#include <hash.h>
#include <send.h>
#include <s_conf.h>
#include <s_serv.h>

static const char inv_notify_desc[] = "Notifies channel on /invite and provides the invite-notify client capability";
Expand Down Expand Up @@ -32,12 +33,16 @@ mapi_clist_av1 inv_notify_clist[] = { &invited_msgtab, NULL };
static void
invite_notify(struct Client *source, struct Client *target, struct Channel *channel)
{
sendto_channel_local_with_capability(source, CHFL_CHANOP, 0, CAP_INVITE_NOTIFY, channel,
":%s NOTICE %s :%s is inviting %s to %s.",
me.name, channel->chname, source->name, target->name, channel->chname);
sendto_channel_local_with_capability(source, CHFL_CHANOP, CAP_INVITE_NOTIFY, 0, channel,
":%s!%s@%s INVITE %s %s", source->name, source->username,
source->host, target->name, channel->chname);

if (!ConfigChannel.invite_notify_notice)
return;

sendto_channel_local_with_capability(source, CHFL_CHANOP, 0, CAP_INVITE_NOTIFY, channel,
":%s NOTICE %s :%s is inviting %s to %s.",
me.name, channel->chname, source->name, target->name, channel->chname);
}

static void
Expand Down
1 change: 1 addition & 0 deletions include/s_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ struct config_channel_entry
int strip_topic_colors;
int opmod_send_statusmsg;
int ip_bans_through_vhost;
int invite_notify_notice;
};

struct config_server_hide
Expand Down
1 change: 1 addition & 0 deletions ircd/newconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2821,6 +2821,7 @@ static struct ConfEntry conf_channel_table[] =
{ "strip_topic_colors", CF_YESNO, NULL, 0, &ConfigChannel.strip_topic_colors },
{ "opmod_send_statusmsg", CF_YESNO, NULL, 0, &ConfigChannel.opmod_send_statusmsg },
{ "ip_bans_through_vhost", CF_YESNO, NULL, 0, &ConfigChannel.ip_bans_through_vhost },
{ "invite_notify_notice", CF_YESNO, NULL, 0, &ConfigChannel.invite_notify_notice },
{ "\0", 0, NULL, 0, NULL }
};

Expand Down
3 changes: 2 additions & 1 deletion ircd/s_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,8 @@ set_default_conf(void)
ConfigChannel.disable_local_channels = false;
ConfigChannel.displayed_usercount = 3;
ConfigChannel.opmod_send_statusmsg = false;
ConfigChannel.ip_bans_through_vhost= true;
ConfigChannel.ip_bans_through_vhost = true;
ConfigChannel.invite_notify_notice = true;

ConfigChannel.autochanmodes = MODE_TOPICLIMIT | MODE_NOPRIVMSGS;

Expand Down
5 changes: 5 additions & 0 deletions modules/m_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,11 @@ static struct InfoStruct info_table[] = {
"Channel IP bans see through dynamic spoofs",
INFO_INTBOOL_YN(&ConfigChannel.ip_bans_through_vhost),
},
{
"invite_notify_notice",
"NOTICEs are sent to clients that do not support invite-notify",
INFO_INTBOOL_YN(&ConfigChannel.invite_notify_notice),
},
{
"hide_opers",
"Hide all opers from unprivileged users",
Expand Down

0 comments on commit 4d12e65

Please sign in to comment.