summaryrefslogtreecommitdiff
path: root/modules/extra/hs_request.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-04-22 03:16:11 -0400
committerAdam <Adam@anope.org>2011-05-16 04:06:17 -0400
commitc8c23158a4ff74822d6c7d201dc53d879e3d91e8 (patch)
tree4bc9ae029691d5e7c03ebc1481683a010b733844 /modules/extra/hs_request.cpp
parent1782ce260c5bc214ec0b2e39257ab1371b68ae9c (diff)
Moved the core pseudo clients out into their own modules
Diffstat (limited to 'modules/extra/hs_request.cpp')
-rw-r--r--modules/extra/hs_request.cpp47
1 files changed, 26 insertions, 21 deletions
diff --git a/modules/extra/hs_request.cpp b/modules/extra/hs_request.cpp
index 4978035d3..f208d72b3 100644
--- a/modules/extra/hs_request.cpp
+++ b/modules/extra/hs_request.cpp
@@ -16,6 +16,8 @@
*/
#include "module.h"
+#include "hostserv.h"
+#include "memoserv.h"
static bool HSRequestMemoUser = false;
static bool HSRequestMemoOper = false;
@@ -152,8 +154,8 @@ class CommandHSActivate : public Command
na->hostinfo.SetVhost(it->second->ident, it->second->host, u->nick, it->second->time);
FOREACH_MOD(I_OnSetVhost, OnSetVhost(na));
- if (HSRequestMemoUser)
- memo_send(source, na->nick, _("[auto memo] Your requested vHost has been approved."), 2);
+ if (HSRequestMemoUser && memoserv)
+ memoserv->Send(Config->s_HostServ, na->nick, _("[auto memo] Your requested vHost has been approved."), true);
me->SendMessage(source, _("vHost for %s has been activated"), na->nick.c_str());
Log(LOG_COMMAND, u, this, NULL) << "for " << na->nick << " for vhost " << (!it->second->ident.empty() ? it->second->ident + "@" : "") << it->second->host;
@@ -207,15 +209,15 @@ class CommandHSReject : public Command
delete it->second;
Requests.erase(it);
- if (HSRequestMemoUser)
+ if (HSRequestMemoUser && memoserv)
{
- char message[BUFSIZE];
+ Anope::string message;
if (!reason.empty())
- snprintf(message, sizeof(message), _("[auto memo] Your requested vHost has been rejected. Reason: %s"), reason.c_str());
+ message = Anope::printf(_("[auto memo] Your requested vHost has been rejected. Reason: %s"), reason.c_str());
else
- snprintf(message, sizeof(message), "%s", _("[auto memo] Your requested vHost has been rejected."));
+ message = _("[auto memo] Your requested vHost has been rejected.");
- memo_send(source, nick, message, 2);
+ memoserv->Send(Config->s_HostServ, nick, message, true);
}
me->SendMessage(source, _("vHost for %s has been rejected"), nick.c_str());
@@ -312,18 +314,21 @@ class HSRequest : public Module
{
me = this;
- this->AddCommand(HostServ, &commandhsrequest);
- this->AddCommand(HostServ, &commandhsactive);
- this->AddCommand(HostServ, &commandhsreject);
- this->AddCommand(HostServ, &commandhswaiting);
+ if (!hostserv)
+ throw ModuleException("HostServ is not loaded!");
+
+ this->AddCommand(hostserv->Bot(), &commandhsrequest);
+ this->AddCommand(hostserv->Bot(), &commandhsactive);
+ this->AddCommand(hostserv->Bot(), &commandhsreject);
+ this->AddCommand(hostserv->Bot(), &commandhswaiting);
this->SetAuthor("Anope");
this->SetType(SUPPORTED);
- this->OnReload(false);
-
Implementation i[] = { I_OnPreCommand, I_OnDatabaseRead, I_OnDatabaseWrite, I_OnReload };
ModuleManager::Attach(i, this, 4);
+
+ this->OnReload();
}
~HSRequest()
@@ -339,7 +344,7 @@ class HSRequest : public Module
EventReturn OnPreCommand(CommandSource &source, Command *command, const std::vector<Anope::string> &params)
{
BotInfo *service = source.owner;
- if (service == HostServ)
+ if (service->nick == Config->s_HostServ)
{
if (command->name.equals_ci("LIST"))
{
@@ -348,7 +353,7 @@ class HSRequest : public Module
if (!key.empty() && key.equals_ci("+req"))
{
std::vector<Anope::string> emptyParams;
- Command *c = FindCommand(HostServ, "WAITING");
+ Command *c = FindCommand(hostserv->Bot(), "WAITING");
if (!c)
throw CoreException("No waiting command?");
c->Execute(source, emptyParams);
@@ -356,7 +361,7 @@ class HSRequest : public Module
}
}
}
- else if (service == NickServ)
+ else if (service->nick == Config->s_NickServ)
{
if (command->name.equals_ci("DROP"))
{
@@ -402,7 +407,7 @@ class HSRequest : public Module
}
}
- void OnReload(bool)
+ void OnReload()
{
ConfigReader config;
HSRequestMemoUser = config.ReadFlag("hs_request", "memouser", "no", 0);
@@ -422,7 +427,7 @@ void req_send_memos(CommandSource &source, const Anope::string &vIdent, const An
else
host = vHost;
- if (HSRequestMemoOper == 1)
+ if (HSRequestMemoOper == 1 && memoserv)
for (unsigned i = 0; i < Config->Opers.size(); ++i)
{
Oper *o = Config->Opers[i];
@@ -431,9 +436,9 @@ void req_send_memos(CommandSource &source, const Anope::string &vIdent, const An
if (!na)
continue;
- char message[BUFSIZE];
- snprintf(message, sizeof(message), _("[auto memo] vHost \002%s\002 has been requested."), host.c_str());
- memo_send(source, na->nick, message, 2);
+ Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.u->GetMask().c_str());
+
+ memoserv->Send(Config->s_HostServ, na->nick, message, true);
}
}