summaryrefslogtreecommitdiff
path: root/modules/extra
diff options
context:
space:
mode:
Diffstat (limited to 'modules/extra')
-rw-r--r--modules/extra/cs_appendtopic.cpp13
-rw-r--r--modules/extra/cs_enforce.cpp14
-rw-r--r--modules/extra/cs_entrymsg.cpp6
-rw-r--r--modules/extra/cs_set_misc.cpp5
-rw-r--r--modules/extra/cs_tban.cpp18
-rw-r--r--modules/extra/db_mysql.cpp30
-rw-r--r--modules/extra/hs_request.cpp65
-rw-r--r--modules/extra/m_dnsbl.cpp10
-rw-r--r--modules/extra/ns_set_misc.cpp3
9 files changed, 91 insertions, 73 deletions
diff --git a/modules/extra/cs_appendtopic.cpp b/modules/extra/cs_appendtopic.cpp
index e8ccde22b..b98efeed6 100644
--- a/modules/extra/cs_appendtopic.cpp
+++ b/modules/extra/cs_appendtopic.cpp
@@ -50,15 +50,16 @@ class CommandCSAppendTopic : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
- Anope::string chan = params[0];
- Anope::string newtopic = params[1];
- ChannelInfo *ci = cs_findchan(chan);
- Channel *c = ci ? ci->c : NULL;
+ const Anope::string &newtopic = params[1];
+
+ User *u = source.u;
+ ChannelInfo *ci = source.ci;
+ Channel *c = ci->c;
if (!c)
- u->SendMessage(ChanServ, CHAN_X_NOT_IN_USE, chan.c_str());
+ u->SendMessage(ChanServ, CHAN_X_NOT_IN_USE, ci->name.c_str());
else if (!check_access(u, ci, CA_TOPIC))
u->SendMessage(ChanServ, ACCESS_DENIED);
else
diff --git a/modules/extra/cs_enforce.cpp b/modules/extra/cs_enforce.cpp
index 2d65422c6..4e21cf372 100644
--- a/modules/extra/cs_enforce.cpp
+++ b/modules/extra/cs_enforce.cpp
@@ -125,18 +125,16 @@ class CommandCSEnforce : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
- Anope::string chan = params[0];
- Anope::string what = params.size() > 1 ? params[1] : "";
- Channel *c = findchan(chan);
- ChannelInfo *ci;
+ const Anope::string &what = params.size() > 1 ? params[1] : "";
- if (c)
- ci = c->ci;
+ User *u = source.u;
+ ChannelInfo *ci = source.ci;
+ Channel *c = ci->c;
if (!c)
- u->SendMessage(ChanServ, CHAN_X_NOT_IN_USE, chan.c_str());
+ u->SendMessage(ChanServ, CHAN_X_NOT_IN_USE, ci->name.c_str());
else if (!check_access(u, ci, CA_AKICK))
u->SendMessage(ChanServ, ACCESS_DENIED);
else
diff --git a/modules/extra/cs_entrymsg.cpp b/modules/extra/cs_entrymsg.cpp
index e2143f7d1..4c6dee644 100644
--- a/modules/extra/cs_entrymsg.cpp
+++ b/modules/extra/cs_entrymsg.cpp
@@ -94,9 +94,11 @@ class CommandEntryMessage : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
- ChannelInfo *ci = cs_findchan(params[0]);
+ User *u = source.u;
+ ChannelInfo *ci = source.ci;
+
if (ci && (IsFounder(u, ci) || u->Account()->HasCommand("chanserv/entrymsg")))
{
bool success = true;
diff --git a/modules/extra/cs_set_misc.cpp b/modules/extra/cs_set_misc.cpp
index c5f11ca29..0ed913b69 100644
--- a/modules/extra/cs_set_misc.cpp
+++ b/modules/extra/cs_set_misc.cpp
@@ -20,9 +20,10 @@ class CommandCSSetMisc : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
- ChannelInfo *ci = cs_findchan(params[0]);
+ User *u = source.u;
+ ChannelInfo *ci = source.ci;
if (!ci)
throw CoreException("NULL ci in CommandCSSetMisc");
diff --git a/modules/extra/cs_tban.cpp b/modules/extra/cs_tban.cpp
index 444681262..a037c8243 100644
--- a/modules/extra/cs_tban.cpp
+++ b/modules/extra/cs_tban.cpp
@@ -58,23 +58,25 @@ class CommandCSTBan : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
- Anope::string mask;
- Channel *c;
- User *u2 = NULL;
+ User *u = source.u;
+ ChannelInfo *ci = source.ci;
+ Channel *c = ci->c;
- Anope::string chan = params[0];
- Anope::string nick = params[1];
- Anope::string time = params[2];
+ const Anope::string &chan = params[0];
+ const Anope::string &nick = params[1];
+ const Anope::string &time = params[2];
- if (!(c = findchan(chan)))
+ User *u2;
+ if (!c)
u->SendMessage(ChanServ, CHAN_X_NOT_IN_USE, chan.c_str());
else if (!(u2 = finduser(nick)))
u->SendMessage(ChanServ, NICK_X_NOT_IN_USE, nick.c_str());
else
if (CanBanUser(c, u, u2))
{
+ Anope::string mask;
get_idealban(c->ci, u2, mask);
c->SetMode(NULL, CMODE_BAN, mask);
new TempBan(dotime(time), c, mask);
diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp
index bd1810f94..8298fcbdf 100644
--- a/modules/extra/db_mysql.cpp
+++ b/modules/extra/db_mysql.cpp
@@ -311,7 +311,7 @@ class CommandSQLSync : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params);
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params);
bool OnHelp(User *u, const Anope::string &subcommand)
{
@@ -979,14 +979,18 @@ class DBMySQL : public Module
return EVENT_CONTINUE;
}
- void OnPostCommand(User *u, BotInfo *service, const Anope::string &command, const std::vector<Anope::string> &params)
+ void OnPostCommand(CommandSource &source, Command *command, const std::vector<Anope::string> &params)
{
+ User *u = source.u;
+ BotInfo *service = command->service;
+ ChannelInfo *ci = source.ci;
+
if (service == NickServ)
{
- if (u->Account() && ((command.equals_ci("SET") && !params.empty()) || (command.equals_ci("SASET") && u->Account()->HasCommand("nickserv/saset") && params.size() > 1)))
+ if (u->Account() && ((command->name.equals_ci("SET") && !params.empty()) || (command->name.equals_ci("SASET") && u->Account()->HasCommand("nickserv/saset") && params.size() > 1)))
{
- Anope::string cmd = (command == "SET" ? params[0] : params[1]);
- NickCore *nc = (command == "SET" ? u->Account() : findcore(params[0]));
+ Anope::string cmd = (command->name.equals_ci("SET") ? params[0] : params[1]);
+ NickCore *nc = (command->name.equals_ci("SET") ? u->Account() : findcore(params[0]));
if (!nc)
return;
if (cmd.equals_ci("PASSWORD") && params.size() > 1)
@@ -1013,9 +1017,8 @@ class DBMySQL : public Module
}
else if (service == ChanServ)
{
- if (command.equals_ci("SET") && u->Account() && params.size() > 1)
+ if (command->name.equals_ci("SET") && u->Account() && params.size() > 1)
{
- ChannelInfo *ci = cs_findchan(params[0]);
if (!ci)
return;
if (!u->Account()->HasPriv("chanserv/set") && check_access(u, ci, CA_SET))
@@ -1051,9 +1054,8 @@ class DBMySQL : public Module
}
else if (service == BotServ)
{
- if (command.equals_ci("KICK") && params.size() > 2)
+ if (command->name.equals_ci("KICK") && params.size() > 2)
{
- ChannelInfo *ci = cs_findchan(params[0]);
if (!ci)
return;
if (!check_access(u, ci, CA_SET) && !u->Account()->HasPriv("botserv/administration"))
@@ -1083,9 +1085,8 @@ class DBMySQL : public Module
}
}
}
- else if (command.equals_ci("SET") && params.size() > 2)
+ else if (command->name.equals_ci("SET") && params.size() > 2)
{
- ChannelInfo *ci = cs_findchan(params[0]);
if (ci && !check_access(u, ci, CA_SET) && !u->Account()->HasPriv("botserv/administration"))
return;
BotInfo *bi = NULL;
@@ -1105,11 +1106,11 @@ class DBMySQL : public Module
}
else if (service == MemoServ)
{
- if (command.equals_ci("IGNORE") && params.size() > 0)
+ if (command->name.equals_ci("IGNORE") && params.size() > 0)
{
Anope::string target = params[0];
NickCore *nc = NULL;
- ChannelInfo *ci = NULL;
+ ci = NULL;
if (target[0] != '#')
{
target = u->nick;
@@ -1609,8 +1610,9 @@ static void SaveDatabases()
me->OnExceptionAdd(NULL, exceptions[i]);
}
-CommandReturn CommandSQLSync::Execute(User *u, const std::vector<Anope::string> &params)
+CommandReturn CommandSQLSync::Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
+ User *u = source.u;
SaveDatabases();
u->SendMessage(OperServ, OPER_SYNC_UPDATED);
return MOD_CONT;
diff --git a/modules/extra/hs_request.cpp b/modules/extra/hs_request.cpp
index 9ae097d27..031fa72b7 100644
--- a/modules/extra/hs_request.cpp
+++ b/modules/extra/hs_request.cpp
@@ -49,12 +49,12 @@ class CommandHSRequest : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
- Anope::string nick = u->nick;
+ User *u = source.u;
+
Anope::string rawhostmask = params[0];
Anope::string hostmask;
- NickAlias *na;
Anope::string vIdent = myStrGetToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */
if (!vIdent.empty())
@@ -97,22 +97,17 @@ class CommandHSRequest : public Command
return MOD_CONT;
}
- if ((na = findnick(nick)))
+ if (HSRequestMemoOper && Config->MSSendDelay > 0 && u && u->lastmemosend + Config->MSSendDelay > Anope::CurTime)
{
- if (HSRequestMemoOper && Config->MSSendDelay > 0 && u && u->lastmemosend + Config->MSSendDelay > Anope::CurTime)
- {
- me->SendMessage(HostServ, u, _("Please wait %d seconds before requesting a new vHost"), Config->MSSendDelay);
- u->lastmemosend = Anope::CurTime;
- return MOD_CONT;
- }
- my_add_host_request(nick, vIdent, hostmask, u->nick, Anope::CurTime);
-
- me->SendMessage(HostServ, u, _("Your vHost has been requested"));
- req_send_memos(u, vIdent, hostmask);
- Log(LOG_COMMAND, u, this, NULL) << "to request new vhost " << (!vIdent.empty() ? vIdent + "@" : "") << hostmask;
+ me->SendMessage(HostServ, u, _("Please wait %d seconds before requesting a new vHost"), Config->MSSendDelay);
+ u->lastmemosend = Anope::CurTime;
+ return MOD_CONT;
}
- else
- u->SendMessage(HostServ, HOST_NOREG, nick.c_str());
+ my_add_host_request(u->nick, vIdent, hostmask, u->nick, Anope::CurTime);
+
+ me->SendMessage(HostServ, u, _("Your vHost has been requested"));
+ req_send_memos(u, vIdent, hostmask);
+ Log(LOG_COMMAND, u, this, NULL) << "to request new vhost " << (!vIdent.empty() ? vIdent + "@" : "") << hostmask;
return MOD_CONT;
}
@@ -145,12 +140,14 @@ class CommandHSActivate : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
- Anope::string nick = params[0];
- NickAlias *na;
+ User *u = source.u;
- if ((na = findnick(nick)))
+ const Anope::string &nick = params[0];
+
+ NickAlias *na = findnick(nick);
+ if (na)
{
RequestMap::iterator it = Requests.find(na->nick);
if (it != Requests.end())
@@ -205,10 +202,12 @@ class CommandHSReject : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
- Anope::string nick = params[0];
- Anope::string reason = params.size() > 1 ? params[1] : "";
+ User *u = source.u;
+
+ const Anope::string &nick = params[0];
+ const Anope::string &reason = params.size() > 1 ? params[1] : "";
RequestMap::iterator it = Requests.find(nick);
if (it != Requests.end())
@@ -297,9 +296,9 @@ class CommandHSWaiting : public HSListBase
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
- return this->DoList(u);
+ return this->DoList(source.u);
}
bool OnHelp(User *u, const Anope::string &subcommand)
@@ -351,7 +350,7 @@ class HSRequest : public Module
EventReturn OnPreCommand(User *u, BotInfo *service, const Anope::string &command, const std::vector<Anope::string> &params)
{
- if (!Config->s_HostServ.empty() && service == findbot(Config->s_HostServ))
+ if (service == HostServ)
{
if (command.equals_ci("LIST"))
{
@@ -361,12 +360,20 @@ class HSRequest : public Module
{
std::vector<Anope::string> emptyParams;
Command *c = FindCommand(HostServ, "WAITING");
- c->Execute(u, emptyParams);
+ if (!c)
+ throw CoreException("No waiting command?");
+ CommandSource source;
+ source.u = u;
+ source.ci = NULL;
+ source.owner = service;
+ source.service = service;
+ source.fantasy = false;
+ c->Execute(source, emptyParams);
return EVENT_STOP;
}
}
}
- else if (service == findbot(Config->s_NickServ))
+ else if (service == NickServ)
{
if (command.equals_ci("DROP"))
{
diff --git a/modules/extra/m_dnsbl.cpp b/modules/extra/m_dnsbl.cpp
index a9351d35e..b363d3503 100644
--- a/modules/extra/m_dnsbl.cpp
+++ b/modules/extra/m_dnsbl.cpp
@@ -7,6 +7,12 @@
#include "module.h"
+struct FakeAkill : public Command
+{
+ FakeAkill() : Command("AKILL", 0, 0) { this->service = OperServ; }
+ CommandReturn Execute(CommandSource &, const std::vector<Anope::string> &) { return MOD_CONT; }
+} fake_akill;
+
struct Blacklist
{
Anope::string name;
@@ -56,9 +62,7 @@ class DNSBLResolver : public DNSRequest
XLine *x = NULL;
if (this->add_to_akill && SGLine && (x = SGLine->Add(NULL, NULL, Anope::string("*@") + user->host, Anope::CurTime + this->blacklist.bantime, reason)))
{
- static Command command_akill("AKILL", 0);
- command_akill.service = OperServ;
- Log(LOG_COMMAND, OperServ, &command_akill) << "for " << user->GetMask() << " (Listed in " << this->blacklist.name << ")";
+ Log(LOG_COMMAND, OperServ, &fake_akill) << "for " << user->GetMask() << " (Listed in " << this->blacklist.name << ")";
/* If AkillOnAdd is disabled send it anyway, noone wants bots around... */
if (!Config->AkillOnAdd)
ircdproto->SendAkill(x);
diff --git a/modules/extra/ns_set_misc.cpp b/modules/extra/ns_set_misc.cpp
index 71ba9834f..f7a2f815f 100644
--- a/modules/extra/ns_set_misc.cpp
+++ b/modules/extra/ns_set_misc.cpp
@@ -23,8 +23,9 @@ class CommandNSSetMisc : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
+ User *u = source.u;
NickAlias *na = findnick(params[0]);
if (!na)
throw CoreException("NULL na in CommandNSSetMisc");