summaryrefslogtreecommitdiff
path: root/src/modules/m_knock.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-09-13 01:15:44 +0200
committerattilamolnar <attilamolnar@hush.com>2012-09-13 18:12:38 +0200
commit1b03dfaeec9b4e4668fe1c02af93ebf4e7f82f73 (patch)
tree2bb6fc7ae2b941f87e0c8492bcd97becfa96a8ef /src/modules/m_knock.cpp
parent35ce47718b6021115c9b12e7e63a7daf8bb4a900 (diff)
m_knock Add support for sending a 710 numeric when a KNOCK succeeds, add a config option to choose between behaviors
Fixes #287 reported by @ElementalAlchemist
Diffstat (limited to 'src/modules/m_knock.cpp')
-rw-r--r--src/modules/m_knock.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 8cd5088bc..97eb0e005 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -28,6 +28,8 @@
class CommandKnock : public Command
{
public:
+ bool sendnotice;
+ bool sendnumeric;
CommandKnock(Module* Creator) : Command(Creator,"KNOCK", 2, 2)
{
syntax = "<channel> <reason>";
@@ -62,7 +64,12 @@ class CommandKnock : public Command
return CMD_FAILURE;
}
- c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :User %s is KNOCKing on %s (%s)", c->name.c_str(), user->nick.c_str(), c->name.c_str(), parameters[1].c_str());
+ if (sendnotice)
+ c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :User %s is KNOCKing on %s (%s)", c->name.c_str(), user->nick.c_str(), c->name.c_str(), parameters[1].c_str());
+
+ if (sendnumeric)
+ c->WriteChannelWithServ(ServerInstance->Config->ServerName, "710 %s %s %s :is KNOCKing: %s", c->name.c_str(), c->name.c_str(), user->GetFullHost().c_str(), parameters[1].c_str());
+
user->WriteServ("NOTICE %s :KNOCKing on %s", user->nick.c_str(), c->name.c_str());
return CMD_SUCCESS;
}
@@ -92,11 +99,30 @@ class ModuleKnock : public Module
throw ModuleException("Could not add new modes!");
ServerInstance->AddCommand(&cmd);
+ ServerInstance->Modules->Attach(I_OnRehash, this);
+ OnRehash(NULL);
}
-
- virtual ~ModuleKnock()
+ void OnRehash(User* user)
{
+ std::string knocknotify = ServerInstance->Config->ConfValue("knock")->getString("notify");
+ irc::string notify(knocknotify.c_str());
+
+ if (notify == "numeric")
+ {
+ cmd.sendnotice = false;
+ cmd.sendnumeric = true;
+ }
+ else if (notify == "both")
+ {
+ cmd.sendnotice = true;
+ cmd.sendnumeric = true;
+ }
+ else
+ {
+ cmd.sendnotice = true;
+ cmd.sendnumeric = false;
+ }
}
virtual Version GetVersion()