summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/configreader.cpp3
-rw-r--r--src/coremods/core_channel/cmd_invite.cpp43
-rw-r--r--src/coremods/core_privmsg.cpp9
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_ircv3_echomessage.cpp70
-rw-r--r--src/modules/m_ircv3_invitenotify.cpp68
-rw-r--r--src/modules/m_spanningtree/main.cpp2
-rw-r--r--src/modules/m_spanningtree/main.h2
8 files changed, 167 insertions, 32 deletions
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;