diff options
-rw-r--r-- | docs/conf/inspircd.conf.example | 5 | ||||
-rw-r--r-- | docs/conf/modules.conf.example | 13 | ||||
-rw-r--r-- | include/configreader.h | 5 | ||||
-rw-r--r-- | include/modules.h | 4 | ||||
-rw-r--r-- | src/configreader.cpp | 3 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_invite.cpp | 43 | ||||
-rw-r--r-- | src/coremods/core_privmsg.cpp | 9 | ||||
-rw-r--r-- | src/modules.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_ircv3_echomessage.cpp | 70 | ||||
-rw-r--r-- | src/modules/m_ircv3_invitenotify.cpp | 68 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 2 |
12 files changed, 183 insertions, 43 deletions
diff --git a/docs/conf/inspircd.conf.example b/docs/conf/inspircd.conf.example index de2b5ee68..33f455357 100644 --- a/docs/conf/inspircd.conf.example +++ b/docs/conf/inspircd.conf.example @@ -567,11 +567,6 @@ # triggers anti-takeover mechanisms of some obsolete bots. cyclehostsfromuser="no" - # ircumsgprefix: Use undernet-style message prefixing for NOTICE and - # PRIVMSG. If enabled, it will add users' prefix to the line, if not, - # it will just message the user normally. - ircumsgprefix="no" - # announcets: If set to yes, when the timestamp on a channel changes, all users # in the channel will be sent a NOTICE about it. announcets="yes" diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index 52a8f5eeb..dddd6b91f 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -982,6 +982,19 @@ #<module name="ircv3_chghost"> #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# +# IRCv3 echo-message module: Provides the echo-message IRCv3.2 +# extension which allows capable clients to get an acknowledgement when +# their messages are delivered and learn what modifications, if any, +# were applied to them. +#<module name="ircv3_echomessage"> + +#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# +# IRCv3 invite-notify module: Provides the invite-notify IRCv3.2 +# extension which notifies supporting clients when a user invites +# another user into a channel. This respects <options:announceinvites>. +#<module name="ircv3_invitenotify"> + +#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Join flood module: Adds support for join flood protection +j X:Y. # Closes the channel for 60 seconds if X users join in Y seconds. #<module name="joinflood"> diff --git a/include/configreader.h b/include/configreader.h index 9b73dd3c6..fe1e5da9e 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -431,11 +431,6 @@ class CoreExport ServerConfig */ bool CycleHostsFromUser; - /** If set to true, prefixed channel NOTICEs and PRIVMSGs will have the prefix - * added to the outgoing text for undernet style msg prefixing. - */ - bool UndernetMsgPrefix; - /** If set to true, the full nick!user\@host will be shown in the TOPIC command * for who set the topic last. If false, only the nick is shown. */ diff --git a/include/modules.h b/include/modules.h index 93e5c05a0..526c283b2 100644 --- a/include/modules.h +++ b/include/modules.h @@ -487,8 +487,10 @@ class CoreExport Module : public classbase, public usecountbase * @param dest The user being invited * @param channel The channel the user is being invited to * @param timeout The time the invite will expire (0 == never) + * @param notifyrank Rank required to get an invite announcement (if enabled) + * @param notifyexcepts List of users to not send the default NOTICE invite announcement to */ - virtual void OnUserInvite(User* source,User* dest,Channel* channel, time_t timeout); + virtual void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts); /** Called whenever a user is about to PRIVMSG A user or a channel, before any processing is done. * Returning any nonzero value from this function stops the process immediately, causing no diff --git a/src/configreader.cpp b/src/configreader.cpp index a81a1b646..092911c74 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -55,7 +55,7 @@ ServerConfig::ServerConfig() , Limits(EmptyTag) , NoSnoticeStack(false) { - RawLog = HideBans = HideSplits = UndernetMsgPrefix = false; + RawLog = HideBans = HideSplits = false; WildcardIPv6 = true; dns_timeout = 5; MaxTargets = 20; @@ -413,7 +413,6 @@ void ServerConfig::Fill() GenericOper = security->getBool("genericoper"); SyntaxHints = options->getBool("syntaxhints"); CycleHostsFromUser = options->getBool("cyclehostsfromuser"); - UndernetMsgPrefix = options->getBool("ircumsgprefix"); FullHostInTopic = options->getBool("hostintopic"); MaxTargets = security->getInt("maxtargets", 20, 1, 31); DefaultModes = options->getString("defaultmodes", "not"); diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp index 96f560582..c1f1b00c7 100644 --- a/src/coremods/core_channel/cmd_invite.cpp +++ b/src/coremods/core_channel/cmd_invite.cpp @@ -122,31 +122,36 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use user->WriteNumeric(RPL_AWAY, "%s :%s", u->nick.c_str(), u->awaymsg.c_str()); } - if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE) + char prefix = 0; + unsigned int minrank = 0; + switch (ServerInstance->Config->AnnounceInvites) { - char prefix; - switch (ServerInstance->Config->AnnounceInvites) + case ServerConfig::INVITE_ANNOUNCE_OPS: { - case ServerConfig::INVITE_ANNOUNCE_OPS: - { - prefix = '@'; - break; - } - case ServerConfig::INVITE_ANNOUNCE_DYNAMIC: - { - PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h'); - prefix = (mh && mh->name == "halfop" ? mh->GetPrefix() : '@'); - break; - } - default: + prefix = '@'; + minrank = OP_VALUE; + break; + } + case ServerConfig::INVITE_ANNOUNCE_DYNAMIC: + { + PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h'); + if ((mh) && (mh->name == "halfop")) { - prefix = 0; - break; + prefix = mh->GetPrefix(); + minrank = mh->GetPrefixRank(); } + break; + } + default: + { } - c->WriteAllExceptSender(user, true, prefix, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str()); } - FOREACH_MOD(OnUserInvite, (user,u,c,timeout)); + + CUList excepts; + FOREACH_MOD(OnUserInvite, (user, u, c, timeout, minrank, excepts)); + + if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE) + c->WriteAllExcept(user, true, prefix, excepts, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str()); } else if (IS_LOCAL(user)) { diff --git a/src/coremods/core_privmsg.cpp b/src/coremods/core_privmsg.cpp index 34527027c..d691464c0 100644 --- a/src/coremods/core_privmsg.cpp +++ b/src/coremods/core_privmsg.cpp @@ -169,14 +169,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para if (status) { - if (ServerInstance->Config->UndernetMsgPrefix) - { - chan->WriteAllExcept(user, false, status, except_list, "%s %c%s :%c %s", MessageTypeString[mt], status, chan->name.c_str(), status, text); - } - else - { - chan->WriteAllExcept(user, false, status, except_list, "%s %c%s :%s", MessageTypeString[mt], status, chan->name.c_str(), text); - } + chan->WriteAllExcept(user, false, status, except_list, "%s %c%s :%s", MessageTypeString[mt], status, chan->name.c_str(), text); } else { diff --git a/src/modules.cpp b/src/modules.cpp index d77221c39..292986df5 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -114,7 +114,7 @@ ModResult Module::OnPreTopicChange(User*, Channel*, const std::string&) { Detach ModResult Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { DetachEvent(I_OnPassCompare); return MOD_RES_PASSTHRU; } void Module::OnPostConnect(User*) { DetachEvent(I_OnPostConnect); } void Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&, MessageType) { DetachEvent(I_OnUserMessage); } -void Module::OnUserInvite(User*, User*, Channel*, time_t) { DetachEvent(I_OnUserInvite); } +void Module::OnUserInvite(User*, User*, Channel*, time_t, unsigned int, CUList&) { DetachEvent(I_OnUserInvite); } void Module::OnPostTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPostTopicChange); } void Module::OnSyncUser(User*, ProtocolInterface::Server&) { DetachEvent(I_OnSyncUser); } void Module::OnSyncChannel(Channel*, ProtocolInterface::Server&) { DetachEvent(I_OnSyncChannel); } diff --git a/src/modules/m_ircv3_echomessage.cpp b/src/modules/m_ircv3_echomessage.cpp new file mode 100644 index 000000000..8773d7187 --- /dev/null +++ b/src/modules/m_ircv3_echomessage.cpp @@ -0,0 +1,70 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com> + * Copyright (C) 2013-2015 Peter Powell <petpow@saberuk.com> + * + * This file is part of InspIRCd. InspIRCd 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, version 2. + * + * 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, see <http://www.gnu.org/licenses/>. + */ + + +#include "inspircd.h" +#include "modules/cap.h" + +static const char* MessageTypeStringSp[] = { "PRIVMSG ", "NOTICE " }; + +class ModuleIRCv3EchoMessage : public Module +{ + Cap::Capability cap; + + public: + ModuleIRCv3EchoMessage() + : cap(this, "echo-message") + { + } + + void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE + { + if (!cap.get(user)) + return; + + std::string msg = MessageTypeStringSp[msgtype]; + if (target_type == TYPE_USER) + { + User* destuser = static_cast<User*>(dest); + msg.append(destuser->nick); + } + else if (target_type == TYPE_CHANNEL) + { + if (status) + msg.push_back(status); + + Channel* chan = static_cast<Channel*>(dest); + msg.append(chan->name); + } + else + { + const char* servername = static_cast<const char*>(dest); + msg.append(servername); + } + msg.append(" :").append(text); + user->WriteFrom(user, msg); + } + + Version GetVersion() CXX11_OVERRIDE + { + return Version("Provides the echo-message IRCv3.2 extension", VF_VENDOR); + } +}; + +MODULE_INIT(ModuleIRCv3EchoMessage) diff --git a/src/modules/m_ircv3_invitenotify.cpp b/src/modules/m_ircv3_invitenotify.cpp new file mode 100644 index 000000000..3783ff33c --- /dev/null +++ b/src/modules/m_ircv3_invitenotify.cpp @@ -0,0 +1,68 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com> + * + * This file is part of InspIRCd. InspIRCd 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, version 2. + * + * 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, see <http://www.gnu.org/licenses/>. + */ + + +#include "inspircd.h" +#include "modules/cap.h" + +class ModuleIRCv3InviteNotify : public Module +{ + Cap::Capability cap; + + public: + ModuleIRCv3InviteNotify() + : cap(this, "invite-notify") + { + } + + void OnUserInvite(User* source, User* dest, Channel* chan, time_t expiry, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE + { + std::string msg = "INVITE "; + msg.append(dest->nick).append(1, ' ').append(chan->name); + const Channel::MemberMap& users = chan->GetUsers(); + for (Channel::MemberMap::const_iterator i = users.begin(); i != users.end(); ++i) + { + User* user = i->first; + // Skip members who don't use this extension or were excluded by other modules + if ((!cap.get(user)) || (notifyexcepts.count(user))) + continue; + + Membership* memb = i->second; + // Check whether the member has a high enough rank to see the notification + if (memb->getRank() < notifyrank) + continue; + + // Send and add the user to the exceptions so they won't get the NOTICE invite announcement message + user->WriteFrom(source, msg); + notifyexcepts.insert(user); + } + } + + void Prioritize() CXX11_OVERRIDE + { + // Prioritize after all modules to see all excepted users + ServerInstance->Modules.SetPriority(this, I_OnUserInvite, PRIORITY_LAST); + } + + Version GetVersion() CXX11_OVERRIDE + { + return Version("Provides the invite-notify IRCv3.2 extension", VF_VENDOR); + } +}; + +MODULE_INIT(ModuleIRCv3InviteNotify) diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 98cf3188f..4e45b4fe8 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -358,7 +358,7 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& para return MOD_RES_DENY; } -void ModuleSpanningTree::OnUserInvite(User* source,User* dest,Channel* channel, time_t expiry) +void ModuleSpanningTree::OnUserInvite(User* source, User* dest, Channel* channel, time_t expiry, unsigned int notifyrank, CUList& notifyexcepts) { if (IS_LOCAL(source)) { diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 9fde32cad..d29609a35 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -149,7 +149,7 @@ class ModuleSpanningTree : public Module ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE; void OnPostCommand(Command*, const std::vector<std::string>& parameters, LocalUser* user, CmdResult result, const std::string& original_line) CXX11_OVERRIDE; void OnUserConnect(LocalUser* source) CXX11_OVERRIDE; - void OnUserInvite(User* source,User* dest,Channel* channel, time_t) CXX11_OVERRIDE; + void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE; void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE; void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE; void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE; |