#include "inspircd.h"
-/* $ModDesc: Provides aliases of commands. */
-
/** An alias definition
*/
class Alias
/* whether or not +B users are allowed to use fantasy commands */
bool AllowBots;
+ UserModeReference botmode;
- void ReadAliases()
+ public:
+ void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
ConfigTag* fantasy = ServerInstance->Config->ConfValue("fantasy");
AllowBots = fantasy->getBool("allowbots", false);
}
}
- public:
- void init() CXX11_OVERRIDE
+ ModuleAlias()
+ : botmode(this, "bot")
{
- ReadAliases();
- Implementation eventlist[] = { I_OnPreCommand, I_OnRehash, I_OnUserMessage };
- ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
Version GetVersion() CXX11_OVERRIDE
}
/* Stop here if the user is +B and allowbot is set to no. */
- if (!AllowBots && user->IsModeSet('B'))
+ if (!AllowBots && user->IsModeSet(botmode))
{
return;
}
}
- int DoAlias(User *user, Channel *c, Alias *a, const std::string compare, const std::string safe)
+ int DoAlias(User *user, Channel *c, Alias *a, const std::string& compare, const std::string& safe)
{
User *u = NULL;
u = ServerInstance->FindNick(a->RequiredNick);
if (!u)
{
- user->WriteNumeric(401, ""+user->nick+" "+a->RequiredNick+" :is currently unavailable. Please try again later.");
+ user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is currently unavailable. Please try again later.");
return 1;
}
}
if (!ServerInstance->ULine(u->server))
{
ServerInstance->SNO->WriteToSnoMask('a', "NOTICE -- Service "+a->RequiredNick+" required by alias "+std::string(a->AliasedCommand.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
- user->WriteNumeric(401, ""+user->nick+" "+a->RequiredNick+" :is an imposter! Please inform an IRC operator as soon as possible.");
+ user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is an imposter! Please inform an IRC operator as soon as possible.");
return 1;
}
}
void DoCommand(const std::string& newline, User* user, Channel *chan, const std::string &original_line)
{
std::string result;
- result.reserve(MAXBUF);
+ result.reserve(newline.length());
for (unsigned int i = 0; i < newline.length(); i++)
{
char c = newline[i];
std::string command, token;
ss.GetToken(command);
- while (ss.GetToken(token) && (pars.size() <= MAXPARAMETERS))
+ while (ss.GetToken(token))
{
pars.push_back(token);
}
ServerInstance->Parser->CallHandler(command, pars, user);
}
- void OnRehash(User* user) CXX11_OVERRIDE
- {
- ReadAliases();
- }
-
void Prioritize()
{
// Prioritise after spanningtree so that channel aliases show the alias before the effects.