diff options
153 files changed, 1028 insertions, 1059 deletions
diff --git a/include/commands.h b/include/commands.h index cfd46d644..d644ea8cb 100644 --- a/include/commands.h +++ b/include/commands.h @@ -33,11 +33,23 @@ struct CommandInfo Anope::string permission; }; +struct CommandReply +{ + virtual void SendMessage(const BotInfo *source, const Anope::string &msg) = 0; +}; + /* The source for a command */ -struct CoreExport CommandSource +class CoreExport CommandSource { - /* User executing the command */ + /* The nick executing the command */ + Anope::string nick; + /* User executing the command, may be NULL */ User *u; + public: + /* The account executing the command */ + NickCore *nc; + /* Where the reply should go */ + CommandReply *reply; /* Channel the command was executed on (fantasy) */ Channel *c; /* The service this command is on */ @@ -49,8 +61,20 @@ struct CoreExport CommandSource /* The permission of the command being executed */ Anope::string permission; + CommandSource(const Anope::string &n, User *user, NickCore *core, CommandReply *reply); + + const Anope::string &GetNick() const; + User *GetUser() const; + AccessGroup AccessFor(ChannelInfo *ci) const; + bool IsFounder(ChannelInfo *ci) const; + void Reply(const char *message, ...); void Reply(const Anope::string &message); + + bool HasCommand(const Anope::string &cmd); + bool HasPriv(const Anope::string &cmd); + bool IsServicesOper() const; + bool IsOper() const; }; /** Every services command is a class, inheriting from Command. @@ -118,4 +142,6 @@ class CoreExport Command : public Service, public Flags<CommandFlag> virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand); }; +extern void RunCommand(CommandSource &source, const Anope::string &message); + #endif // COMMANDS_H diff --git a/include/lists.h b/include/lists.h index 308080c93..841faf7a9 100644 --- a/include/lists.h +++ b/include/lists.h @@ -81,11 +81,11 @@ class CoreExport ListFormatter */ class CoreExport InfoFormatter { - User *user; + NickCore *nc; std::vector<std::pair<Anope::string, Anope::string> > replies; unsigned longest; public: - InfoFormatter(User *u); + InfoFormatter(NickCore *nc); void Process(std::vector<Anope::string> &); Anope::string &operator[](const Anope::string &key); }; diff --git a/include/logger.h b/include/logger.h index 8cb54a754..9364cfb7c 100644 --- a/include/logger.h +++ b/include/logger.h @@ -50,6 +50,7 @@ class CoreExport Log public: const BotInfo *bi; const User *u; + const NickCore *nc; Command *c; Channel *chan; const ChannelInfo *ci; @@ -63,7 +64,7 @@ class CoreExport Log Log(LogType type = LOG_NORMAL, const Anope::string &category = "", const BotInfo *bi = NULL); /* LOG_COMMAND/OVERRIDE/ADMIN */ - Log(LogType type, const User *u, Command *c, const ChannelInfo *ci = NULL); + Log(LogType type, const CommandSource &source, Command *c, const ChannelInfo *ci = NULL); /* LOG_CHANNEL */ Log(const User *u, Channel *c, const Anope::string &category = ""); diff --git a/include/modules.h b/include/modules.h index d44cbf8d9..ae7ab139a 100644 --- a/include/modules.h +++ b/include/modules.h @@ -499,25 +499,25 @@ class CoreExport Module : public Extensible virtual EventReturn OnExceptionAdd(Exception *ex) { return EVENT_CONTINUE; } /** Called before an exception is deleted - * @param u The user who is deleting it + * @param source The source deleting it * @param ex The exceotion */ - virtual void OnExceptionDel(User *u, Exception *ex) { } + virtual void OnExceptionDel(CommandSource &source, Exception *ex) { } /** Called before a XLine is added - * @param u The user adding the XLine + * @param source The source of the XLine * @param x The XLine * @param xlm The xline manager it was added to * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnAddXLine(User *u, const XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; } + virtual EventReturn OnAddXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; } /** Called before a XLine is deleted - * @param u The user deleting the XLine + * @param source The source of the XLine * @param x The XLine * @param xlm The xline manager it was deleted from */ - virtual void OnDelXLine(User *u, const XLine *x, XLineManager *xlm) { } + virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { } /** Called when a user is checked for whether they are a services oper * @param u The user @@ -558,31 +558,31 @@ class CoreExport Module : public Extensible /** Called when access is deleted from a channel * @param ci The channel - * @param u The user who removed the access + * @param source The source of the command * @param access The access entry being removed */ - virtual void OnAccessDel(ChannelInfo *ci, User *u, ChanAccess *access) { } + virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { } /** Called when access is added * @param ci The channel - * @param u The user who added the access + * @param source The source of the command * @param access The access changed */ - virtual void OnAccessAdd(ChannelInfo *ci, User *u, ChanAccess *access) { } + virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { } /** Called when the access list is cleared * @param ci The channel * @param u The user who cleared the access */ - virtual void OnAccessClear(ChannelInfo *ci, User *u) { } + virtual void OnAccessClear(ChannelInfo *ci, CommandSource &source) { } /** Called when a level for a channel is changed - * @param u The user changing the level + * @param source The source of the command * @param ci The channel the level was changed on * @param priv The privilege changed * @param what The new level */ - virtual void OnLevelChange(User *u, ChannelInfo *ci, const Anope::string &priv, int16_t what) { } + virtual void OnLevelChange(CommandSource &source, ChannelInfo *ci, const Anope::string &priv, int16_t what) { } /** Called right before a channel is dropped * @param ci The channel @@ -625,18 +625,18 @@ class CoreExport Module : public Extensible virtual void OnChannelDelete(Channel *c) { } /** Called after adding an akick to a channel - * @param u The user adding the akick + * @param source The source of the command * @param ci The channel * @param ak The akick */ - virtual void OnAkickAdd(User *u, ChannelInfo *ci, const AutoKick *ak) { } + virtual void OnAkickAdd(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { } /** Called before removing an akick from a channel - * @param u The user removing the akick + * @param source The source of the command * @param ci The channel * @param ak The akick */ - virtual void OnAkickDel(User *u, ChannelInfo *ci, const AutoKick *ak) { } + virtual void OnAkickDel(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { } /** Called after a user join a channel when we decide whether to kick them or not * @param u The user @@ -669,10 +669,10 @@ class CoreExport Module : public Extensible virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) { return EVENT_CONTINUE; } /** Called when a nick is dropped - * @param u The user dropping the nick + * @param source The source of the command * @param na The nick */ - virtual void OnNickDrop(User *u, NickAlias *na) { } + virtual void OnNickDrop(CommandSource &source, NickAlias *na) { } /** Called when a nick is forbidden * @param na The nick alias of the forbidden nick diff --git a/include/users.h b/include/users.h index e69c9d30b..d0b38025e 100644 --- a/include/users.h +++ b/include/users.h @@ -12,6 +12,7 @@ #include "modes.h" #include "extensible.h" #include "serialize.h" +#include "commands.h" extern CoreExport Anope::insensitive_map<User *> UserListByNick; extern CoreExport Anope::map<User *> UserListByUID; @@ -37,7 +38,7 @@ typedef std::list<ChannelContainer *> UChannelList; /* Online user and channel data. */ -class CoreExport User : public virtual Base, public Extensible +class CoreExport User : public virtual Base, public Extensible, public CommandReply { protected: Anope::string vident; @@ -161,7 +162,7 @@ class CoreExport User : public virtual Base, public Extensible * @param ... any number of parameters */ void SendMessage(const BotInfo *source, const char *fmt, ...); - virtual void SendMessage(const BotInfo *source, Anope::string msg); + void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override; /** Collide a nick * See the comment in users.cpp @@ -194,13 +195,13 @@ class CoreExport User : public virtual Base, public Extensible * @param CheckNick True to check if the user is identified to the nickname they are on too * @return true or false */ - virtual bool IsIdentified(bool CheckNick = false) const; + bool IsIdentified(bool CheckNick = false) const; /** Check if the user is recognized for their nick (on the nicks access list) * @param CheckSecure Only returns true if the user has secure off * @return true or false */ - virtual bool IsRecognized(bool CheckSecure = true) const; + bool IsRecognized(bool CheckSecure = true) const; /** Check if the user is a services oper * @return true if they are an oper diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index 5c1691047..874c40015 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -27,8 +27,6 @@ class CommandBSAssign : public Command const Anope::string &chan = params[0]; const Anope::string &nick = params[1]; - User *u = source.u; - if (readonly) { source.Reply(BOT_ASSIGN_READONLY); @@ -49,13 +47,14 @@ class CommandBSAssign : public Command return; } - if (ci->botflags.HasFlag(BS_NOBOT) || (!ci->AccessFor(u).HasPriv("ASSIGN") && !u->HasPriv("botserv/administration"))) + AccessGroup access = source.AccessFor(ci); + if (ci->botflags.HasFlag(BS_NOBOT) || (!access.HasPriv("ASSIGN") && !source.HasPriv("botserv/administration"))) { source.Reply(ACCESS_DENIED); return; } - if (bi->HasFlag(BI_PRIVATE) && !u->HasCommand("botserv/assign/private")) + if (bi->HasFlag(BI_PRIVATE) && !source.HasCommand("botserv/assign/private")) { source.Reply(ACCESS_DENIED); return; @@ -67,10 +66,10 @@ class CommandBSAssign : public Command return; } - bool override = !ci->AccessFor(u).HasPriv("ASSIGN"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << bi->nick; + bool override = !access.HasPriv("ASSIGN"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << bi->nick; - bi->Assign(u, ci); + bi->Assign(source.GetUser(), ci); source.Reply(_("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), ci->name.c_str()); } @@ -96,8 +95,6 @@ class CommandBSUnassign : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - if (readonly) { source.Reply(BOT_ASSIGN_READONLY); @@ -111,7 +108,8 @@ class CommandBSUnassign : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("ASSIGN")) + AccessGroup access = source.AccessFor(ci); + if (!source.HasPriv("botserv/administration") && !access.HasPriv("ASSIGN")) { source.Reply(ACCESS_DENIED); return; @@ -129,10 +127,10 @@ class CommandBSUnassign : public Command return; } - bool override = !ci->AccessFor(u).HasPriv("ASSIGN"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << ci->bi->nick; + bool override = !access.HasPriv("ASSIGN"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << ci->bi->nick; - ci->bi->UnAssign(u, ci); + ci->bi->UnAssign(source.GetUser(), ci); source.Reply(_("There is no bot assigned to %s anymore."), ci->name.c_str()); } diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index eaf00d347..30de67d29 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -24,7 +24,7 @@ class BadwordsDelCallback : public NumberList public: BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), Deleted(0), override(false) { - if (!ci->AccessFor(source.u).HasPriv("BADWORDS") && source.u->HasPriv("botserv/administration")) + if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration")) this->override = true; } @@ -43,7 +43,7 @@ class BadwordsDelCallback : public NumberList if (!Number || Number > ci->GetBadWordCount()) return; - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word; ++Deleted; ci->EraseBadWord(Number - 1); } @@ -54,8 +54,8 @@ class CommandBSBadwords : public Command private: void DoList(CommandSource &source, ChannelInfo *ci, const Anope::string &word) { - bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "LIST"; + bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST"; ListFormatter list; list.addColumn("Number").addColumn("Word").addColumn("Type"); @@ -163,8 +163,8 @@ class CommandBSBadwords : public Command } } - bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "ADD " << realword; + bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ADD " << realword; ci->AddBadWord(realword, bwtype); source.Reply(_("\002%s\002 added to %s bad words list."), realword.c_str(), ci->name.c_str()); @@ -199,8 +199,8 @@ class CommandBSBadwords : public Command return; } - bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "DEL " << badword->word; + bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "DEL " << badword->word; source.Reply(_("\002%s\002 deleted from %s bad words list."), badword->word.c_str(), ci->name.c_str()); @@ -212,8 +212,8 @@ class CommandBSBadwords : public Command void DoClear(CommandSource &source, ChannelInfo *ci) { - bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "CLEAR"; + bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "CLEAR"; ci->ClearBadWords(); source.Reply(_("Bad words list is now empty.")); @@ -233,7 +233,6 @@ class CommandBSBadwords : public Command { const Anope::string &cmd = params[1]; const Anope::string &word = params.size() > 2 ? params[2] : ""; - User *u = source.u; bool need_args = cmd.equals_ci("LIST") || cmd.equals_ci("CLEAR"); if (!need_args && word.empty()) @@ -249,8 +248,7 @@ class CommandBSBadwords : public Command return; } - - if (!ci->AccessFor(u).HasPriv("BADWORDS") && (!need_args || !u->HasPriv("botserv/administration"))) + if (!source.AccessFor(ci).HasPriv("BADWORDS") && (!need_args || !source.HasPriv("botserv/administration"))) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index b1f22909f..0b45ee71c 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -94,7 +94,7 @@ class CommandBSBot : public Command BotInfo *bi = new BotInfo(nick, user, host, real); - Log(LOG_ADMIN, source.u, this) << "ADD " << bi->GetMask() << " " << bi->realname; + Log(LOG_ADMIN, source, this) << "ADD " << bi->GetMask() << " " << bi->realname; source.Reply(_("%s!%s@%s (%s) added to the bot list."), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); @@ -253,7 +253,7 @@ class CommandBSBot : public Command } source.Reply(_("Bot \002%s\002 has been changed to %s!%s@%s (%s)"), oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); - Log(LOG_ADMIN, source.u, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; + Log(LOG_ADMIN, source, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; FOREACH_MOD(I_OnBotChange, OnBotChange(bi)); return; @@ -284,7 +284,7 @@ class CommandBSBot : public Command FOREACH_MOD(I_OnBotDelete, OnBotDelete(bi)); - Log(LOG_ADMIN, source.u, this) << "DEL " << bi->nick; + Log(LOG_ADMIN, source, this) << "DEL " << bi->nick; source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str()); bi->destroy(); @@ -302,7 +302,6 @@ class CommandBSBot : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { const Anope::string &cmd = params[0]; - User *u = source.u; if (readonly) { @@ -313,7 +312,7 @@ class CommandBSBot : public Command if (cmd.equals_ci("ADD")) { // ADD nick user host real - 5 - if (!u->HasCommand("botserv/bot/add")) + if (!source.HasCommand("botserv/bot/add")) { source.Reply(ACCESS_DENIED); return; @@ -336,7 +335,7 @@ class CommandBSBot : public Command { // CHANGE oldn newn user host real - 6 // but only oldn and newn are required - if (!u->HasCommand("botserv/bot/change")) + if (!source.HasCommand("botserv/bot/change")) { source.Reply(ACCESS_DENIED); return; @@ -353,7 +352,7 @@ class CommandBSBot : public Command else if (cmd.equals_ci("DEL")) { // DEL nick - if (!u->HasCommand("botserv/bot/del")) + if (!source.HasCommand("botserv/bot/del")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp index 9fd8b81f7..176040b10 100644 --- a/modules/commands/bs_botlist.cpp +++ b/modules/commands/bs_botlist.cpp @@ -24,7 +24,6 @@ class CommandBSBotList : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; unsigned count = 0; ListFormatter list; @@ -34,7 +33,7 @@ class CommandBSBotList : public Command { BotInfo *bi = it->second; - if (u->HasCommand("botserv/botlist") || !bi->HasFlag(BI_PRIVATE)) + if (source.HasCommand("botserv/botlist") || !bi->HasFlag(BI_PRIVATE)) { ++count; ListFormatter::ListEntry entry; diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 6ca435b37..6957d0a78 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -26,8 +26,6 @@ class CommandBSSay : public Command { const Anope::string &text = params[1]; - User *u = source.u; - ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -35,7 +33,7 @@ class CommandBSSay : public Command return; } - if (!ci->AccessFor(u).HasPriv("SAY")) + if (!source.AccessFor(ci).HasPriv("SAY")) { source.Reply(ACCESS_DENIED); return; @@ -63,7 +61,7 @@ class CommandBSSay : public Command ci->bi->lastmsg = Anope::CurTime; // XXX need a way to find if someone is overriding this - Log(LOG_COMMAND, u, this, ci) << text; + Log(LOG_COMMAND, source, this, ci) << text; return; } @@ -88,7 +86,6 @@ class CommandBSAct : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; Anope::string message = params[1]; ChannelInfo *ci = cs_findchan(params[0]); @@ -98,7 +95,7 @@ class CommandBSAct : public Command return; } - if (!ci->AccessFor(u).HasPriv("SAY")) + if (!source.AccessFor(ci).HasPriv("SAY")) { source.Reply(ACCESS_DENIED); return; @@ -124,7 +121,7 @@ class CommandBSAct : public Command ci->bi->lastmsg = Anope::CurTime; // XXX Need to be able to find if someone is overriding this. - Log(LOG_COMMAND, u, this, ci) << message; + Log(LOG_COMMAND, source, this, ci) << message; return; } diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index 251bd84df..d5b2693ad 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -59,10 +59,9 @@ class CommandBSInfo : public Command { const Anope::string &query = params[0]; - User *u = source.u; const BotInfo *bi = findbot(query); ChannelInfo *ci; - InfoFormatter info(u); + InfoFormatter info(source.nc); if (bi) { @@ -79,7 +78,7 @@ class CommandBSInfo : public Command for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); - if (u->HasPriv("botserv/administration")) + if (source.HasPriv("botserv/administration")) { std::vector<Anope::string> buf; this->send_bot_channels(buf, bi); @@ -90,7 +89,7 @@ class CommandBSInfo : public Command } else if ((ci = cs_findchan(query))) { - if (!ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasPriv("botserv/administration")) + if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("botserv/administration")) { source.Reply(ACCESS_DENIED); return; @@ -99,8 +98,8 @@ class CommandBSInfo : public Command source.Reply(CHAN_INFO_HEADER, ci->name.c_str()); info[_("Bot nick")] = ci->bi ? ci->bi->nick : "not assigned yet"; - Anope::string enabled = translate(u, _("Enabled")); - Anope::string disabled = translate(u, _("Disabled")); + Anope::string enabled = translate(source.nc, _("Enabled")); + Anope::string disabled = translate(source.nc, _("Disabled")); if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) { @@ -203,11 +202,11 @@ class CommandBSInfo : public Command info[_("AMSG kicker")] = disabled; Anope::string flags; - CheckOptStr(flags, BS_DONTKICKOPS, _("Ops protection"), ci->botflags, u->Account()); - CheckOptStr(flags, BS_DONTKICKVOICES, _("Voices protection"), ci->botflags, u->Account()); - CheckOptStr(flags, BS_FANTASY, _("Fantasy"), ci->botflags, u->Account()); - CheckOptStr(flags, BS_GREET, _("Greet"), ci->botflags, u->Account()); - CheckOptStr(flags, BS_NOBOT, _("No bot"), ci->botflags, u->Account()); + CheckOptStr(flags, BS_DONTKICKOPS, _("Ops protection"), ci->botflags, source.nc); + CheckOptStr(flags, BS_DONTKICKVOICES, _("Voices protection"), ci->botflags, source.nc); + CheckOptStr(flags, BS_FANTASY, _("Fantasy"), ci->botflags, source.nc); + CheckOptStr(flags, BS_GREET, _("Greet"), ci->botflags, source.nc); + CheckOptStr(flags, BS_NOBOT, _("No bot"), ci->botflags, source.nc); info[_("Options")] = flags.empty() ? _("None") : flags; diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 819c5af74..32cfbe952 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -30,7 +30,6 @@ class CommandBSKick : public Command const Anope::string &value = params[2]; const Anope::string &ttb = params.size() > 3 ? params[3] : ""; - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (readonly) @@ -41,14 +40,14 @@ class CommandBSKick : public Command this->OnSyntaxError(source, ""); else if (!value.equals_ci("ON") && !value.equals_ci("OFF")) this->OnSyntaxError(source, ""); - else if (!ci->AccessFor(u).HasPriv("SET") && !u->HasPriv("botserv/administration")) + else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("botserv/administration")) source.Reply(ACCESS_DENIED); else if (!ci->bi) source.Reply(BOT_NOT_ASSIGNED); else { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << option << " " << value; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << option << " " << value; if (option.equals_ci("BADWORDS")) { diff --git a/modules/commands/bs_set_dontkickops.cpp b/modules/commands/bs_set_dontkickops.cpp index f05cb1a2c..598dfdcea 100644 --- a/modules/commands/bs_set_dontkickops.cpp +++ b/modules/commands/bs_set_dontkickops.cpp @@ -24,7 +24,6 @@ class CommandBSSetDontKickOps : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,8 @@ class CommandBSSetDontKickOps : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET")) + AccessGroup access = source.AccessFor(ci); + if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -46,16 +46,16 @@ class CommandBSSetDontKickOps : public Command if (params[1].equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable dontkickops"; + bool override = !access.HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickops"; ci->botflags.SetFlag(BS_DONTKICKOPS); source.Reply(_("Bot \002won't kick ops\002 on channel %s."), ci->name.c_str()); } else if (params[1].equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable dontkickops"; + bool override = !access.HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickops"; ci->botflags.UnsetFlag(BS_DONTKICKOPS); source.Reply(_("Bot \002will kick ops\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_dontkickvoices.cpp b/modules/commands/bs_set_dontkickvoices.cpp index 2b477bbfe..05453296b 100644 --- a/modules/commands/bs_set_dontkickvoices.cpp +++ b/modules/commands/bs_set_dontkickvoices.cpp @@ -24,7 +24,6 @@ class CommandBSSetDontKickVoices : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,8 @@ class CommandBSSetDontKickVoices : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET")) + AccessGroup access = source.AccessFor(ci); + if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -46,16 +46,16 @@ class CommandBSSetDontKickVoices : public Command if (params[1].equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable dontkickvoices"; + bool override = !access.HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickvoices"; ci->botflags.SetFlag(BS_DONTKICKVOICES); source.Reply(_("Bot \002won't kick voices\002 on channel %s."), ci->name.c_str()); } else if (params[1].equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable dontkickvoices"; + bool override = !access.HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickvoices"; ci->botflags.UnsetFlag(BS_DONTKICKVOICES); source.Reply(_("Bot \002will kick voices\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_fantasy.cpp b/modules/commands/bs_set_fantasy.cpp index 06df20fbc..03bd40c70 100644 --- a/modules/commands/bs_set_fantasy.cpp +++ b/modules/commands/bs_set_fantasy.cpp @@ -24,7 +24,6 @@ class CommandBSSetFantasy : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); const Anope::string &value = params[1]; @@ -34,7 +33,7 @@ class CommandBSSetFantasy : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET")) + if (!source.HasPriv("botserv/administration") && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -48,16 +47,16 @@ class CommandBSSetFantasy : public Command if (value.equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable fantasy"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable fantasy"; ci->botflags.SetFlag(BS_FANTASY); source.Reply(_("Fantasy mode is now \002on\002 on channel %s."), ci->name.c_str()); } else if (value.equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable fantasy"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable fantasy"; ci->botflags.UnsetFlag(BS_FANTASY); source.Reply(_("Fantasy mode is now \002off\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_greet.cpp b/modules/commands/bs_set_greet.cpp index 806f62f29..b74b0e5dd 100644 --- a/modules/commands/bs_set_greet.cpp +++ b/modules/commands/bs_set_greet.cpp @@ -24,7 +24,6 @@ class CommandBSSetGreet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); const Anope::string &value = params[1]; @@ -34,7 +33,7 @@ class CommandBSSetGreet : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET")) + if (!source.HasPriv("botserv/administration") && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -48,16 +47,16 @@ class CommandBSSetGreet : public Command if (value.equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable greets"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable greets"; ci->botflags.SetFlag(BS_GREET); source.Reply(_("Greet mode is now \002on\002 on channel %s."), ci->name.c_str()); } else if (value.equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable greets"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable greets"; ci->botflags.UnsetFlag(BS_GREET); source.Reply(_("Greet mode is now \002off\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_nobot.cpp b/modules/commands/bs_set_nobot.cpp index 75c3a8286..246864953 100644 --- a/modules/commands/bs_set_nobot.cpp +++ b/modules/commands/bs_set_nobot.cpp @@ -24,7 +24,6 @@ class CommandBSSetNoBot : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); const Anope::string &value = params[1]; @@ -34,7 +33,7 @@ class CommandBSSetNoBot : public Command return; } - if (!u->HasCommand("botserv/set/nobot")) + if (!source.HasCommand("botserv/set/nobot")) { source.Reply(ACCESS_DENIED); return; @@ -42,18 +41,18 @@ class CommandBSSetNoBot : public Command if (value.equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to enable nobot"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to enable nobot"; ci->botflags.SetFlag(BS_NOBOT); if (ci->bi) - ci->bi->UnAssign(u, ci); + ci->bi->UnAssign(source.GetUser(), ci); source.Reply(_("No Bot mode is now \002on\002 on channel %s."), ci->name.c_str()); } else if (value.equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to disable nobot"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to disable nobot"; ci->botflags.UnsetFlag(BS_NOBOT); source.Reply(_("No Bot mode is now \002off\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_private.cpp b/modules/commands/bs_set_private.cpp index 5a1be8d45..0cd055d00 100644 --- a/modules/commands/bs_set_private.cpp +++ b/modules/commands/bs_set_private.cpp @@ -24,7 +24,6 @@ class CommandBSSetPrivate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; BotInfo *bi = findbot(params[0]); const Anope::string &value = params[1]; @@ -34,7 +33,7 @@ class CommandBSSetPrivate : public Command return; } - if (!u->HasCommand("botserv/set/private")) + if (!source.HasCommand("botserv/set/private")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index ff0ee067e..c482e3c66 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -90,8 +90,6 @@ class CommandCSAccess : public Command { void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { - User *u = source.u; - Anope::string mask = params[2]; int level = ACCESS_INVALID; @@ -112,7 +110,7 @@ class CommandCSAccess : public Command return; } - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); const ChanAccess *highest = u_access.Highest(); AccessChanAccess tmp_access(NULL); @@ -123,7 +121,7 @@ class CommandCSAccess : public Command if ((!highest || *highest <= tmp_access) && !u_access.Founder) { - if (u->HasPriv("chanserv/access/modify")) + if (source.HasPriv("chanserv/access/modify")) override = true; else { @@ -150,7 +148,7 @@ class CommandCSAccess : public Command if (mask.equals_ci(access->mask)) { /* Don't allow lowering from a level >= u_level */ - if ((!highest || *access >= *highest) && !u_access.Founder && !u->HasPriv("chanserv/access/modify")) + if ((!highest || *access >= *highest) && !u_access.Founder && !source.HasPriv("chanserv/access/modify")) { source.Reply(ACCESS_DENIED); return; @@ -172,15 +170,15 @@ class CommandCSAccess : public Command AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create()); access->ci = ci; access->mask = mask; - access->creator = u->nick; + access->creator = source.GetNick(); access->level = level; access->last_seen = 0; access->created = Anope::CurTime; ci->AddAccess(access); - FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, access)); + FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access)); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to add " << mask << " with level " << level; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << level; source.Reply(_("\002%s\002 added to %s access list at level \002%d\002."), access->mask.c_str(), ci->name.c_str(), level); return; @@ -188,8 +186,6 @@ class CommandCSAccess : public Command void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { - User *u = source.u; - const Anope::string &mask = params[2]; if (!ci->GetAccessCount()) @@ -208,7 +204,7 @@ class CommandCSAccess : public Command public: AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), Deleted(0), Denied(false), override(false) { - if (!ci->AccessFor(source.u).HasPriv("ACCESS_CHANGE") && source.u->HasPriv("chanserv/access/modify")) + if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify")) this->override = true; } @@ -220,7 +216,7 @@ class CommandCSAccess : public Command source.Reply(_("No matching entries on %s access list."), ci->name.c_str()); else { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "to delete " << Nicks; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Nicks; if (Deleted == 1) source.Reply(_("Deleted 1 entry from %s access list."), ci->name.c_str()); @@ -234,14 +230,12 @@ class CommandCSAccess : public Command if (!Number || Number > ci->GetAccessCount()) return; - User *user = source.u; - ChanAccess *access = ci->GetAccess(Number - 1); - AccessGroup u_access = ci->AccessFor(user); + AccessGroup u_access = source.AccessFor(ci); const ChanAccess *u_highest = u_access.Highest(); - if ((!u_highest || *u_highest <= *access) && !u_access.Founder && !this->override && !access->mask.equals_ci(user->Account()->display)) + if ((!u_highest || *u_highest <= *access) && !u_access.Founder && !this->override && !access->mask.equals_ci(source.nc->display)) { Denied = true; return; @@ -253,7 +247,7 @@ class CommandCSAccess : public Command else Nicks = access->mask; - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, user, access)); + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access)); ci->EraseAccess(Number - 1); } @@ -263,7 +257,7 @@ class CommandCSAccess : public Command } else { - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); const ChanAccess *highest = u_access.Highest(); for (unsigned i = ci->GetAccessCount(); i > 0; --i) @@ -271,15 +265,15 @@ class CommandCSAccess : public Command ChanAccess *access = ci->GetAccess(i - 1); if (mask.equals_ci(access->mask)) { - if (!access->mask.equals_ci(u->Account()->display) && !u_access.Founder && (!highest || *highest <= *access) && !u->HasPriv("chanserv/access/modify")) + if (!access->mask.equals_ci(source.nc->display) && !u_access.Founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else { source.Reply(_("\002%s\002 deleted from %s access list."), access->mask.c_str(), ci->name.c_str()); - bool override = !u_access.Founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(u->Account()->display); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to delete " << access->mask; + bool override = !u_access.Founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask; - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, access)); + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access)); ci->EraseAccess(access); } return; @@ -420,20 +414,18 @@ class CommandCSAccess : public Command void DoClear(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; - - if (!IsFounder(u, ci) && !u->HasPriv("chanserv/access/modify")) + if (!source.IsFounder(ci) && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else { - FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u)); + FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, source)); ci->ClearAccess(); source.Reply(_("Channel %s access list has been cleared."), ci->name.c_str()); - bool override = !IsFounder(u, ci); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to clear the access list"; + bool override = !source.IsFounder(ci); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list"; } return; @@ -456,7 +448,6 @@ class CommandCSAccess : public Command const Anope::string &nick = params.size() > 2 ? params[2] : ""; const Anope::string &s = params.size() > 3 ? params[3] : ""; - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -469,16 +460,16 @@ class CommandCSAccess : public Command bool is_del = cmd.equals_ci("DEL"); bool has_access = false; - if (u->HasPriv("chanserv/access/modify")) + if (source.HasPriv("chanserv/access/modify")) has_access = true; - else if (is_list && ci->AccessFor(u).HasPriv("ACCESS_LIST")) + else if (is_list && source.AccessFor(ci).HasPriv("ACCESS_LIST")) has_access = true; - else if (ci->AccessFor(u).HasPriv("ACCESS_CHANGE")) + else if (source.AccessFor(ci).HasPriv("ACCESS_CHANGE")) has_access = true; else if (is_del) { const NickAlias *na = findnick(nick); - if (na && na->nc == u->Account()) + if (na && na->nc == source.nc) has_access = true; } @@ -575,8 +566,6 @@ class CommandCSLevels : public Command { void DoSet(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { - User *u = source.u; - const Anope::string &what = params[2]; const Anope::string &lev = params[3]; @@ -607,10 +596,10 @@ class CommandCSLevels : public Command else { ci->SetLevel(p->name, level); - FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, p->name, level)); + FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, p->name, level)); - bool override = !ci->AccessFor(u).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to set " << p->name << " to level " << level; + bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << p->name << " to level " << level; if (level == ACCESS_FOUNDER) source.Reply(_("Level for %s on channel %s changed to founder only."), p->name.c_str(), ci->name.c_str()); @@ -622,8 +611,6 @@ class CommandCSLevels : public Command void DoDisable(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { - User *u = source.u; - const Anope::string &what = params[2]; /* Don't allow disabling of the founder level. It would be hard to change it back if you dont have access to use this command */ @@ -633,10 +620,10 @@ class CommandCSLevels : public Command if (p != NULL) { ci->SetLevel(p->name, ACCESS_INVALID); - FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, p->name, ACCESS_INVALID)); + FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, p->name, ACCESS_INVALID)); - bool override = !ci->AccessFor(u).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable " << p->name; + bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable " << p->name; source.Reply(_("\002%s\002 disabled on channel %s."), p->name.c_str(), ci->name.c_str()); return; @@ -684,13 +671,11 @@ class CommandCSLevels : public Command void DoReset(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; - reset_levels(ci); - FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, "ALL", 0)); + FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, "ALL", 0)); - bool override = !ci->AccessFor(u).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to reset all levels"; + bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to reset all levels"; source.Reply(_("Access levels for \002%s\002 reset to defaults."), ci->name.c_str()); return; @@ -712,8 +697,6 @@ class CommandCSLevels : public Command const Anope::string &what = params.size() > 2 ? params[2] : ""; const Anope::string &s = params.size() > 3 ? params[3] : ""; - User *u = source.u; - ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -726,7 +709,7 @@ class CommandCSLevels : public Command */ if (cmd.equals_ci("SET") ? s.empty() : (cmd.substr(0, 3).equals_ci("DIS") ? (what.empty() || !s.empty()) : !what.empty())) this->OnSyntaxError(source, cmd); - else if (!ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasPriv("chanserv/access/modify")) + else if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else if (cmd.equals_ci("SET")) this->DoSet(source, ci, params); @@ -757,7 +740,7 @@ class CommandCSLevels : public Command const Privilege &p = privs[i]; ListFormatter::ListEntry entry; entry["Name"] = p.name; - entry["Description"] = translate(source.u, p.desc.c_str()); + entry["Description"] = translate(source.nc, p.desc.c_str()); list.addEntry(entry); } diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 107f97584..1ff67215c 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -50,8 +50,6 @@ class CommandCSAKick : public Command { void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { - User *u = source.u; - Anope::string mask = params[2]; Anope::string reason = params.size() > 3 ? params[3] : ""; const NickAlias *na = findnick(mask); @@ -86,7 +84,7 @@ class CommandCSAKick : public Command * or whether the mask matches a user with higher/equal access - Viper */ if (ci->HasFlag(CI_PEACE) && nc) { - AccessGroup nc_access = ci->AccessFor(nc), u_access = ci->AccessFor(u); + AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); if (nc == ci->GetFounder() || nc_access >= u_access) { source.Reply(ACCESS_DENIED); @@ -101,7 +99,7 @@ class CommandCSAKick : public Command { User *u2 = it->second; - AccessGroup nc_access = ci->AccessFor(nc), u_access = ci->AccessFor(u); + AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); Entry entry_mask(CMODE_BEGIN, mask); if ((ci->AccessFor(u2).HasPriv("FOUNDER") || nc_access >= u_access) && entry_mask.Matches(u2)) @@ -117,7 +115,7 @@ class CommandCSAKick : public Command { na = it->second; - AccessGroup nc_access = ci->AccessFor(na->nc), u_access = ci->AccessFor(u); + AccessGroup nc_access = ci->AccessFor(na->nc), u_access = source.AccessFor(ci); if (na->nc && (na->nc == ci->GetFounder() || nc_access >= u_access)) { Anope::string buf = na->nick + "!" + na->last_usermask; @@ -147,14 +145,14 @@ class CommandCSAKick : public Command } if (nc) - akick = ci->AddAkick(u->nick, nc, reason); + akick = ci->AddAkick(source.GetNick(), nc, reason); else - akick = ci->AddAkick(u->nick, mask, reason); + akick = ci->AddAkick(source.GetNick(), mask, reason); - bool override = !ci->AccessFor(u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason; + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason; - FOREACH_MOD(I_OnAkickAdd, OnAkickAdd(u, ci, akick)); + FOREACH_MOD(I_OnAkickAdd, OnAkickAdd(source, ci, akick)); source.Reply(_("\002%s\002 added to %s autokick list."), mask.c_str(), ci->name.c_str()); @@ -163,8 +161,6 @@ class CommandCSAKick : public Command void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { - User *u = source.u; - const Anope::string &mask = params[2]; unsigned i, end; @@ -190,8 +186,8 @@ class CommandCSAKick : public Command ~AkickDelCallback() { - bool override = !ci->AccessFor(source.u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "to delete " << Deleted << (Deleted == 1 ? " entry" : " entries"); + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Deleted << (Deleted == 1 ? " entry" : " entries"); if (!Deleted) source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str()); @@ -206,7 +202,7 @@ class CommandCSAKick : public Command if (!Number || Number > ci->GetAkickCount()) return; - FOREACH_MOD(I_OnAkickDel, OnAkickDel(source.u, ci, ci->GetAkick(Number - 1))); + FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(Number - 1))); ++Deleted; ci->EraseAkick(Number - 1); @@ -234,10 +230,10 @@ class CommandCSAKick : public Command return; } - bool override = !ci->AccessFor(u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to delete " << mask; + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; - FOREACH_MOD(I_OnAkickDel, OnAkickDel(u, ci, ci->GetAkick(i))); + FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(i))); ci->EraseAkick(i); @@ -370,7 +366,6 @@ class CommandCSAKick : public Command void DoEnforce(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; Channel *c = ci->c; int count = 0; @@ -388,17 +383,16 @@ class CommandCSAKick : public Command ++count; } - bool override = !ci->AccessFor(u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ENFORCE, affects " << count << " users"; + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ENFORCE, affects " << count << " users"; source.Reply(_("AKICK ENFORCE for \002%s\002 complete; \002%d\002 users were affected."), ci->name.c_str(), count); } void DoClear(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; - bool override = !ci->AccessFor(u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to clear the akick list"; + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the akick list"; ci->ClearAkick(); source.Reply(_("Channel %s akick list has been cleared."), ci->name.c_str()); @@ -422,8 +416,6 @@ class CommandCSAKick : public Command Anope::string cmd = params[1]; Anope::string mask = params.size() > 2 ? params[2] : ""; - User *u = source.u; - ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -433,7 +425,7 @@ class CommandCSAKick : public Command if (mask.empty() && (cmd.equals_ci("ADD") || cmd.equals_ci("DEL"))) this->OnSyntaxError(source, cmd); - else if (!ci->AccessFor(u).HasPriv("AKICK") && !u->HasPriv("chanserv/access/modify")) + else if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else if (!cmd.equals_ci("LIST") && !cmd.equals_ci("VIEW") && !cmd.equals_ci("ENFORCE") && readonly) source.Reply(_("Sorry, channel autokick list modification is temporarily disabled.")); diff --git a/modules/commands/cs_appendtopic.cpp b/modules/commands/cs_appendtopic.cpp index fe1633b8a..70cde7b7b 100644 --- a/modules/commands/cs_appendtopic.cpp +++ b/modules/commands/cs_appendtopic.cpp @@ -52,14 +52,13 @@ class CommandCSAppendTopic : public Command { const Anope::string &newtopic = params[1]; - User *u = source.u; Channel *c = findchan(params[0]);; if (!c) source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); else if (!c->ci) source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); - else if (!c->ci->AccessFor(u).HasPriv("TOPIC") && !u->HasCommand("chanserv/topic")) + else if (!source.AccessFor(c->ci).HasPriv("TOPIC") && !source.HasCommand("chanserv/topic")) source.Reply(ACCESS_DENIED); else { @@ -74,12 +73,12 @@ class CommandCSAppendTopic : public Command bool has_topiclock = c->ci->HasFlag(CI_TOPICLOCK); c->ci->UnsetFlag(CI_TOPICLOCK); - c->ChangeTopic(u->nick, topic, Anope::CurTime); + c->ChangeTopic(source.GetNick(), topic, Anope::CurTime); if (has_topiclock) c->ci->SetFlag(CI_TOPICLOCK); - bool override = !c->ci->AccessFor(u).HasPriv("TOPIC"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, c->ci) << "to append: " << topic; + bool override = !source.AccessFor(c->ci).HasPriv("TOPIC"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to append: " << topic; } return; } diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index 867d654c5..063d98ab5 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -36,11 +36,11 @@ class CommandCSBan : public Command return; } - User *u = source.u; Channel *c = ci->c; + User *u = source.GetUser(); User *u2 = finduser(target); - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); if (!c) source.Reply(CHAN_X_NOT_IN_USE, chan.c_str()); @@ -66,7 +66,7 @@ class CommandCSBan : public Command get_idealban(ci, u2, mask); // XXX need a way to detect if someone is overriding - Log(LOG_COMMAND, u, this, ci) << "for " << mask; + Log(LOG_COMMAND, source, this, ci) << "for " << mask; c->SetMode(NULL, CMODE_BAN, mask); @@ -74,15 +74,15 @@ class CommandCSBan : public Command if (!c->FindUser(u2)) return; - if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !ci->AccessFor(u).HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), u->nick.c_str()); + if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !source.AccessFor(ci).HasPriv("SIGNKICK"))) + c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), source.GetNick().c_str()); else c->Kick(ci->WhoSends(), u2, "%s", reason.c_str()); } } else if (u_access.HasPriv("FOUNDER")) { - Log(LOG_COMMAND, u, this, ci) << "for " << target; + Log(LOG_COMMAND, source, this, ci) << "for " << target; c->SetMode(NULL, CMODE_BAN, target); @@ -106,7 +106,7 @@ class CommandCSBan : public Command ++kicked; if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !u_access.HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), u->nick.c_str()); + c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), source.GetNick().c_str()); else c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), target.c_str()); } diff --git a/modules/commands/cs_clearusers.cpp b/modules/commands/cs_clearusers.cpp index 58de57f5a..1c26fe382 100644 --- a/modules/commands/cs_clearusers.cpp +++ b/modules/commands/cs_clearusers.cpp @@ -26,7 +26,6 @@ class CommandCSClearUsers : public Command { const Anope::string &chan = params[0]; - User *u = source.u; Channel *c = findchan(chan); Anope::string modebuf; @@ -40,13 +39,13 @@ class CommandCSClearUsers : public Command source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); return; } - else if (!c->ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasCommand("chanserv/clearusers")) + else if (!source.AccessFor(c->ci).HasPriv("FOUNDER") && !source.HasCommand("chanserv/clearusers")) { source.Reply(ACCESS_DENIED); return; } - Anope::string buf = "CLEARUSERS command from " + u->nick + " (" + u->Account()->display + ")"; + Anope::string buf = "CLEARUSERS command from " + source.GetNick() + " (" + source.nc->display + ")"; for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { @@ -55,8 +54,8 @@ class CommandCSClearUsers : public Command c->Kick(NULL, uc->user, "%s", buf.c_str()); } - bool override = !c->ci->AccessFor(u).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, c->ci); + bool override = !source.AccessFor(c->ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci); source.Reply(_("All users have been kicked from \002%s\002."), chan.c_str()); diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index be6907b81..99c635c8f 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -28,7 +28,7 @@ public: const Anope::string &target = params[1]; Anope::string what = params.size() > 2 ? params[2] : ""; - User *u = source.u; + User *u = source.GetUser(); ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -36,7 +36,7 @@ public: return; } - if (!ci->AccessFor(u).HasPriv("SET")) + if (!source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -48,7 +48,7 @@ public: source.Reply(CHAN_X_NOT_REGISTERED, target.c_str()); return; } - if (!IsFounder(u, ci) || !IsFounder(u, target_ci)) + if (!source.IsFounder(ci) || !source.IsFounder(target_ci)) { source.Reply(ACCESS_DENIED); return; @@ -71,7 +71,7 @@ public: target_ci->c->CheckModes(); ChannelMode *cm; - if (u->FindChannel(target_ci->c) != NULL) + if (u && u->FindChannel(target_ci->c) != NULL) { /* On most ircds you do not receive the admin/owner mode till its registered */ if ((cm = ModeManager::FindChannelModeByName(CMODE_OWNER))) @@ -155,7 +155,7 @@ public: return; } - Log(LOG_COMMAND, u, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name; + Log(LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name; return; } diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp index fb9da23b8..cf8c5040e 100644 --- a/modules/commands/cs_drop.cpp +++ b/modules/commands/cs_drop.cpp @@ -26,8 +26,6 @@ class CommandCSDrop : public Command { const Anope::string &chan = params[0]; - User *u = source.u; - if (readonly) { source.Reply(_("Sorry, channel de-registration is temporarily disabled.")); // XXX: READ_ONLY_MODE? @@ -41,20 +39,20 @@ class CommandCSDrop : public Command return; } - if (ci->HasFlag(CI_SUSPENDED) && !u->HasCommand("chanserv/drop")) + if (ci->HasFlag(CI_SUSPENDED) && !source.HasCommand("chanserv/drop")) { source.Reply(CHAN_X_SUSPENDED, chan.c_str()); return; } - if ((ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->AccessFor(u).HasPriv("FOUNDER")) && !u->HasCommand("chanserv/drop")) + if ((ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop")) { source.Reply(ACCESS_DENIED); return; } - bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->AccessFor(u).HasPriv("FOUNDER")); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->display : "none") << ")"; + bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->display : "none") << ")"; FOREACH_MOD(I_OnChanDrop, OnChanDrop(ci)); @@ -71,10 +69,9 @@ class CommandCSDrop : public Command bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { - User *u = source.u; this->SendSyntax(source); source.Reply(" "); - if (u->IsServicesOper()) + if (source.IsServicesOper()) source.Reply(_("Unregisters the named channel. Only \002Services Operators\002\n" "can drop a channel for which they have not identified.")); else diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp index 62c8e0c6d..96031a96f 100644 --- a/modules/commands/cs_enforce.cpp +++ b/modules/commands/cs_enforce.cpp @@ -122,14 +122,13 @@ class CommandCSEnforce : public Command { const Anope::string &what = params.size() > 1 ? params[1] : ""; - User *u = source.u; Channel *c = findchan(params[0]); if (!c) source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); else if (!c->ci) source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); - else if (!c->ci->AccessFor(u).HasPriv("AKICK")) + else if (!source.AccessFor(c->ci).HasPriv("AKICK")) source.Reply(ACCESS_DENIED); else { diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index 9fbcc624f..e5b8d2221 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -22,7 +22,6 @@ struct EntryMsg : Serializable EntryMsg(ChannelInfo *c, const Anope::string &cname, const Anope::string &cmessage, time_t ct = Anope::CurTime) { - this->ci = c; this->creator = cname; this->message = cmessage; @@ -128,8 +127,6 @@ class CommandEntryMessage : public Command void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &message) { - User *u = source.u; - EntryMessageList *messages = ci->GetExt<EntryMessageList *>("cs_entrymsg"); if (messages == NULL) { @@ -141,16 +138,14 @@ class CommandEntryMessage : public Command source.Reply(_("The entry message list for \002%s\002 is full."), ci->name.c_str()); else { - (*messages)->push_back(new EntryMsg(ci, source.u->nick, message)); - Log(IsFounder(u, ci) ? LOG_COMMAND : LOG_OVERRIDE, u, this, ci) << "to add a message"; + (*messages)->push_back(new EntryMsg(ci, source.GetNick(), message)); + Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to add a message"; source.Reply(_("Entry message added to \002%s\002"), ci->name.c_str()); } } void DoDel(CommandSource &source, ChannelInfo *ci, const Anope::string &message) { - User *u = source.u; - EntryMessageList *messages = ci->GetExt<EntryMessageList *>("cs_entrymsg"); if (messages == NULL) { @@ -173,7 +168,7 @@ class CommandEntryMessage : public Command (*messages)->erase((*messages)->begin() + i - 1); if ((*messages)->empty()) ci->Shrink("cs_entrymsg"); - Log(IsFounder(u, ci) ? LOG_COMMAND : LOG_OVERRIDE, u, this, ci) << "to remove a message"; + Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message"; source.Reply(_("Entry message \002%i\002 for \002%s\002 deleted."), i, ci->name.c_str()); } else @@ -188,8 +183,6 @@ class CommandEntryMessage : public Command void DoClear(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; - EntryMessageList *messages = ci->GetExt<EntryMessageList *>("cs_entrymsg"); if (messages != NULL) { @@ -199,7 +192,7 @@ class CommandEntryMessage : public Command ci->Shrink("cs_entrymsg"); } - Log(IsFounder(u, ci) ? LOG_COMMAND : LOG_OVERRIDE, u, this, ci) << "to remove all messages"; + Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove all messages"; source.Reply(_("Entry messages for \002%s\002 have been cleared."), ci->name.c_str()); } @@ -215,8 +208,6 @@ class CommandEntryMessage : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -224,7 +215,7 @@ class CommandEntryMessage : public Command return; } - if (IsFounder(u, ci) || u->HasCommand("chanserv/set")) + if (source.IsFounder(ci) || source.HasCommand("chanserv/set")) { if (params[1].equals_ci("LIST")) this->DoList(source, ci); diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index a8f6fe2fc..7c79593a2 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -102,12 +102,12 @@ class CSStats : public Module void DoStats(CommandSource &source, const bool is_global, const std::vector<Anope::string> ¶ms) { - if (!source.u || !source.c) + if (!source.c) return; Anope::string display; if (params.empty()) - display = source.u->Account()->display; + display = source.nc->display; else if (const NickAlias *na = findnick(params[0])) display = na->nc->display; else diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index b85849ed5..587b4c525 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -131,7 +131,7 @@ class CSTop : public Module void DoTop(CommandSource &source, const std::vector<Anope::string> ¶ms, bool is_global, int limit = 1) { - if (!source.u || !source.c || !source.c->ci) + if (!source.c || !source.c->ci) return; Anope::string channel; @@ -204,4 +204,4 @@ void CommandCSGTop10::Execute(CommandSource &source, const std::vector<Anope::st } -MODULE_INIT(CSTop)
\ No newline at end of file +MODULE_INIT(CSTop) diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index 52d826e97..633ebd734 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -75,8 +75,6 @@ class CommandCSFlags : public Command { void DoModify(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { - User *u = source.u; - Anope::string mask = params.size() > 2 ? params[2] : ""; Anope::string flags = params.size() > 3 ? params[3] : ""; @@ -86,7 +84,7 @@ class CommandCSFlags : public Command return; } - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) { @@ -141,7 +139,7 @@ class CommandCSFlags : public Command { if (!u_access.HasPriv(it->first)) { - if (u->HasPriv("chanserv/access/modify")) + if (source.HasPriv("chanserv/access/modify")) override = true; else continue; @@ -161,7 +159,7 @@ class CommandCSFlags : public Command continue; else if (!u_access.HasPriv(it->first)) { - if (u->HasPriv("chanserv/access/modify")) + if (source.HasPriv("chanserv/access/modify")) override = true; else { @@ -181,9 +179,9 @@ class CommandCSFlags : public Command { if (current != NULL) { - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, current)); + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, current)); ci->EraseAccess(current); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to delete " << mask; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; source.Reply(_("\002%s\002 removed from the %s access list."), mask.c_str(), ci->name.c_str()); } else @@ -199,7 +197,7 @@ class CommandCSFlags : public Command FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create()); access->ci = ci; access->mask = mask; - access->creator = u->nick; + access->creator = source.GetNick(); access->last_seen = current ? current->last_seen : 0; access->created = Anope::CurTime; access->flags = current_flags; @@ -209,9 +207,9 @@ class CommandCSFlags : public Command ci->AddAccess(access); - FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, access)); + FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access)); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to modify " << mask << "'s flags to " << access->Serialize(); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->Serialize(); source.Reply(_("Access for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->Serialize().c_str()); return; @@ -259,7 +257,7 @@ class CommandCSFlags : public Command entry["Mask"] = access->mask; entry["Flags"] = FlagsChanAccess::DetermineFlags(access); entry["Creator"] = access->creator; - entry["Created"] = do_strftime(access->created, source.u->Account(), true); + entry["Created"] = do_strftime(access->created, source.nc, true); list.addEntry(entry); } @@ -282,20 +280,18 @@ class CommandCSFlags : public Command void DoClear(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; - - if (!IsFounder(u, ci) && !u->HasPriv("chanserv/access/modify")) + if (!source.IsFounder(ci) && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else { ci->ClearAccess(); - FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u)); + FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, source)); source.Reply(_("Channel %s access list has been cleared."), ci->name.c_str()); - bool override = !IsFounder(u, ci); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to clear the access list"; + bool override = !source.IsFounder(ci); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list"; } return; @@ -315,7 +311,6 @@ class CommandCSFlags : public Command const Anope::string &chan = params[0]; const Anope::string &cmd = params[1]; - User *u = source.u; ChannelInfo *ci = cs_findchan(chan); if (ci == NULL) { @@ -325,11 +320,11 @@ class CommandCSFlags : public Command bool is_list = cmd.equals_ci("LIST"); bool has_access = false; - if (u->HasPriv("chanserv/access/modify")) + if (source.HasPriv("chanserv/access/modify")) has_access = true; - else if (is_list && ci->AccessFor(u).HasPriv("ACCESS_LIST")) + else if (is_list && source.AccessFor(ci).HasPriv("ACCESS_LIST")) has_access = true; - else if (ci->AccessFor(u).HasPriv("ACCESS_CHANGE")) + else if (source.AccessFor(ci).HasPriv("ACCESS_CHANGE")) has_access = true; if (!has_access) @@ -379,7 +374,7 @@ class CommandCSFlags : public Command Privilege *p = PrivilegeManager::FindPrivilege(it->second); if (p == NULL) continue; - source.Reply(" %c - %s", it->first, translate(source.u->Account(), p->desc.c_str())); + source.Reply(" %c - %s", it->first, translate(source.nc, p->desc.c_str())); } return true; diff --git a/modules/commands/cs_getkey.cpp b/modules/commands/cs_getkey.cpp index f8164707d..e0205ad03 100644 --- a/modules/commands/cs_getkey.cpp +++ b/modules/commands/cs_getkey.cpp @@ -26,7 +26,6 @@ class CommandCSGetKey : public Command { const Anope::string &chan = params[0]; - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -34,8 +33,7 @@ class CommandCSGetKey : public Command return; } - - if (!ci->AccessFor(u).HasPriv("GETKEY") && !u->HasCommand("chanserv/getkey")) + if (!source.AccessFor(ci).HasPriv("GETKEY") && !source.HasCommand("chanserv/getkey")) { source.Reply(ACCESS_DENIED); return; @@ -48,8 +46,8 @@ class CommandCSGetKey : public Command return; } - bool override = !ci->AccessFor(u).HasPriv("GETKEY"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci); + bool override = !source.AccessFor(ci).HasPriv("GETKEY"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); source.Reply(_("Key for channel \002%s\002 is \002%s\002."), chan.c_str(), key.c_str()); return; diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index cee3c8251..3c113269e 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -40,7 +40,7 @@ class CommandCSInfo : public Command { const Anope::string &chan = params[0]; - User *u = source.u; + NickCore *nc = source.nc; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -48,14 +48,14 @@ class CommandCSInfo : public Command return; } - bool has_auspex = u->IsIdentified() && u->HasPriv("chanserv/auspex"); + bool has_auspex = source.HasPriv("chanserv/auspex"); bool show_all = false; /* Should we show all fields? Only for sadmins and identified users */ - if (has_auspex || ci->AccessFor(u).HasPriv("INFO")) + if (has_auspex || source.AccessFor(ci).HasPriv("INFO")) show_all = true; - InfoFormatter info(u); + InfoFormatter info(nc); source.Reply(CHAN_INFO_HEADER, chan.c_str()); if (ci->GetFounder()) @@ -82,21 +82,21 @@ class CommandCSInfo : public Command info["Ban type"] = stringify(ci->bantype); Anope::string optbuf; - CheckOptStr(optbuf, CI_KEEPTOPIC, _("Topic Retention"), ci, u->Account()); - CheckOptStr(optbuf, CI_PEACE, _("Peace"), ci, u->Account()); - CheckOptStr(optbuf, CI_PRIVATE, _("Private"), ci, u->Account()); - CheckOptStr(optbuf, CI_RESTRICTED, _("Restricted Access"), ci, u->Account()); - CheckOptStr(optbuf, CI_SECURE, _("Secure"), ci, u->Account()); - CheckOptStr(optbuf, CI_SECUREFOUNDER, _("Secure Founder"), ci, u->Account()); - CheckOptStr(optbuf, CI_SECUREOPS, _("Secure Ops"), ci, u->Account()); + CheckOptStr(optbuf, CI_KEEPTOPIC, _("Topic Retention"), ci, nc); + CheckOptStr(optbuf, CI_PEACE, _("Peace"), ci, nc); + CheckOptStr(optbuf, CI_PRIVATE, _("Private"), ci, nc); + CheckOptStr(optbuf, CI_RESTRICTED, _("Restricted Access"), ci, nc); + CheckOptStr(optbuf, CI_SECURE, _("Secure"), ci, nc); + CheckOptStr(optbuf, CI_SECUREFOUNDER, _("Secure Founder"), ci, nc); + CheckOptStr(optbuf, CI_SECUREOPS, _("Secure Ops"), ci, nc); if (ci->HasFlag(CI_SIGNKICK)) - CheckOptStr(optbuf, CI_SIGNKICK, _("Signed kicks"), ci, u->Account()); + CheckOptStr(optbuf, CI_SIGNKICK, _("Signed kicks"), ci, nc); else - CheckOptStr(optbuf, CI_SIGNKICK_LEVEL, _("Signed kicks"), ci, u->Account()); - CheckOptStr(optbuf, CI_TOPICLOCK, _("Topic Lock"), ci, u->Account()); - CheckOptStr(optbuf, CI_PERSIST, _("Persistant"), ci, u->Account()); - CheckOptStr(optbuf, CI_NO_EXPIRE, _("No expire"), ci, u->Account()); - CheckOptStr(optbuf, CI_STATS, _("Chanstats"), ci, u->Account()); + CheckOptStr(optbuf, CI_SIGNKICK_LEVEL, _("Signed kicks"), ci, nc); + CheckOptStr(optbuf, CI_TOPICLOCK, _("Topic Lock"), ci, nc); + CheckOptStr(optbuf, CI_PERSIST, _("Persistant"), ci, nc); + CheckOptStr(optbuf, CI_NO_EXPIRE, _("No expire"), ci, nc); + CheckOptStr(optbuf, CI_STATS, _("Chanstats"), ci, nc); info["Options"] = optbuf.empty() ? _("None") : optbuf; info["Mode lock"] = ci->GetMLockAsString(true); diff --git a/modules/commands/cs_invite.cpp b/modules/commands/cs_invite.cpp index be3132907..09c077fc6 100644 --- a/modules/commands/cs_invite.cpp +++ b/modules/commands/cs_invite.cpp @@ -26,7 +26,7 @@ class CommandCSInvite : public Command { const Anope::string &chan = params[0]; - User *u = source.u; + User *u = source.GetUser(); Channel *c = findchan(chan); if (!c) @@ -42,7 +42,7 @@ class CommandCSInvite : public Command return; } - if (!ci->AccessFor(u).HasPriv("INVITE") && !u->HasCommand("chanserv/invite")) + if (!source.AccessFor(ci).HasPriv("INVITE") && !source.HasCommand("chanserv/invite")) { source.Reply(ACCESS_DENIED); return; @@ -52,12 +52,12 @@ class CommandCSInvite : public Command if (params.size() == 1) u2 = u; else + u2 = finduser(params[1]); + + if (!u2) { - if (!(u2 = finduser(params[1]))) - { - source.Reply(NICK_X_NOT_IN_USE, params[1].c_str()); - return; - } + source.Reply(NICK_X_NOT_IN_USE, params.size() > 1 ? params[1].c_str() : source.GetNick().c_str()); + return; } if (c->FindUser(u2)) @@ -69,17 +69,17 @@ class CommandCSInvite : public Command } else { - bool override = !ci->AccessFor(u).HasPriv("INVITE"); + bool override = !source.AccessFor(ci).HasPriv("INVITE"); ircdproto->SendInvite(ci->WhoSends(), c, u2); if (u2 != u) { source.Reply(_("\002%s\002 has been invited to \002%s\002."), u2->nick.c_str(), c->name.c_str()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << u2->nick; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << u2->nick; } else { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); } u2->SendMessage(ci->WhoSends(), _("You have been invited to \002%s\002."), c->name.c_str()); } diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp index 3ee444698..97d879416 100644 --- a/modules/commands/cs_kick.cpp +++ b/modules/commands/cs_kick.cpp @@ -29,7 +29,7 @@ class CommandCSKick : public Command const Anope::string &target = params[1]; const Anope::string &reason = params.size() > 2 ? params[2] : "Requested"; - User *u = source.u; + User *u = source.GetUser(); ChannelInfo *ci = cs_findchan(params[0]); Channel *c = findchan(params[0]); User *u2 = finduser(target); @@ -45,7 +45,7 @@ class CommandCSKick : public Command return; } - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); if (!u_access.HasPriv("KICK")) source.Reply(ACCESS_DENIED); @@ -61,17 +61,17 @@ class CommandCSKick : public Command else { // XXX - Log(LOG_COMMAND, u, this, ci) << "for " << u2->nick; + Log(LOG_COMMAND, source, this, ci) << "for " << u2->nick; if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !u_access.HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), u->nick.c_str()); + c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), source.GetNick().c_str()); else c->Kick(ci->WhoSends(), u2, "%s", reason.c_str()); } } else if (u_access.HasPriv("FOUNDER")) { - Log(LOG_COMMAND, u, this, ci) << "for " << target; + Log(LOG_COMMAND, source, this, ci) << "for " << target; int matched = 0, kicked = 0; for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end;) @@ -90,7 +90,7 @@ class CommandCSKick : public Command ++kicked; if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !u_access.HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), u->nick.c_str()); + c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), source.GetNick().c_str()); else c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), target.c_str()); } diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index 8bc0de8d9..db5a5136a 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -25,11 +25,9 @@ class CommandCSList : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - Anope::string pattern = params[0]; unsigned nchans; - bool is_servadmin = u->HasCommand("chanserv/list"); + bool is_servadmin = source.HasCommand("chanserv/list"); int count = 0, from = 0, to = 0; bool suspended = false, channoexpire = false; diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index 163789b53..0f680e111 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -28,11 +28,10 @@ public: { const Anope::string &channel = params[0]; - User *u = source.u; ChannelInfo *ci = cs_findchan(channel); if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str()); - else if (!ci->AccessFor(u).HasPriv("SET") && !u->HasPriv("chanserv/set")) + else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("chanserv/set")) source.Reply(ACCESS_DENIED); else if (params.size() == 1) { @@ -108,7 +107,7 @@ public: return; } - bool override = !ci->AccessFor(u).HasPriv("SET"); + bool override = !source.AccessFor(ci).HasPriv("SET"); for (unsigned i = ci->log_settings->size(); i > 0; --i) { @@ -120,13 +119,13 @@ public: { log->destroy(); ci->log_settings->erase(ci->log_settings->begin() + i - 1); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra; source.Reply(_("Logging for command %s on %s with log method %s%s%s has been removed."), command_name.c_str(), bi->nick.c_str(), method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str()); } else { log->extra = extra; - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to change logging for " << command << " to method " << method << (extra == "" ? "" : " ") << extra; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change logging for " << command << " to method " << method << (extra == "" ? "" : " ") << extra; source.Reply(_("Logging changed for command %s on %s, now using log method %s%s%s."), command_name.c_str(), bi->nick.c_str(), method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str()); } return; @@ -141,10 +140,10 @@ public: log->method = method; log->extra = extra; log->created = Anope::CurTime; - log->creator = u->nick; + log->creator = source.GetNick(); ci->log_settings->push_back(log); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to log " << command << " with method " << method << (extra == "" ? "" : " ") << extra; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to log " << command << " with method " << method << (extra == "" ? "" : " ") << extra; source.Reply(_("Logging is now active for command %s on %s, using log method %s%s%s."), command_name.c_str(), bi->nick.c_str(), method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str()); } diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index 452b3b365..6b8df2cc9 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -15,15 +15,15 @@ class CommandCSMode : public Command { - bool CanSet(User *u, ChannelInfo *ci, ChannelMode *cm) + bool CanSet(CommandSource &source, ChannelInfo *ci, ChannelMode *cm) { - if (!u || !ci || !cm || cm->Type != MODE_STATUS) + if (!ci || !cm || cm->Type != MODE_STATUS) return false; const Anope::string accesses[] = { "VOICE", "HALFOP", "OPDEOP", "PROTECT", "OWNER", "" }; const ChannelModeName modes[] = { CMODE_VOICE, CMODE_HALFOP, CMODE_OP, CMODE_PROTECT, CMODE_OWNER }; ChannelModeStatus *cms = anope_dynamic_static_cast<ChannelModeStatus *>(cm); - AccessGroup access = ci->AccessFor(u); + AccessGroup access = source.AccessFor(ci); unsigned short u_level = 0; for (int i = 0; !accesses[i].empty(); ++i) @@ -42,11 +42,11 @@ class CommandCSMode : public Command void DoLock(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { - User *u = source.u; + User *u = source.GetUser(); const Anope::string &subcommand = params[2]; const Anope::string ¶m = params.size() > 3 ? params[3] : ""; - bool override = !ci->AccessFor(u).HasPriv("MODE"); + bool override = !source.AccessFor(ci).HasPriv("MODE"); if (subcommand.equals_ci("ADD") && !param.empty()) { @@ -75,7 +75,7 @@ class CommandCSMode : public Command source.Reply(_("Unknown mode character %c ignored."), modes[i]); break; } - else if (!cm->CanSet(u)) + else if (u && !cm->CanSet(u)) { source.Reply(_("You may not (un)lock mode %c."), modes[i]); break; @@ -86,11 +86,11 @@ class CommandCSMode : public Command source.Reply(_("Missing parameter for mode %c."), cm->ModeChar); else { - ci->SetMLock(cm, adding, mode_param, u->nick); + ci->SetMLock(cm, adding, mode_param, source.GetNick()); if (!mode_param.empty()) mode_param = " " + mode_param; source.Reply(_("%c%c%s locked on %s"), adding ? '+' : '-', cm->ModeChar, mode_param.c_str(), ci->name.c_str()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to lock " << (adding ? '+' : '-') << cm->ModeChar << mode_param; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to lock " << (adding ? '+' : '-') << cm->ModeChar << mode_param; } } } @@ -125,7 +125,7 @@ class CommandCSMode : public Command source.Reply(_("Unknown mode character %c ignored."), modes[i]); break; } - else if (!cm->CanSet(u)) + else if (u && !cm->CanSet(u)) { source.Reply(_("You may not (un)lock mode %c."), modes[i]); break; @@ -141,7 +141,7 @@ class CommandCSMode : public Command if (!mode_param.empty()) mode_param = " " + mode_param; source.Reply(_("%c%c%s has been unlocked from %s."), adding == 1 ? '+' : '-', cm->ModeChar, mode_param.c_str(), ci->name.c_str()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->ModeChar << mode_param; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->ModeChar << mode_param; } else source.Reply(_("%c%c is not locked on %s."), adding == 1 ? '+' : '-', cm->ModeChar, ci->name.c_str()); @@ -172,7 +172,7 @@ class CommandCSMode : public Command entry["Mode"] = Anope::printf("%c%c", ml->set ? '+' : '-', cm->ModeChar); entry["Param"] = ml->param; entry["Creator"] = ml->setter; - entry["Created"] = do_strftime(ml->created, source.u->Account(), false); + entry["Created"] = do_strftime(ml->created, source.nc, false); list.addEntry(entry); } @@ -191,13 +191,13 @@ class CommandCSMode : public Command void DoSet(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { - User *u = source.u; + User *u = source.GetUser(); spacesepstream sep(params.size() > 3 ? params[3] : ""); Anope::string modes = params[2], param; - bool override = !ci->AccessFor(u).HasPriv("MODE"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to set " << params[2]; + bool override = !source.AccessFor(ci).HasPriv("MODE"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << params[2]; int adding = -1; for (size_t i = 0; i < modes.length(); ++i) @@ -216,7 +216,7 @@ class CommandCSMode : public Command for (unsigned j = 0; j < ModeManager::ChannelModes.size(); ++j) { ChannelMode *cm = ModeManager::ChannelModes[j]; - if (cm->CanSet(u)) + if (!u || cm->CanSet(u)) { if (cm->Type == MODE_REGULAR || (!adding && cm->Type == MODE_PARAM)) { @@ -232,7 +232,7 @@ class CommandCSMode : public Command if (adding == -1) break; ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]); - if (!cm || !cm->CanSet(u)) + if (!cm || (u && !cm->CanSet(u))) continue; switch (cm->Type) { @@ -255,13 +255,13 @@ class CommandCSMode : public Command if (!sep.GetToken(param)) break; - if (!this->CanSet(u, ci, cm)) + if (!this->CanSet(source, ci, cm)) { source.Reply(_("You do not have access to set mode %c."), cm->ModeChar); break; } - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); if (str_is_wildcard(param)) { @@ -343,12 +343,11 @@ class CommandCSMode : public Command { const Anope::string &subcommand = params[1]; - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (!ci || !ci->c) source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); - else if (!ci->AccessFor(u).HasPriv("MODE") && !u->HasPriv("chanserv/set")) + else if (!source.AccessFor(ci).HasPriv("MODE") && !source.HasPriv("chanserv/set")) source.Reply(ACCESS_DENIED); else if (subcommand.equals_ci("LOCK")) this->DoLock(source, ci, params); diff --git a/modules/commands/cs_modes.cpp b/modules/commands/cs_modes.cpp index 37d710505..b398e1e8e 100644 --- a/modules/commands/cs_modes.cpp +++ b/modules/commands/cs_modes.cpp @@ -17,7 +17,7 @@ class CommandModeBase : public Command { void do_mode(CommandSource &source, Command *com, ChannelMode *cm, const Anope::string &chan, const Anope::string &nick, bool set, const Anope::string &level, const Anope::string &levelself) { - User *u = source.u; + User *u = source.GetUser(); User *u2 = finduser(nick); Channel *c = findchan(chan); @@ -42,9 +42,9 @@ class CommandModeBase : public Command } bool is_same = u == u2; - AccessGroup u_access = ci->AccessFor(u), u2_access = ci->AccessFor(u2); + AccessGroup u_access = source.AccessFor(ci), u2_access = ci->AccessFor(u2); - if (is_same ? !ci->AccessFor(u).HasPriv(levelself) : !ci->AccessFor(u).HasPriv(level)) + if (is_same ? !source.AccessFor(ci).HasPriv(levelself) : !source.AccessFor(ci).HasPriv(level)) source.Reply(ACCESS_DENIED); else if (!set && !is_same && ci->HasFlag(CI_PEACE) && u2_access >= u_access) source.Reply(ACCESS_DENIED); @@ -59,7 +59,7 @@ class CommandModeBase : public Command else c->RemoveMode(NULL, cm, u2->nick); - Log(LOG_COMMAND, u, com, ci) << "for " << u2->nick; + Log(LOG_COMMAND, source, com, ci) << "for " << u2->nick; } } @@ -76,15 +76,13 @@ class CommandModeBase : public Command */ void do_util(CommandSource &source, Command *com, ChannelMode *cm, const Anope::string &chan, const Anope::string &nick, bool set, const Anope::string &level, const Anope::string &levelself) { - User *u = source.u; + User *u = source.GetUser(); - if (chan.empty()) + if (chan.empty() && u) for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end(); ++it) do_mode(source, com, cm, (*it)->chan->name, u->nick, set, level, levelself); - else + else if (!chan.empty()) do_mode(source, com, cm, chan, !nick.empty() ? nick : u->nick, set, level, levelself); - - return; } public: diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index fd62ff754..49c0919c4 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -27,13 +27,14 @@ class CommandCSRegister : public Command const Anope::string &chan = params[0]; const Anope::string &chdesc = params.size() > 1 ? params[1] : ""; - User *u = source.u; + User *u = source.GetUser(); + NickCore *nc = source.nc; Channel *c = findchan(params[0]); ChannelInfo *ci = cs_findchan(params[0]); if (readonly) source.Reply(_("Sorry, channel registration is temporarily disabled.")); - else if (u->Account()->HasFlag(NI_UNCONFIRMED)) + else if (nc->HasFlag(NI_UNCONFIRMED)) source.Reply(_("You must confirm your account before you can register a channel.")); else if (chan[0] == '&') source.Reply(_("Local channels cannot be registered.")); @@ -45,19 +46,19 @@ class CommandCSRegister : public Command source.Reply(_("Channel \002%s\002 is already registered!"), chan.c_str()); else if (c && !c->HasUserStatus(u, CMODE_OP)) source.Reply(_("You must be a channel operator to register the channel.")); - else if (Config->CSMaxReg && u->Account()->channelcount >= Config->CSMaxReg && !u->HasPriv("chanserv/no-register-limit")) - source.Reply(u->Account()->channelcount > Config->CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, Config->CSMaxReg); + else if (Config->CSMaxReg && nc->channelcount >= Config->CSMaxReg && !source.HasPriv("chanserv/no-register-limit")) + source.Reply(nc->channelcount > Config->CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, Config->CSMaxReg); else { ci = new ChannelInfo(chan); - ci->SetFounder(u->Account()); + ci->SetFounder(nc); if (!chdesc.empty()) ci->desc = chdesc; for (ChannelInfo::ModeList::iterator it = def_mode_locks.begin(), it_end = def_mode_locks.end(); it != it_end; ++it) { ModeLock *ml = new ModeLock(*it->second); - ml->setter = u->nick; + ml->setter = source.GetNick(); ml->ci = ci; ci->mode_locks->insert(std::make_pair(it->first, ml)); } @@ -71,8 +72,8 @@ class CommandCSRegister : public Command else ci->last_topic_setter = source.owner->nick; - Log(LOG_COMMAND, u, this, ci); - source.Reply(_("Channel \002%s\002 registered under your nickname: %s"), chan.c_str(), u->nick.c_str()); + Log(LOG_COMMAND, source, this, ci); + source.Reply(_("Channel \002%s\002 registered under your account: %s"), chan.c_str(), nc->display.c_str()); /* Implement new mode lock */ if (c) @@ -80,7 +81,7 @@ class CommandCSRegister : public Command c->CheckModes(); ChannelMode *cm; - if (u->FindChannel(c) != NULL) + if (u && u->FindChannel(c) != NULL) { /* On most ircds you do not receive the admin/owner mode till its registered */ if ((cm = ModeManager::FindChannelModeByName(CMODE_OWNER))) diff --git a/modules/commands/cs_saset_noexpire.cpp b/modules/commands/cs_saset_noexpire.cpp index a71544a25..78d8641d4 100644 --- a/modules/commands/cs_saset_noexpire.cpp +++ b/modules/commands/cs_saset_noexpire.cpp @@ -24,7 +24,6 @@ class CommandCSSASetNoexpire : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSASetNoexpire : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index ec3ac708f..289988867 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -155,8 +155,8 @@ class CommandOSSeen : public Command counter++; } } - Log(LOG_ADMIN, source.u, this) << "CLEAR and removed " << counter << " nicks that were added after " << do_strftime(time, NULL, true); - source.Reply(_("Database cleared, removed %lu nicks that were added after %s"), counter, do_strftime(time, source.u->Account(), true).c_str()); + Log(LOG_ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << do_strftime(time, NULL, true); + source.Reply(_("Database cleared, removed %lu nicks that were added after %s"), counter, do_strftime(time, source.nc, true).c_str()); } else this->SendSyntax(source); @@ -190,7 +190,6 @@ class CommandSeen : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { const Anope::string &target = params[0]; - User *u = source.u; if (target.length() > Config->NickLen) { @@ -204,9 +203,9 @@ class CommandSeen : public Command return; } - if (target.equals_ci(u->nick)) + if (target.equals_ci(source.GetNick())) { - source.Reply(_("You might see yourself in the mirror, %s."), u->nick.c_str()); + source.Reply(_("You might see yourself in the mirror, %s."), source.GetNick().c_str()); return; } @@ -224,8 +223,8 @@ class CommandSeen : public Command else onlinestatus = Anope::printf(_(" but %s mysteriously dematerialized."), target.c_str()); - Anope::string timebuf = duration(Anope::CurTime - info->last, u->Account()); - Anope::string timebuf2 = do_strftime(info->last, u->Account(), true); + Anope::string timebuf = duration(Anope::CurTime - info->last, source.nc); + Anope::string timebuf2 = do_strftime(info->last, source.nc, true); if (info->type == NEW) { diff --git a/modules/commands/cs_set_bantype.cpp b/modules/commands/cs_set_bantype.cpp index af63d0568..dc28e37f6 100644 --- a/modules/commands/cs_set_bantype.cpp +++ b/modules/commands/cs_set_bantype.cpp @@ -24,7 +24,6 @@ class CommandCSSetBanType : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetBanType : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_chanstats.cpp b/modules/commands/cs_set_chanstats.cpp index dd58c3ac4..02fa9dad9 100644 --- a/modules/commands/cs_set_chanstats.cpp +++ b/modules/commands/cs_set_chanstats.cpp @@ -24,7 +24,6 @@ class CommandCSSetChanstats : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (!ci) { @@ -32,7 +31,7 @@ class CommandCSSetChanstats : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_description.cpp b/modules/commands/cs_set_description.cpp index 0abd8462e..949f40694 100644 --- a/modules/commands/cs_set_description.cpp +++ b/modules/commands/cs_set_description.cpp @@ -24,7 +24,6 @@ class CommandCSSetDescription : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetDescription : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_founder.cpp b/modules/commands/cs_set_founder.cpp index 5f2990196..037ec62ff 100644 --- a/modules/commands/cs_set_founder.cpp +++ b/modules/commands/cs_set_founder.cpp @@ -24,7 +24,6 @@ class CommandCSSetFounder : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,13 +31,13 @@ class CommandCSSetFounder : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; } - if (source.permission.empty() && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->AccessFor(u).HasPriv("FOUNDER"))) + if (source.permission.empty() && (ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER"))) { source.Reply(ACCESS_DENIED); return; @@ -52,13 +51,13 @@ class CommandCSSetFounder : public Command } NickCore *nc = na->nc; - if (Config->CSMaxReg && nc->channelcount >= Config->CSMaxReg && !u->HasPriv("chanserv/no-register-limit")) + if (Config->CSMaxReg && nc->channelcount >= Config->CSMaxReg && !source.HasPriv("chanserv/no-register-limit")) { source.Reply(_("\002%s\002 has too many channels registered."), na->nick.c_str()); return; } - Log(!source.permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the founder from " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << " to " << nc->display; + Log(!source.permission.empty() ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to change the founder from " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << " to " << nc->display; ci->SetFounder(nc); diff --git a/modules/commands/cs_set_keeptopic.cpp b/modules/commands/cs_set_keeptopic.cpp index ddb09c4d1..e29c7727b 100644 --- a/modules/commands/cs_set_keeptopic.cpp +++ b/modules/commands/cs_set_keeptopic.cpp @@ -24,7 +24,6 @@ class CommandCSSetKeepTopic : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetKeepTopic : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 4a2e8fec5..1ad15f02f 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -86,7 +86,7 @@ class CommandCSSetMisc : public Command source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); return; } - else if (source.permission.empty() && !ci->AccessFor(source.u).HasPriv("SET")) + else if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_peace.cpp b/modules/commands/cs_set_peace.cpp index 002690721..49d105820 100644 --- a/modules/commands/cs_set_peace.cpp +++ b/modules/commands/cs_set_peace.cpp @@ -24,7 +24,6 @@ class CommandCSSetPeace : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetPeace : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_persist.cpp b/modules/commands/cs_set_persist.cpp index 60cc7895d..fbca0994f 100644 --- a/modules/commands/cs_set_persist.cpp +++ b/modules/commands/cs_set_persist.cpp @@ -24,7 +24,6 @@ class CommandCSSetPersist : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetPersist : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_private.cpp b/modules/commands/cs_set_private.cpp index 4fd261c45..53deb4d72 100644 --- a/modules/commands/cs_set_private.cpp +++ b/modules/commands/cs_set_private.cpp @@ -24,7 +24,6 @@ class CommandCSSetPrivate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetPrivate : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_restricted.cpp b/modules/commands/cs_set_restricted.cpp index f02d17f3f..fc48f32bc 100644 --- a/modules/commands/cs_set_restricted.cpp +++ b/modules/commands/cs_set_restricted.cpp @@ -23,7 +23,6 @@ class CommandCSSetRestricted : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -31,7 +30,7 @@ class CommandCSSetRestricted : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_secure.cpp b/modules/commands/cs_set_secure.cpp index 480071cbc..49357d2c7 100644 --- a/modules/commands/cs_set_secure.cpp +++ b/modules/commands/cs_set_secure.cpp @@ -24,7 +24,6 @@ class CommandCSSetSecure : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetSecure : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_securefounder.cpp b/modules/commands/cs_set_securefounder.cpp index 7d1c1a7dc..2f58e9ee6 100644 --- a/modules/commands/cs_set_securefounder.cpp +++ b/modules/commands/cs_set_securefounder.cpp @@ -24,7 +24,6 @@ class CommandCSSetSecureFounder : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -33,7 +32,7 @@ class CommandCSSetSecureFounder : public Command } - if (source.permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->AccessFor(u).HasPriv("FOUNDER")) + if (source.permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_secureops.cpp b/modules/commands/cs_set_secureops.cpp index b83e32a63..760a73e6a 100644 --- a/modules/commands/cs_set_secureops.cpp +++ b/modules/commands/cs_set_secureops.cpp @@ -24,7 +24,6 @@ class CommandCSSetSecureOps : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetSecureOps : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_signkick.cpp b/modules/commands/cs_set_signkick.cpp index f8cce4022..79da0fc2e 100644 --- a/modules/commands/cs_set_signkick.cpp +++ b/modules/commands/cs_set_signkick.cpp @@ -24,7 +24,6 @@ class CommandCSSetSignKick : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetSignKick : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_set_successor.cpp b/modules/commands/cs_set_successor.cpp index e0f05e67b..0d752b9d2 100644 --- a/modules/commands/cs_set_successor.cpp +++ b/modules/commands/cs_set_successor.cpp @@ -24,7 +24,6 @@ class CommandCSSetSuccessor : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,13 +31,13 @@ class CommandCSSetSuccessor : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; } - if (source.permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->AccessFor(u).HasPriv("FOUNDER")) + if (source.permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) { source.Reply(ACCESS_DENIED); return; @@ -65,7 +64,7 @@ class CommandCSSetSuccessor : public Command else nc = NULL; - Log(!source.permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the successor from " << (ci->successor ? ci->successor->display : "(none)") << " to " << (nc ? nc->display : "(none)"); + Log(!source.permission.empty() ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to change the successor from " << (ci->successor ? ci->successor->display : "(none)") << " to " << (nc ? nc->display : "(none)"); ci->successor = nc; diff --git a/modules/commands/cs_set_topiclock.cpp b/modules/commands/cs_set_topiclock.cpp index 911c8b463..730c473a4 100644 --- a/modules/commands/cs_set_topiclock.cpp +++ b/modules/commands/cs_set_topiclock.cpp @@ -24,7 +24,6 @@ class CommandCSSetTopicLock : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,7 @@ class CommandCSSetTopicLock : public Command return; } - if (source.permission.empty() && !ci->AccessFor(u).HasPriv("SET")) + if (source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 803202a26..b0ffa3e4c 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -79,7 +79,6 @@ class CommandCSSuspend : public Command Anope::string reason = params.size() > 2 ? params[2] : ""; time_t expiry_secs = Config->CSSuspendExpire; - User *u = source.u; if (!expiry.empty() && expiry[0] != '+') { @@ -107,7 +106,7 @@ class CommandCSSuspend : public Command } ci->SetFlag(CI_SUSPENDED); - ci->Extend("suspend_by", new ExtensibleString(u->nick)); + ci->Extend("suspend_by", new ExtensibleString(source.GetNick())); if (!reason.empty()) ci->Extend("suspend_reason", new ExtensibleString(reason)); @@ -133,7 +132,7 @@ class CommandCSSuspend : public Command ci->Extend("cs_suspend_expire", cs); } - Log(LOG_ADMIN, u, this, ci) << (!reason.empty() ? reason : "No reason") << ", expires in " << (expiry_secs ? do_strftime(Anope::CurTime + expiry_secs) : "never"); + Log(LOG_ADMIN, source, this, ci) << (!reason.empty() ? reason : "No reason") << ", expires in " << (expiry_secs ? do_strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("Channel \002%s\002 is now suspended."), ci->name.c_str()); FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci)); @@ -168,7 +167,6 @@ class CommandCSUnSuspend : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; if (readonly) source.Reply(READ_ONLY_MODE); @@ -189,7 +187,7 @@ class CommandCSUnSuspend : public Command Anope::string *by = ci->GetExt<ExtensibleString *>("suspend_by"), *reason = ci->GetExt<ExtensibleString *>("suspend_reason"); if (by != NULL) - Log(LOG_ADMIN, u, this, ci) << " which was suspended by " << *by << " for: " << (reason && !reason->empty() ? *reason : "No reason"); + Log(LOG_ADMIN, source, this, ci) << " which was suspended by " << *by << " for: " << (reason && !reason->empty() ? *reason : "No reason"); ci->UnsetFlag(CI_SUSPENDED); ci->Shrink("suspend_by"); diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp index d3542398b..549860c01 100644 --- a/modules/commands/cs_sync.cpp +++ b/modules/commands/cs_sync.cpp @@ -22,14 +22,13 @@ class CommandCSSync : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); else if (ci->c == NULL) source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); - else if (!ci->AccessFor(u).HasPriv("ACCESS_CHANGE")) + else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE")) source.Reply(ACCESS_DENIED); else { diff --git a/modules/commands/cs_tban.cpp b/modules/commands/cs_tban.cpp index 61f1f810f..65746fdfc 100644 --- a/modules/commands/cs_tban.cpp +++ b/modules/commands/cs_tban.cpp @@ -56,7 +56,7 @@ class CommandCSTBan : public Command source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); else if (!c->ci) source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); - else if (!c->ci->AccessFor(source.u).HasPriv("BAN")) + else if (!source.AccessFor(c->ci).HasPriv("BAN")) source.Reply(ACCESS_DENIED); else if (!(u2 = finduser(nick))) source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); diff --git a/modules/commands/cs_topic.cpp b/modules/commands/cs_topic.cpp index e1aba12fb..5badaa12d 100644 --- a/modules/commands/cs_topic.cpp +++ b/modules/commands/cs_topic.cpp @@ -26,7 +26,6 @@ class CommandCSTopic : public Command { const Anope::string &topic = params.size() > 1 ? params[1] : ""; - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) @@ -37,18 +36,18 @@ class CommandCSTopic : public Command if (!ci->c) source.Reply(CHAN_X_NOT_IN_USE, ci->name.c_str()); - else if (!ci->AccessFor(u).HasPriv("TOPIC") && !u->HasCommand("chanserv/topic")) + else if (!source.AccessFor(ci).HasPriv("TOPIC") && !source.HasCommand("chanserv/topic")) source.Reply(ACCESS_DENIED); else { bool has_topiclock = ci->HasFlag(CI_TOPICLOCK); ci->UnsetFlag(CI_TOPICLOCK); - ci->c->ChangeTopic(u->nick, topic, Anope::CurTime); + ci->c->ChangeTopic(source.GetNick(), topic, Anope::CurTime); if (has_topiclock) ci->SetFlag(CI_TOPICLOCK); - bool override = !ci->AccessFor(u).HasPriv("TOPIC"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << (!topic.empty() ? "to change the topic to: " : "to unset the topic") << (!topic.empty() ? topic : ""); + bool override = !source.AccessFor(ci).HasPriv("TOPIC"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << (!topic.empty() ? "to change the topic to: " : "to unset the topic") << (!topic.empty() ? topic : ""); } return; } diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp index 24d9caab8..91776b0c0 100644 --- a/modules/commands/cs_unban.cpp +++ b/modules/commands/cs_unban.cpp @@ -24,8 +24,6 @@ class CommandCSUnban : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -39,13 +37,13 @@ class CommandCSUnban : public Command return; } - if (!ci->AccessFor(u).HasPriv("UNBAN")) + if (!source.AccessFor(ci).HasPriv("UNBAN")) { source.Reply(ACCESS_DENIED); return; } - User *u2 = u; + User *u2 = source.GetUser(); if (params.size() > 1) u2 = finduser(params[1]); @@ -55,8 +53,8 @@ class CommandCSUnban : public Command return; } - common_unban(ci, u2, u == u2); - if (u2 == u) + common_unban(ci, u2, source.GetUser() == u2); + if (u2 == source.GetUser()) source.Reply(_("You have been unbanned from \002%s\002."), ci->c->name.c_str()); else source.Reply(_("\002%s\002 has been unbanned from \002%s\002."), u2->nick.c_str(), ci->c->name.c_str()); diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp index 11b2f4749..56841f5a9 100644 --- a/modules/commands/cs_updown.cpp +++ b/modules/commands/cs_updown.cpp @@ -24,7 +24,9 @@ class CommandCSUp : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; + User *u = source.GetUser(); + if (!u) + return; if (params.empty()) for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end(); ++it) @@ -79,7 +81,9 @@ class CommandCSDown : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; + User *u = source.GetUser(); + if (!u) + return; if (params.empty()) for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end(); ++it) diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index a2f97675c..8033efbe1 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -201,7 +201,6 @@ class XOPBase : public Command private: void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms, XOPType level) { - User *u = source.u; Anope::string mask = params.size() > 2 ? params[2] : ""; @@ -221,13 +220,13 @@ class XOPBase : public Command tmp_access.ci = ci; tmp_access.type = level; - AccessGroup access = ci->AccessFor(u); + AccessGroup access = source.AccessFor(ci); const ChanAccess *highest = access.Highest(); bool override = false; if ((!access.Founder && !access.HasPriv("ACCESS_CHANGE")) || ((!highest || *highest <= tmp_access) && !access.Founder)) { - if (u->HasPriv("chanserv/access/modify")) + if (source.HasPriv("chanserv/access/modify")) override = true; else { @@ -254,7 +253,7 @@ class XOPBase : public Command if (a->mask.equals_ci(mask)) { - if ((!highest || *a >= *highest) && !access.Founder && !u->HasPriv("chanserv/access/modify")) + if ((!highest || *a >= *highest) && !access.Founder && !source.HasPriv("chanserv/access/modify")) { source.Reply(ACCESS_DENIED); return; @@ -277,22 +276,21 @@ class XOPBase : public Command XOPChanAccess *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create()); acc->ci = ci; acc->mask = mask; - acc->creator = u->nick; + acc->creator = source.GetNick(); acc->type = level; acc->last_seen = 0; acc->created = Anope::CurTime; ci->AddAccess(acc); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to add " << mask; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask; - FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, acc)); + FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, acc)); source.Reply(_("\002%s\002 added to %s %s list."), acc->mask.c_str(), ci->name.c_str(), source.command.c_str()); } void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms, XOPType level) { - User *u = source.u; - + NickCore *nc = source.nc; const Anope::string &mask = params.size() > 2 ? params[2] : ""; if (mask.empty()) @@ -317,13 +315,13 @@ class XOPBase : public Command tmp_access.ci = ci; tmp_access.type = level; - AccessGroup access = ci->AccessFor(u); + AccessGroup access = source.AccessFor(ci); const ChanAccess *highest = access.Highest(); bool override = false; - if ((!mask.equals_ci(u->Account()->display) && !access.HasPriv("ACCESS_CHANGE") && !access.Founder) || ((!highest || tmp_access >= *highest) && !access.Founder)) + if ((!mask.equals_ci(nc->display) && !access.HasPriv("ACCESS_CHANGE") && !access.Founder) || ((!highest || tmp_access >= *highest) && !access.Founder)) { - if (u->HasPriv("chanserv/access/modify")) + if (source.HasPriv("chanserv/access/modify")) override = true; else { @@ -355,7 +353,7 @@ class XOPBase : public Command source.Reply(_("No matching entries on %s %s list."), ci->name.c_str(), source.command.c_str()); else { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "to delete " << Nicks; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Nicks; if (Deleted == 1) source.Reply(_("Deleted one entry from %s %s list."), ci->name.c_str(), source.command.c_str()); @@ -380,7 +378,7 @@ class XOPBase : public Command else Nicks = caccess->mask; - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source.u, caccess)); + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, caccess)); ci->EraseAccess(Number - 1); } @@ -396,11 +394,11 @@ class XOPBase : public Command if (a->mask.equals_ci(mask) && XOPChanAccess::DetermineLevel(a) == level) { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to delete " << a->mask; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << a->mask; source.Reply(_("\002%s\002 deleted from %s %s list."), a->mask.c_str(), ci->name.c_str(), source.command.c_str()); - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, a)); + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, a)); ci->EraseAccess(a); return; @@ -413,13 +411,12 @@ class XOPBase : public Command void DoList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms, XOPType level) { - User *u = source.u; const Anope::string &nick = params.size() > 2 ? params[2] : ""; - AccessGroup access = ci->AccessFor(u); + AccessGroup access = source.AccessFor(ci); - if (!access.HasPriv("ACCESS_LIST") && !u->HasCommand("chanserv/access/list")) + if (!access.HasPriv("ACCESS_LIST") && !source.HasCommand("chanserv/access/list")) { source.Reply(ACCESS_DENIED); return; @@ -497,7 +494,6 @@ class XOPBase : public Command void DoClear(CommandSource &source, ChannelInfo *ci, XOPType level) { - User *u = source.u; if (readonly) { @@ -511,14 +507,14 @@ class XOPBase : public Command return; } - if (!ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasPriv("chanserv/access/modify")) + if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("chanserv/access/modify")) { source.Reply(ACCESS_DENIED); return; } - bool override = !ci->AccessFor(u).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to clear the access list"; + bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list"; for (unsigned i = ci->GetAccessCount(); i > 0; --i) { @@ -527,7 +523,7 @@ class XOPBase : public Command ci->EraseAccess(i - 1); } - FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u)); + FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, source)); source.Reply(_("Channel %s %s list has been cleared."), ci->name.c_str(), source.command.c_str()); diff --git a/modules/commands/gl_global.cpp b/modules/commands/gl_global.cpp index 0933efb13..2ec39b3b9 100644 --- a/modules/commands/gl_global.cpp +++ b/modules/commands/gl_global.cpp @@ -25,15 +25,14 @@ class CommandGLGlobal : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &msg = params[0]; if (!global) source.Reply("No global reference, is gl_main loaded?"); else { - Log(LOG_ADMIN, u, this); - global->SendGlobal(findbot(Config->Global), u->nick, msg); + Log(LOG_ADMIN, source, this); + global->SendGlobal(findbot(Config->Global), source.GetNick(), msg); } } diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index 7b7c52110..c0c57dbae 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -30,7 +30,6 @@ class CommandHelp : public Command if (MOD_RESULT == EVENT_STOP) return; - User *u = source.u; const BotInfo *bi = source.owner; if (params.empty()) @@ -48,7 +47,7 @@ class CommandHelp : public Command service_reference<Command> c("Command", info.name); if (!c) continue; - if (!Config->HidePrivilegedCommands || info.permission.empty() || u->HasCommand(info.permission)) + if (!Config->HidePrivilegedCommands || info.permission.empty() || source.HasCommand(info.permission)) { source.command = c_name; c->OnServHelp(source); @@ -75,7 +74,7 @@ class CommandHelp : public Command if (!c) continue; - if (Config->HidePrivilegedCommands && !info.permission.empty() && !u->HasCommand(info.permission)) + if (Config->HidePrivilegedCommands && !info.permission.empty() && !source.HasCommand(info.permission)) continue; const Anope::string &subcommand = params.size() > max ? params[max] : ""; @@ -91,14 +90,14 @@ class CommandHelp : public Command source.Reply(" "); source.Reply(_("Access to this command requires the permission \002%s\002 to be present in your opertype."), info.permission.c_str()); } - if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->IsIdentified()) + if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !source.nc) { if (info.permission.empty()) source.Reply(" "); source.Reply( _("You need to be identified to use this command.")); } /* User doesn't have the proper permission to use this command */ - else if (!info.permission.empty() && !u->HasCommand(info.permission)) + else if (!info.permission.empty() && !source.HasCommand(info.permission)) { source.Reply(_("You cannot use this command.")); } diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index 48e11c08c..9ad39a95d 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -24,12 +24,11 @@ class CommandHSDel : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; NickAlias *na = findnick(nick); if (na) { - Log(LOG_ADMIN, u, this) << "for user " << na->nick; + Log(LOG_ADMIN, source, this) << "for user " << na->nick; FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na)); na->RemoveVhost(); source.Reply(_("Vhost for \002%s\002 removed."), nick.c_str()); @@ -60,7 +59,6 @@ class CommandHSDelAll : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { const Anope::string &nick = params[0]; - User *u = source.u; NickAlias *na = findnick(nick); if (na) { @@ -71,7 +69,7 @@ class CommandHSDelAll : public Command na = *it; na->RemoveVhost(); } - Log(LOG_ADMIN, u, this) << "for all nicks in group " << nc->display; + Log(LOG_ADMIN, source, this) << "for all nicks in group " << nc->display; source.Reply(_("vhosts for group \002%s\002 have been removed."), nc->display.c_str()); } else diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index a9c3dc232..f0d030c70 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -37,15 +37,14 @@ class CommandHSGroup : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - NickAlias *na = findnick(u->nick); - if (na && u->Account() == na->nc && na->HasVhost()) + NickAlias *na = findnick(source.GetNick()); + if (na && source.nc == na->nc && na->HasVhost()) { this->Sync(na); if (!na->GetVhostIdent().empty()) - source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002@\002%s\002"), u->Account()->display.c_str(), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); + source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002@\002%s\002"), source.nc->display.c_str(), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); else - source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002"), u->Account()->display.c_str(), na->GetVhostHost().c_str()); + source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002"), source.nc->display.c_str(), na->GetVhostHost().c_str()); } else source.Reply(HOST_NOT_ASSIGNED); diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp index bf7d92dba..39b701fed 100644 --- a/modules/commands/hs_off.cpp +++ b/modules/commands/hs_off.cpp @@ -24,7 +24,10 @@ class CommandHSOff : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; + User *u = source.GetUser(); + if (!u) + return; + const NickAlias *na = findnick(u->nick); if (!na || !na->HasVhost()) @@ -32,7 +35,7 @@ class CommandHSOff : public Command else { ircdproto->SendVhostDel(u); - Log(LOG_COMMAND, u, this) << "to disable their vhost"; + Log(LOG_COMMAND, source, this) << "to disable their vhost"; source.Reply(_("Your vhost was removed and the normal cloaking restored.")); } diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index 223f169fc..91fcaf10e 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -24,7 +24,10 @@ class CommandHSOn : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; + User *u = source.GetUser(); + if (!u) + return; + const NickAlias *na = findnick(u->nick); if (na && u->Account() == na->nc && na->HasVhost()) { @@ -32,7 +35,7 @@ class CommandHSOn : public Command source.Reply(_("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); else source.Reply(_("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); - Log(LOG_COMMAND, u, this) << "to enable their vhost of " << (!na->GetVhostIdent().empty() ? na->GetVhostIdent() + "@" : "") << na->GetVhostHost(); + Log(LOG_COMMAND, source, this) << "to enable their vhost of " << (!na->GetVhostIdent().empty() ? na->GetVhostIdent() + "@" : "") << na->GetVhostHost(); ircdproto->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); if (ircd->vhost) u->vhost = na->GetVhostHost(); diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index ae1077a68..1b08968ae 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -87,13 +87,13 @@ class CommandHSRequest : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - - NickAlias *na = findnick(u->nick); - if (na == NULL) - na = findnick(u->Account()->display); - if (!na) + User *u = source.GetUser(); + NickAlias *na = findnick(source.GetNick()); + if (!na || na->nc != source.nc) + { + source.Reply(ACCESS_DENIED); return; + } Anope::string rawhostmask = params[0]; @@ -163,7 +163,7 @@ class CommandHSRequest : public Command source.Reply(_("Your vHost has been requested")); req_send_memos(source, user, host); - Log(LOG_COMMAND, u, this, NULL) << "to request new vhost " << (!user.empty() ? user + "@" : "") << host; + Log(LOG_COMMAND, source, this) << "to request new vhost " << (!user.empty() ? user + "@" : "") << host; return; } @@ -190,7 +190,6 @@ class CommandHSActivate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; @@ -198,14 +197,14 @@ class CommandHSActivate : public Command HostRequest *req = na ? na->GetExt<HostRequest *>("hs_request") : NULL; if (req) { - na->SetVhost(req->ident, req->host, u->nick, req->time); + na->SetVhost(req->ident, req->host, source.GetNick(), req->time); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (HSRequestMemoUser && memoserv) memoserv->Send(Config->HostServ, na->nick, _("[auto memo] Your requested vHost has been approved."), true); source.Reply(_("vHost for %s has been activated"), na->nick.c_str()); - Log(LOG_COMMAND, u, this, NULL) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host; + Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host; na->Shrink("hs_request"); } else @@ -234,7 +233,6 @@ class CommandHSReject : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; const Anope::string &reason = params.size() > 1 ? params[1] : ""; @@ -257,7 +255,7 @@ class CommandHSReject : public Command } source.Reply(_("vHost for %s has been rejected"), nick.c_str()); - Log(LOG_COMMAND, u, this, NULL) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "") << ")"; + Log(LOG_COMMAND, source, this, NULL) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "") << ")"; } else source.Reply(_("No request for nick %s found."), nick.c_str()); @@ -400,7 +398,7 @@ void req_send_memos(CommandSource &source, const Anope::string &vIdent, const An if (!na) continue; - Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.u->GetMask().c_str()); + Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.GetNick().c_str()); memoserv->Send(Config->HostServ, na->nick, message, true); } diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index d4fbe9d5c..b2509bcea 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -24,7 +24,6 @@ class CommandHSSet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; @@ -80,9 +79,9 @@ class CommandHSSet : public Command return; } - Log(LOG_ADMIN, u, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host; + Log(LOG_ADMIN, source, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host; - na->SetVhost(user, host, u->nick); + na->SetVhost(user, host, source.GetNick()); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (!user.empty()) source.Reply(_("VHost for \002%s\002 set to \002%s\002@\002%s\002."), nick.c_str(), user.c_str(), host.c_str()); @@ -126,7 +125,6 @@ class CommandHSSetAll : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; Anope::string nick = params[0]; @@ -182,9 +180,9 @@ class CommandHSSetAll : public Command return; } - Log(LOG_ADMIN, u, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host; + Log(LOG_ADMIN, source, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host; - na->SetVhost(user, host, u->nick); + na->SetVhost(user, host, source.GetNick()); this->Sync(na); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (!user.empty()) diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index f6f863e71..e4ee9375e 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -28,7 +28,6 @@ class CommandMSCancel : public Command if (!memoserv) return; - User *u = source.u; const Anope::string &nname = params[0]; @@ -46,7 +45,7 @@ class CommandMSCancel : public Command else na = findnick(nname); for (int i = mi->memos->size() - 1; i >= 0; --i) - if (mi->GetMemo(i)->HasFlag(MF_UNREAD) && u->Account()->display.equals_ci(mi->GetMemo(i)->sender)) + if (mi->GetMemo(i)->HasFlag(MF_UNREAD) && source.nc->display.equals_ci(mi->GetMemo(i)->sender)) { if (ischan) FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(i))); diff --git a/modules/commands/ms_check.cpp b/modules/commands/ms_check.cpp index 5b031e8ec..59340b6d7 100644 --- a/modules/commands/ms_check.cpp +++ b/modules/commands/ms_check.cpp @@ -24,7 +24,6 @@ class CommandMSCheck : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &recipient = params[0]; @@ -44,7 +43,7 @@ class CommandMSCheck : public Command for (int i = mi->memos->size() - 1; i >= 0; --i) { - if (u->Account()->display.equals_ci(mi->GetMemo(i)->sender)) + if (source.nc->display.equals_ci(mi->GetMemo(i)->sender)) { found = true; /* Yes, we've found the memo */ diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index bfee5124f..330f45e87 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -31,7 +31,7 @@ class MemoDelCallback : public NumberList if (ci) FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(Number - 1))); else - FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.u->Account(), mi, mi->GetMemo(Number - 1))); + FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.nc, mi, mi->GetMemo(Number - 1))); mi->Del(Number - 1); source.Reply(_("Memo %d has been deleted."), Number); @@ -49,7 +49,6 @@ class CommandMSDel : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; MemoInfo *mi; ChannelInfo *ci = NULL; @@ -71,7 +70,7 @@ class CommandMSDel : public Command source.Reply(READ_ONLY_MODE); return; } - else if (!ci->AccessFor(u).HasPriv("MEMO")) + else if (!source.AccessFor(ci).HasPriv("MEMO")) { source.Reply(ACCESS_DENIED); return; @@ -79,7 +78,7 @@ class CommandMSDel : public Command mi = &ci->memos; } else - mi = const_cast<MemoInfo *>(&u->Account()->memos); + mi = const_cast<MemoInfo *>(&source.nc->memos); if (numstr.empty() || (!isdigit(numstr[0]) && !numstr.equals_ci("ALL") && !numstr.equals_ci("LAST"))) this->OnSyntaxError(source, numstr); else if (mi->memos->empty()) @@ -102,7 +101,7 @@ class CommandMSDel : public Command if (ci) FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(mi->memos->size() - 1))); else - FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, mi->GetMemo(mi->memos->size() - 1))); + FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.nc, mi, mi->GetMemo(mi->memos->size() - 1))); mi->Del(mi->memos->size() - 1); source.Reply(_("Memo %d has been deleted."), mi->memos->size() + 1); } @@ -114,7 +113,7 @@ class CommandMSDel : public Command if (ci) FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(i))); else - FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, mi->GetMemo(i))); + FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.nc, mi, mi->GetMemo(i))); mi->GetMemo(i)->destroy(); } mi->memos->clear(); diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index caea7d147..84ce540a8 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -29,7 +29,6 @@ class CommandMSIgnore : public Command if (!memoserv) return; - User *u = source.u; Anope::string channel = params[0]; Anope::string command = (params.size() > 1 ? params[1] : ""); @@ -39,7 +38,7 @@ class CommandMSIgnore : public Command { param = command; command = channel; - channel = u->nick; + channel = source.GetNick(); } bool ischan; @@ -47,7 +46,7 @@ class CommandMSIgnore : public Command ChannelInfo *ci = cs_findchan(channel); if (!mi) source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), channel.c_str()); - else if (ischan && !ci->AccessFor(u).HasPriv("MEMO")) + else if (ischan && !source.AccessFor(ci).HasPriv("MEMO")) source.Reply(ACCESS_DENIED); else if (command.equals_ci("ADD") && !param.empty()) { diff --git a/modules/commands/ms_info.cpp b/modules/commands/ms_info.cpp index 05d241ced..d2c7eea3b 100644 --- a/modules/commands/ms_info.cpp +++ b/modules/commands/ms_info.cpp @@ -24,15 +24,14 @@ class CommandMSInfo : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - + NickCore *nc = source.nc; const MemoInfo *mi; const NickAlias *na = NULL; ChannelInfo *ci = NULL; const Anope::string &nname = !params.empty() ? params[0] : ""; int hardmax = 0; - if (!nname.empty() && nname[0] != '#' && u->HasPriv("memoserv/info")) + if (!nname.empty() && nname[0] != '#' && source.HasPriv("memoserv/info")) { na = findnick(nname); if (!na) @@ -51,7 +50,7 @@ class CommandMSInfo : public Command source.Reply(CHAN_X_NOT_REGISTERED, nname.c_str()); return; } - else if (!ci->AccessFor(u).HasPriv("MEMO")) + else if (!source.AccessFor(ci).HasPriv("MEMO")) { source.Reply(ACCESS_DENIED); return; @@ -66,11 +65,11 @@ class CommandMSInfo : public Command } else { - mi = &u->Account()->memos; - hardmax = u->Account()->HasFlag(NI_MEMO_HARDMAX) ? 1 : 0; + mi = &nc->memos; + hardmax = nc->HasFlag(NI_MEMO_HARDMAX) ? 1 : 0; } - if (!nname.empty() && (ci || na->nc != u->Account())) + if (!nname.empty() && (ci || na->nc != nc)) { if (mi->memos->empty()) source.Reply(_("%s currently has no memos."), nname.c_str()); @@ -127,7 +126,7 @@ class CommandMSInfo : public Command source.Reply(_("%s is not notified of new memos."), nname.c_str()); } } - else /* !nname || (!ci || na->nc == u->Account()) */ + else /* !nname || (!ci || na->nc == nc) */ { if (mi->memos->empty()) source.Reply(_("You currently have no memos.")); @@ -156,14 +155,14 @@ class CommandMSInfo : public Command if (!mi->memomax) { - if (!u->IsServicesOper() && hardmax) + if (!source.IsServicesOper() && hardmax) source.Reply(_("Your memo limit is \0020\002; you will not receive any new memos. You cannot change this limit.")); else source.Reply(_("Your memo limit is \0020\002; you will not receive any new memos.")); } else if (mi->memomax > 0) { - if (!u->IsServicesOper() && hardmax) + if (!source.IsServicesOper() && hardmax) source.Reply(_("Your memo limit is \002%d\002, and may not be changed."), mi->memomax); else source.Reply(_("Your memo limit is \002%d\002."), mi->memomax); @@ -172,11 +171,11 @@ class CommandMSInfo : public Command source.Reply(_("You have no limit on the number of memos you may keep.")); /* Ripped too. But differently because of a seg fault (loughs) */ - if (u->Account()->HasFlag(NI_MEMO_RECEIVE) && u->Account()->HasFlag(NI_MEMO_SIGNON)) + if (nc->HasFlag(NI_MEMO_RECEIVE) && nc->HasFlag(NI_MEMO_SIGNON)) source.Reply(_("You will be notified of new memos at logon and when they arrive.")); - else if (u->Account()->HasFlag(NI_MEMO_RECEIVE)) + else if (nc->HasFlag(NI_MEMO_RECEIVE)) source.Reply(_("You will be notified when new memos arrive.")); - else if (u->Account()->HasFlag(NI_MEMO_SIGNON)) + else if (nc->HasFlag(NI_MEMO_SIGNON)) source.Reply(_("You will be notified of new memos at logon.")); else source.Reply(_("You will not be notified of new memos.")); diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp index 1ba0644aa..f6a92e9df 100644 --- a/modules/commands/ms_list.cpp +++ b/modules/commands/ms_list.cpp @@ -24,7 +24,6 @@ class CommandMSList : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; Anope::string param = !params.empty() ? params[0] : "", chan; ChannelInfo *ci = NULL; @@ -41,7 +40,7 @@ class CommandMSList : public Command source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); return; } - else if (!ci->AccessFor(u).HasPriv("MEMO")) + else if (!source.AccessFor(ci).HasPriv("MEMO")) { source.Reply(ACCESS_DENIED); return; @@ -49,7 +48,7 @@ class CommandMSList : public Command mi = &ci->memos; } else - mi = &u->Account()->memos; + mi = &source.nc->memos; if (!param.empty() && !isdigit(param[0]) && !param.equals_ci("NEW")) this->OnSyntaxError(source, param); @@ -131,7 +130,7 @@ class CommandMSList : public Command std::vector<Anope::string> replies; list.Process(replies); - source.Reply(_("Memos for %s."), ci ? ci->name.c_str() : u->nick.c_str()); + source.Reply(_("Memos for %s."), ci ? ci->name.c_str() : source.GetNick().c_str()); for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); } diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index 341d8f828..5b46ef0dd 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -36,7 +36,7 @@ static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Ano Anope::string text = Anope::printf(translate(na->nc, _("\002[auto-memo]\002 The memo you sent to %s has been viewed.")), targ.c_str()); /* Send notification */ - memoserv->Send(source.u->nick, m->sender, text, true); + memoserv->Send(source.GetNick(), m->sender, text, true); /* Notify recepient of the memo that a notification has been sent to the sender */ @@ -78,7 +78,7 @@ class MemoListCallback : public NumberList /* Check if a receipt notification was requested */ if (m->HasFlag(MF_RECEIPT)) - rsend_notify(source, mi, m, ci ? ci->name : source.u->nick); + rsend_notify(source, mi, m, ci ? ci->name : source.GetNick()); } }; @@ -93,7 +93,6 @@ class CommandMSRead : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; MemoInfo *mi; ChannelInfo *ci = NULL; @@ -110,7 +109,7 @@ class CommandMSRead : public Command source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); return; } - else if (!ci->AccessFor(u).HasPriv("MEMO")) + else if (!source.AccessFor(ci).HasPriv("MEMO")) { source.Reply(ACCESS_DENIED); return; @@ -118,7 +117,7 @@ class CommandMSRead : public Command mi = &ci->memos; } else - mi = const_cast<MemoInfo *>(&u->Account()->memos); + mi = const_cast<MemoInfo *>(&source.nc->memos); if (numstr.empty() || (!numstr.equals_ci("LAST") && !numstr.equals_ci("NEW") && !numstr.is_number_only())) this->OnSyntaxError(source, numstr); diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp index bf5292dbc..6dc79bb44 100644 --- a/modules/commands/ms_rsend.cpp +++ b/modules/commands/ms_rsend.cpp @@ -28,20 +28,19 @@ class CommandMSRSend : public Command if (!memoserv) return; - User *u = source.u; const Anope::string &nick = params[0]; const Anope::string &text = params[1]; const NickAlias *na = NULL; /* prevent user from rsend to themselves */ - if ((na = findnick(nick)) && na->nc == u->Account()) + if ((na = findnick(nick)) && na->nc == source.nc) { source.Reply(_("You can not request a receipt when sending a memo to yourself.")); return; } - if (Config->MSMemoReceipt == 1 && !u->IsServicesOper()) + if (Config->MSMemoReceipt == 1 && !source.IsServicesOper()) source.Reply(ACCESS_DENIED); else if (Config->MSMemoReceipt > 2 || Config->MSMemoReceipt == 0) { @@ -50,7 +49,7 @@ class CommandMSRSend : public Command } else { - MemoServService::MemoResult result = memoserv->Send(u->nick, nick, text); + MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text); if (result == MemoServService::MEMO_INVALID_TARGET) source.Reply(_("\002%s\002 is not a registered unforbidden nick or channel."), nick.c_str()); else if (result == MemoServService::MEMO_TOO_FAST) diff --git a/modules/commands/ms_send.cpp b/modules/commands/ms_send.cpp index ba33233e8..a2ba53a9e 100644 --- a/modules/commands/ms_send.cpp +++ b/modules/commands/ms_send.cpp @@ -31,7 +31,7 @@ class CommandMSSend : public Command const Anope::string &nick = params[0]; const Anope::string &text = params[1]; - MemoServService::MemoResult result = memoserv->Send(source.u->nick, nick, text); + MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text); if (result == MemoServService::MEMO_SUCCESS) source.Reply(_("Memo sent to \002%s\002."), nick.c_str()); else if (result == MemoServService::MEMO_INVALID_TARGET) diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp index 5a7abdd70..2fba2ecb3 100644 --- a/modules/commands/ms_sendall.cpp +++ b/modules/commands/ms_sendall.cpp @@ -28,7 +28,6 @@ class CommandMSSendAll : public Command if (!memoserv) return; - User *u = source.u; const Anope::string &text = params[0]; if (readonly) @@ -37,14 +36,12 @@ class CommandMSSendAll : public Command return; } - const NickAlias *na = findnick(u->nick); - for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) { const NickCore *nc = it->second; - if ((na && na->nc == nc) || !nc->display.equals_ci(u->nick)) - memoserv->Send(u->nick, nc->display, text); + if (nc != source.nc) + memoserv->Send(source.GetNick(), nc->display, text); } source.Reply(_("A massmemo has been sent to all registered users.")); diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp index ee159c466..998a5a062 100644 --- a/modules/commands/ms_set.cpp +++ b/modules/commands/ms_set.cpp @@ -18,9 +18,8 @@ class CommandMSSet : public Command private: void DoNotify(CommandSource &source, const std::vector<Anope::string> ¶ms, MemoInfo *mi) { - User *u = source.u; const Anope::string ¶m = params[1]; - NickCore *nc = u->Account(); + NickCore *nc = source.nc; if (param.equals_ci("ON")) { @@ -70,16 +69,15 @@ class CommandMSSet : public Command void DoLimit(CommandSource &source, const std::vector<Anope::string> ¶ms, MemoInfo *mi) { - User *u = source.u; Anope::string p1 = params[1]; Anope::string p2 = params.size() > 2 ? params[2] : ""; Anope::string p3 = params.size() > 3 ? params[3] : ""; Anope::string user, chan; int16_t limit; - NickCore *nc = u->Account(); + NickCore *nc = source.nc; ChannelInfo *ci = NULL; - bool is_servadmin = u->HasPriv("memoserv/set-limit"); + bool is_servadmin = source.HasPriv("memoserv/set-limit"); if (p1[0] == '#') { @@ -94,7 +92,7 @@ class CommandMSSet : public Command source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); return; } - else if (!is_servadmin && !ci->AccessFor(u).HasPriv("MEMO")) + else if (!is_servadmin && !source.AccessFor(ci).HasPriv("MEMO")) { source.Reply(ACCESS_DENIED); return; @@ -180,21 +178,21 @@ class CommandMSSet : public Command mi->memomax = limit; if (limit > 0) { - if (chan.empty() && nc == u->Account()) + if (chan.empty() && nc == source.nc) source.Reply(_("Your memo limit has been set to \002%d\002."), limit); else source.Reply(_("Memo limit for %s set to \002%d\002."), !chan.empty() ? chan.c_str() : user.c_str(), limit); } else if (!limit) { - if (chan.empty() && nc == u->Account()) + if (chan.empty() && nc == source.nc) source.Reply(_("You will no longer be able to receive memos.")); else source.Reply(_("Memo limit for %s set to \0020\002."), !chan.empty() ? chan.c_str() : user.c_str()); } else { - if (chan.empty() && nc == u->Account()) + if (chan.empty() && nc == source.nc) source.Reply(_("Your memo limit has been disabled.")); else source.Reply(_("Memo limit \002disabled\002 for %s."), !chan.empty() ? chan.c_str() : user.c_str()); @@ -210,9 +208,8 @@ class CommandMSSet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &cmd = params[0]; - MemoInfo *mi = const_cast<MemoInfo *>(&u->Account()->memos); + MemoInfo *mi = const_cast<MemoInfo *>(&source.nc->memos); if (readonly) source.Reply(_("Sorry, memo option setting is temporarily disabled.")); @@ -263,8 +260,7 @@ class CommandMSSet : public Command "\002ON\002 is essentially \002LOGON\002 and \002NEW\002 combined.")); else if (subcommand.equals_ci("LIMIT")) { - User *u = source.u; - if (u->IsServicesOper()) + if (source.IsServicesOper()) source.Reply(_("Syntax: \002LIMIT [\037user\037 | \037channel\037] {\037limit\037 | NONE} [HARD]\002\n" " \n" "Sets the maximum number of memos a user or channel is\n" diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp index adfe51d68..9896d5971 100644 --- a/modules/commands/ms_staff.cpp +++ b/modules/commands/ms_staff.cpp @@ -40,8 +40,8 @@ class CommandMSStaff : public Command { const NickCore *nc = it->second; - if (nc->IsServicesOper()) - memoserv->Send(source.u->nick, nc->display, text, true); + if (source.nc != nc && nc->IsServicesOper()) + memoserv->Send(source.GetNick(), nc->display, text, true); } return; diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index 5fdba68fb..73748a401 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -94,7 +94,6 @@ class CommandNSAccess : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &cmd = params[0]; Anope::string nick, mask; @@ -115,12 +114,12 @@ class CommandNSAccess : public Command source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); return; } - else if (na->nc != u->Account() && !u->HasPriv("nickserv/access")) + else if (na->nc != source.nc && !source.HasPriv("nickserv/access")) { source.Reply(ACCESS_DENIED); return; } - else if (Config->NSSecureAdmins && u->Account() != na->nc && na->nc->IsServicesOper() && !cmd.equals_ci("LIST")) + else if (Config->NSSecureAdmins && source.nc != na->nc && na->nc->IsServicesOper() && !cmd.equals_ci("LIST")) { source.Reply(_("You may view but not modify the access list of other services operators.")); return; @@ -129,7 +128,7 @@ class CommandNSAccess : public Command nc = na->nc; } else - nc = u->Account(); + nc = source.nc; if (!mask.empty() && (mask.find('@') == Anope::string::npos || mask.find('!') != Anope::string::npos)) { @@ -137,7 +136,7 @@ class CommandNSAccess : public Command source.Reply(MORE_INFO, Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), this->name.c_str()); } else if (nc->HasFlag(NI_SUSPENDED)) - source.Reply(NICK_X_SUSPENDED, u->Account()->display.c_str()); + source.Reply(NICK_X_SUSPENDED, nc->display.c_str()); else if (cmd.equals_ci("ADD")) return this->DoAdd(source, nc, mask); else if (cmd.equals_ci("DEL")) diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index e17f958d0..5a33fb7db 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -82,11 +82,11 @@ class CommandNSAJoin : public Command { void DoList(CommandSource &source, const std::vector<Anope::string> ¶ms) { - AJoinList *channels = source.u->Account()->GetExt<AJoinList *>("ns_ajoin_channels"); + AJoinList *channels = source.nc->GetExt<AJoinList *>("ns_ajoin_channels"); if (channels == NULL) { channels = new AJoinList(); - source.u->Account()->Extend("ns_ajoin_channels", channels); + source.nc->Extend("ns_ajoin_channels", channels); } if ((*channels)->empty()) @@ -117,11 +117,11 @@ class CommandNSAJoin : public Command void DoAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) { - AJoinList *channels = source.u->Account()->GetExt<AJoinList *>("ns_ajoin_channels"); + AJoinList *channels = source.nc->GetExt<AJoinList *>("ns_ajoin_channels"); if (channels == NULL) { channels = new AJoinList(); - source.u->Account()->Extend("ns_ajoin_channels", channels); + source.nc->Extend("ns_ajoin_channels", channels); } unsigned i = 0; @@ -138,7 +138,7 @@ class CommandNSAJoin : public Command else { AJoinEntry *entry = new AJoinEntry(); - entry->owner = source.u->Account(); + entry->owner = source.nc; entry->channel = params[1]; entry->key = params.size() > 2 ? params[2] : ""; (*channels)->push_back(entry); @@ -148,11 +148,11 @@ class CommandNSAJoin : public Command void DoDel(CommandSource &source, const std::vector<Anope::string> ¶ms) { - AJoinList *channels = source.u->Account()->GetExt<AJoinList *>("ns_ajoin_channels"); + AJoinList *channels = source.nc->GetExt<AJoinList *>("ns_ajoin_channels"); if (channels == NULL) { channels = new AJoinList(); - source.u->Account()->Extend("ns_ajoin_channels", channels); + source.nc->Extend("ns_ajoin_channels", channels); } unsigned i = 0; diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index 3ce429e7d..42482e1f9 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -24,10 +24,9 @@ class CommandNSAList : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - Anope::string nick = u->Account()->display; + Anope::string nick = source.GetNick(); - if (params.size() && u->IsServicesOper()) + if (params.size() && source.IsServicesOper()) nick = params[0]; const NickAlias *na = findnick(nick); diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index 2117ed994..da3cb2aa1 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -60,10 +60,10 @@ class CommandNSCert : public Command return; } - if (!source.u->fingerprint.empty() && !nc->FindCert(source.u->fingerprint)) + if (source.GetUser() && !source.GetUser()->fingerprint.empty() && !nc->FindCert(source.GetUser()->fingerprint)) { - nc->AddCert(source.u->fingerprint); - source.Reply(_("\002%s\002 added to your certificate list."), source.u->fingerprint.c_str()); + nc->AddCert(source.GetUser()->fingerprint); + source.Reply(_("\002%s\002 added to your certificate list."), source.GetUser()->fingerprint.c_str()); return; } @@ -86,11 +86,10 @@ class CommandNSCert : public Command void DoDel(CommandSource &source, NickCore *nc, const Anope::string &mask) { - - if (!source.u->fingerprint.empty() && nc->FindCert(source.u->fingerprint)) + if (source.GetUser() && !source.GetUser()->fingerprint.empty() && nc->FindCert(source.GetUser()->fingerprint)) { - nc->EraseCert(source.u->fingerprint); - source.Reply(_("\002%s\002 deleted from your certificate list."), source.u->fingerprint.c_str()); + nc->EraseCert(source.GetUser()->fingerprint); + source.Reply(_("\002%s\002 deleted from your certificate list."), source.GetUser()->fingerprint.c_str()); return; } @@ -114,11 +113,10 @@ class CommandNSCert : public Command void DoList(CommandSource &source, const NickCore *nc) { - User *u = source.u; if (nc->cert.empty()) { - source.Reply(_("Your certificate list is empty."), u->nick.c_str()); + source.Reply(_("Your certificate list is empty.")); return; } @@ -150,18 +148,17 @@ class CommandNSCert : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &cmd = params[0]; const Anope::string &mask = params.size() > 1 ? params[1] : ""; const NickAlias *na; - if (cmd.equals_ci("LIST") && u->IsServicesOper() && !mask.empty() && (na = findnick(mask))) + if (cmd.equals_ci("LIST") && source.IsServicesOper() && !mask.empty() && (na = findnick(mask))) return this->DoServAdminList(source, na->nc); - NickCore *nc = u->Account(); + NickCore *nc = source.nc; - if (u->Account()->HasFlag(NI_SUSPENDED)) - source.Reply(NICK_X_SUSPENDED, u->Account()->display.c_str()); + if (source.nc->HasFlag(NI_SUSPENDED)) + source.Reply(NICK_X_SUSPENDED, source.nc->display.c_str()); else if (cmd.equals_ci("ADD")) return this->DoAdd(source, nc, mask); else if (cmd.equals_ci("DEL")) diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp index 442655c0f..9f6de6f5a 100644 --- a/modules/commands/ns_drop.cpp +++ b/modules/commands/ns_drop.cpp @@ -18,13 +18,11 @@ class CommandNSDrop : public Command public: CommandNSDrop(Module *creator) : Command(creator, "nickserv/drop", 0, 1) { - this->SetFlag(CFLAG_ALLOW_UNREGISTERED); this->SetDesc(_("Cancel the registration of a nickname")); } void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; Anope::string nick = !params.empty() ? params[0] : ""; if (readonly) @@ -33,25 +31,19 @@ class CommandNSDrop : public Command return; } - NickAlias *na = findnick((u->Account() && !nick.empty() ? nick : u->nick)); + NickAlias *na = findnick(!nick.empty() ? nick : source.GetNick()); if (!na) { source.Reply(NICK_NOT_REGISTERED); return; } - if (!u->Account()) - { - source.Reply(NICK_IDENTIFY_REQUIRED, Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str()); - return; - } - - bool is_mine = u->Account() == na->nc; + bool is_mine = source.nc == na->nc; Anope::string my_nick; if (is_mine && nick.empty()) my_nick = na->nick; - if (!is_mine && !u->HasPriv("nickserv/drop")) + if (!is_mine && !source.HasPriv("nickserv/drop")) source.Reply(ACCESS_DENIED); else if (Config->NSSecureAdmins && !is_mine && na->nc->IsServicesOper()) source.Reply(_("You may not drop other services operators nicknames.")); @@ -60,9 +52,9 @@ class CommandNSDrop : public Command if (readonly) source.Reply(READ_ONLY_MODE); - FOREACH_MOD(I_OnNickDrop, OnNickDrop(u, na)); + FOREACH_MOD(I_OnNickDrop, OnNickDrop(source, na)); - Log(!is_mine ? LOG_OVERRIDE : LOG_COMMAND, u, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; + Log(!is_mine ? LOG_OVERRIDE : LOG_COMMAND, source, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; na->destroy(); if (!is_mine) @@ -83,8 +75,7 @@ class CommandNSDrop : public Command bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { - User *u = source.u; - if (u->Account() && u->HasPriv("nickserv/drop")) + if (source.HasPriv("nickserv/drop")) source.Reply(_("Syntax: \002%s [\037nickname\037]\002\n" " \n" "Without a parameter, deletes your nickname.\n" diff --git a/modules/commands/ns_getemail.cpp b/modules/commands/ns_getemail.cpp index 6301ddd4e..a21c8c1b5 100644 --- a/modules/commands/ns_getemail.cpp +++ b/modules/commands/ns_getemail.cpp @@ -28,11 +28,10 @@ class CommandNSGetEMail : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &email = params[0]; int j = 0; - Log(LOG_ADMIN, u, this) << "on " << email; + Log(LOG_ADMIN, source, this) << "on " << email; for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it) { diff --git a/modules/commands/ns_getpass.cpp b/modules/commands/ns_getpass.cpp index e5cf4a7ac..2e5efdf4d 100644 --- a/modules/commands/ns_getpass.cpp +++ b/modules/commands/ns_getpass.cpp @@ -24,7 +24,6 @@ class CommandNSGetPass : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; Anope::string tmp_pass; const NickAlias *na; @@ -37,7 +36,7 @@ class CommandNSGetPass : public Command { if (enc_decrypt(na->nc->pass, tmp_pass) == 1) { - Log(LOG_ADMIN, u, this) << "for " << nick; + Log(LOG_ADMIN, source, this) << "for " << nick; source.Reply(_("Password for %s is \002%s\002."), nick.c_str(), tmp_pass.c_str()); } else diff --git a/modules/commands/ns_ghost.cpp b/modules/commands/ns_ghost.cpp index f68ddb83e..074c133b2 100644 --- a/modules/commands/ns_ghost.cpp +++ b/modules/commands/ns_ghost.cpp @@ -28,7 +28,6 @@ class CommandNSGhost : public Command const Anope::string &nick = params[0]; const Anope::string &pass = params.size() > 1 ? params[1] : ""; - User *u = source.u; User *user = finduser(nick); const NickAlias *na = findnick(nick); @@ -40,16 +39,16 @@ class CommandNSGhost : public Command source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (na->nc->HasFlag(NI_SUSPENDED)) source.Reply(NICK_X_SUSPENDED, na->nick.c_str()); - else if (nick.equals_ci(u->nick)) + else if (nick.equals_ci(source.GetNick())) source.Reply(_("You can't ghost yourself!")); else { bool ok = false; - if (u->Account() == na->nc) + if (source.nc == na->nc) ok = true; - else if (!na->nc->HasFlag(NI_SECURE) && is_on_access(u, na->nc)) + else if (!na->nc->HasFlag(NI_SECURE) && source.GetUser() && is_on_access(source.GetUser(), na->nc)) ok = true; - else if (!u->fingerprint.empty() && na->nc->FindCert(u->fingerprint)) + else if (source.GetUser() && !source.GetUser()->fingerprint.empty() && na->nc->FindCert(source.GetUser()->fingerprint)) ok = true; else if (!pass.empty()) { @@ -67,8 +66,8 @@ class CommandNSGhost : public Command source.Reply(_("You may not ghost an unidentified user, use RECOVER instead.")); else { - Log(LOG_COMMAND, u, this) << "for " << nick; - Anope::string buf = "GHOST command used by " + u->nick; + Log(LOG_COMMAND, source, this) << "for " << nick; + Anope::string buf = "GHOST command used by " + source.GetNick(); user->Kill(Config->NickServ, buf); source.Reply(_("Ghost with your nick has been killed."), nick.c_str()); } @@ -78,8 +77,9 @@ class CommandNSGhost : public Command source.Reply(ACCESS_DENIED); if (!pass.empty()) { - Log(LOG_COMMAND, u, this) << "with an invalid password for " << nick; - bad_password(u); + Log(LOG_COMMAND, source, this) << "with an invalid password for " << nick; + if (source.GetUser()) + bad_password(source.GetUser()); } } } diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index 8b611e6f2..48255d848 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -25,7 +25,10 @@ class CommandNSGroup : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; + User *u = source.GetUser(); + + if (!u) + return; const Anope::string &nick = params[0]; const Anope::string &pass = params.size() > 1 ? params[1] : ""; @@ -61,7 +64,7 @@ class CommandNSGroup : public Command source.Reply(_("Please wait %d seconds before using the GROUP command again."), (Config->NSRegDelay + u->lastnickreg) - Anope::CurTime); else if (target && target->nc->HasFlag(NI_SUSPENDED)) { - Log(LOG_COMMAND, u, this) << "tried to use GROUP for SUSPENDED nick " << target->nick; + Log(LOG_COMMAND, source, this) << "tried to use GROUP for SUSPENDED nick " << target->nick; source.Reply(NICK_X_SUSPENDED, target->nick.c_str()); } else if (na && *target->nc == *na->nc) @@ -123,14 +126,14 @@ class CommandNSGroup : public Command u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target)); - Log(LOG_COMMAND, u, this) << "makes " << u->nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")"; + Log(LOG_COMMAND, source, this) << "makes " << u->nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")"; source.Reply(_("You are now in the group of \002%s\002."), target->nick.c_str()); u->lastnickreg = Anope::CurTime; } else { - Log(LOG_COMMAND, u, this) << "failed group for " << target->nick; + Log(LOG_COMMAND, source, this) << "failed group for " << target->nick; source.Reply(PASSWORD_INCORRECT); bad_password(u); } @@ -183,7 +186,10 @@ class CommandNSUngroup : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; + User *u = source.GetUser(); + if (!u) + return; + Anope::string nick = !params.empty() ? params[0] : ""; NickAlias *na = findnick(!nick.empty() ? nick : u->nick); @@ -249,7 +255,6 @@ class CommandNSGList : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = !params.empty() ? params[0] : ""; const NickCore *nc; @@ -261,7 +266,7 @@ class CommandNSGList : public Command source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); return; } - else if (!u->IsServicesOper()) + else if (!source.IsServicesOper()) { source.Reply(ACCESS_DENIED, Config->NickServ.c_str()); return; @@ -270,7 +275,7 @@ class CommandNSGList : public Command nc = na->nc; } else - nc = u->Account(); + nc = source.nc; ListFormatter list; list.addColumn("Nick").addColumn("Expires"); @@ -298,8 +303,7 @@ class CommandNSGList : public Command bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { - User *u = source.u; - if (u->IsServicesOper()) + if (source.IsServicesOper()) source.Reply(_("Syntax: \002%s [\037nickname\037]\002\n" " \n" "Without a parameter, lists all nicknames that are in\n" diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp index cd0b14ddb..9fbe46f6b 100644 --- a/modules/commands/ns_identify.cpp +++ b/modules/commands/ns_identify.cpp @@ -25,7 +25,10 @@ class CommandNSIdentify : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; + User *u = source.GetUser(); + + if (!u) + return; const Anope::string &nick = params.size() == 2 ? params[0] : u->nick; Anope::string pass = params[params.size() - 1]; @@ -46,16 +49,16 @@ class CommandNSIdentify : public Command source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (MOD_RESULT != EVENT_ALLOW) { - Log(LOG_COMMAND, u, this) << "and failed to identify"; + Log(LOG_COMMAND, source, this) << "and failed to identify"; source.Reply(PASSWORD_INCORRECT); bad_password(u); } else { if (u->IsIdentified()) - Log(LOG_COMMAND, u, this) << "to log out of account " << u->Account()->display; + Log(LOG_COMMAND, source, this) << "to log out of account " << u->Account()->display; - Log(LOG_COMMAND, u, this) << "and identified for account " << na->nc->display; + Log(LOG_COMMAND, source, this) << "and identified for account " << na->nc->display; source.Reply(_("Password accepted - you are now recognized.")); u->Identify(na); } diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index 20ed6ee42..94126e93b 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -16,14 +16,14 @@ class CommandNSInfo : public Command { private: - template<typename T, unsigned END> void CheckOptStr(User *u, Anope::string &buf, T opt, const char *str, const Flags<T, END> *nc, bool reverse_logic = false) + template<typename T, unsigned END> void CheckOptStr(NickCore *core, Anope::string &buf, T opt, const char *str, const Flags<T, END> *nc, bool reverse_logic = false) { if (reverse_logic ? !nc->HasFlag(opt) : nc->HasFlag(opt)) { if (!buf.empty()) buf += ", "; - buf += translate(u, str); + buf += translate(core, str); } } public: @@ -36,11 +36,10 @@ class CommandNSInfo : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - const Anope::string &nick = params.size() ? params[0] : (u->Account() ? u->Account()->display : u->nick); + const Anope::string &nick = params.size() ? params[0] : (source.nc ? source.nc->display : source.GetNick()); NickAlias *na = findnick(nick); - bool has_auspex = u->IsIdentified() && u->HasPriv("nickserv/auspex"); + bool has_auspex = source.HasPriv("nickserv/auspex"); if (!na) { @@ -58,7 +57,7 @@ class CommandNSInfo : public Command if (u2 && u2->Account() == na->nc) nick_online = true; - if (has_auspex || (u->Account() && na->nc == u->Account())) + if (has_auspex || na->nc == source.nc) show_hidden = true; source.Reply(_("%s is %s"), na->nick.c_str(), na->last_realname.c_str()); @@ -69,7 +68,7 @@ class CommandNSInfo : public Command if (na->nc->IsServicesOper() && (show_hidden || !na->nc->HasFlag(NI_HIDE_STATUS))) source.Reply(_("%s is a services operator of type %s."), na->nick.c_str(), na->nc->o->ot->GetName().c_str()); - InfoFormatter info(u); + InfoFormatter info(source.nc); if (nick_online) { @@ -114,14 +113,14 @@ class CommandNSInfo : public Command Anope::string optbuf; - CheckOptStr<NickCoreFlag, NI_END>(u, optbuf, NI_KILLPROTECT, _("Protection"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(u, optbuf, NI_SECURE, _("Security"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(u, optbuf, NI_PRIVATE, _("Private"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(u, optbuf, NI_MSG, _("Message mode"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(u, optbuf, NI_AUTOOP, _("Auto-op"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(u, optbuf, NI_SUSPENDED, _("Suspended"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(u, optbuf, NI_STATS, _("Chanstats"), na->nc); - CheckOptStr<NickNameFlag, NS_END>(u, optbuf, NS_NO_EXPIRE, _("No expire"), na); + CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_KILLPROTECT, _("Protection"), na->nc); + CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_SECURE, _("Security"), na->nc); + CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_PRIVATE, _("Private"), na->nc); + CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_MSG, _("Message mode"), na->nc); + CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_AUTOOP, _("Auto-op"), na->nc); + CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_SUSPENDED, _("Suspended"), na->nc); + CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_STATS, _("Chanstats"), na->nc); + CheckOptStr<NickNameFlag, NS_END>(source.nc, optbuf, NS_NO_EXPIRE, _("No expire"), na); info[_("Options")] = optbuf.empty() ? _("None") : optbuf; diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp index 25766ef1e..89adfc6ea 100644 --- a/modules/commands/ns_list.cpp +++ b/modules/commands/ns_list.cpp @@ -24,12 +24,11 @@ class CommandNSList : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; Anope::string pattern = params[0]; const NickCore *mync; unsigned nnicks; - bool is_servadmin = u->HasCommand("nickserv/list"); + bool is_servadmin = source.HasCommand("nickserv/list"); int count = 0, from = 0, to = 0; bool suspended, nsnoexpire, unconfirmed; @@ -70,7 +69,7 @@ class CommandNSList : public Command } } - mync = u->Account(); + mync = source.nc; ListFormatter list; list.addColumn("Nick").addColumn("Last usermask"); diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp index 240054db6..4e0dc7131 100644 --- a/modules/commands/ns_logout.cpp +++ b/modules/commands/ns_logout.cpp @@ -25,16 +25,15 @@ class CommandNSLogout : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = !params.empty() ? params[0] : ""; const Anope::string ¶m = params.size() > 1 ? params[1] : ""; User *u2; - if (!u->IsServicesOper() && !nick.empty()) + if (!source.IsServicesOper() && !nick.empty()) this->OnSyntaxError(source, ""); - else if (!(u2 = (!nick.empty() ? finduser(nick) : u))) - source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); + else if (!(u2 = (!nick.empty() ? finduser(nick) : source.GetUser()))) + source.Reply(NICK_X_NOT_IN_USE, !nick.empty() ? nick.c_str() : source.GetNick().c_str()); else if (!nick.empty() && u2->IsServicesOper()) source.Reply(_("You can't logout %s because they are a Services Operator."), nick.c_str()); else @@ -43,7 +42,7 @@ class CommandNSLogout : public Command nickserv->Validate(u2); u2->SuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */ - Log(LOG_COMMAND, u, this) << "to logout " << u2->nick; + Log(LOG_COMMAND, source, this) << "to logout " << u2->nick; /* Remove founder status from this user in all channels */ if (!nick.empty()) diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index e985f2881..b74703a48 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -44,7 +44,6 @@ class CommandNSRecover : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; const Anope::string &pass = params.size() > 1 ? params[1] : ""; @@ -59,7 +58,7 @@ class CommandNSRecover : public Command source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (na->nc->HasFlag(NI_SUSPENDED)) source.Reply(NICK_X_SUSPENDED, na->nick.c_str()); - else if (nick.equals_ci(u->nick)) + else if (nick.equals_ci(source.GetNick())) source.Reply(_("You can't recover yourself!")); else if (!pass.empty()) { @@ -75,17 +74,22 @@ class CommandNSRecover : public Command else { source.Reply(ACCESS_DENIED); - Log(LOG_COMMAND, u, this) << "with invalid password for " << nick; - bad_password(u); + Log(LOG_COMMAND, source, this) << "with invalid password for " << nick; + if (source.GetUser()) + bad_password(source.GetUser()); } } else { - if (u->Account() == na->nc || (!na->nc->HasFlag(NI_SECURE) && is_on_access(u, na->nc)) || - (!u->fingerprint.empty() && na->nc->FindCert(u->fingerprint))) - { + bool ok = false; + if (source.nc == na->nc) + ok = true; + else if (!na->nc->HasFlag(NI_SECURE) && source.GetUser() && is_on_access(source.GetUser(), na->nc)) + ok = true; + else if (source.GetUser() && !source.GetUser()->fingerprint.empty() && na->nc->FindCert(source.GetUser()->fingerprint)) + ok = true; + if (ok) this->DoRecover(source, u2, na, nick); - } else source.Reply(ACCESS_DENIED); } diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index f19cf7218..05a87c4cf 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -32,10 +32,9 @@ class CommandNSConfirm : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &passcode = params[0]; - if (u->Account() && !u->Account()->HasFlag(NI_UNCONFIRMED) && u->HasPriv("nickserv/confirm")) + if (source.nc && !source.nc->HasFlag(NI_UNCONFIRMED) && source.HasPriv("nickserv/confirm")) { NickAlias *na = findnick(passcode); if (na == NULL) @@ -45,25 +44,28 @@ class CommandNSConfirm : public Command else { na->nc->UnsetFlag(NI_UNCONFIRMED); - Log(LOG_ADMIN, u, this) << "to confirm nick " << na->nick << " (" << na->nc->display << ")"; + Log(LOG_ADMIN, source, this) << "to confirm nick " << na->nick << " (" << na->nc->display << ")"; source.Reply(_("Nick \002%s\002 has been confirmed."), na->nick.c_str()); } } - else if (u->Account()) + else if (source.nc) { - Anope::string *code = u->Account()->GetExt<ExtensibleString *>("ns_register_passcode"); + Anope::string *code = source.nc->GetExt<ExtensibleString *>("ns_register_passcode"); if (code != NULL && *code == passcode) { - NickCore *nc = u->Account(); + NickCore *nc = source.nc; nc->Shrink("ns_register_passcode"); - Log(LOG_COMMAND, u, this) << "to confirm their email"; - source.Reply(_("Your email address of \002%s\002 has been confirmed."), u->Account()->email.c_str()); + Log(LOG_COMMAND, source, this) << "to confirm their email"; + source.Reply(_("Your email address of \002%s\002 has been confirmed."), source.nc->email.c_str()); nc->UnsetFlag(NI_UNCONFIRMED); - ircdproto->SendLogin(u); - const NickAlias *na = findnick(u->nick); - if (!Config->NoNicknameOwnership && na != NULL && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + if (source.GetUser()) + { + ircdproto->SendLogin(source.GetUser()); + const NickAlias *na = findnick(source.GetNick()); + if (!Config->NoNicknameOwnership && na != NULL && na->nc == source.nc && na->nc->HasFlag(NI_UNCONFIRMED) == false) + source.GetUser()->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + } } else source.Reply(_("Invalid passcode.")); @@ -76,7 +78,6 @@ class CommandNSConfirm : public Command bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { - User *u = source.u; this->SendSyntax(source); source.Reply(" "); source.Reply(_("This command is used by several commands as a way to confirm\n" @@ -87,7 +88,7 @@ class CommandNSConfirm : public Command " \n" "This is also used after the RESETPASS command has been used to\n" "force identify you to your nick so you may change your password.")); - if (u->Account() && u->HasPriv("nickserv/confirm")) + if (source.HasPriv("nickserv/confirm")) source.Reply(_("Additionally, Services Operators with the \037nickserv/confirm\037 permission can\n" "replace \037passcode\037 with a users nick to force validate them.")); return true; @@ -114,10 +115,11 @@ class CommandNSRegister : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; NickAlias *na; size_t prefixlen = Config->NSGuestNickPrefix.length(); - size_t nicklen = u->nick.length(); + User *u = source.GetUser(); + Anope::string u_nick = source.GetNick(); + size_t nicklen = u_nick.length(); Anope::string pass = params[0]; Anope::string email = params.size() > 1 ? params[1] : ""; @@ -133,7 +135,7 @@ class CommandNSRegister : public Command return; } - if (!u->HasMode(UMODE_OPER) && Config->NickRegDelay && Anope::CurTime - u->my_signon < Config->NickRegDelay) + if (u && !u->HasMode(UMODE_OPER) && Config->NickRegDelay && Anope::CurTime - u->my_signon < Config->NickRegDelay) { source.Reply(_("You must have been using this nick for at least %d seconds to register."), Config->NickRegDelay); return; @@ -144,15 +146,15 @@ class CommandNSRegister : public Command /* Guest nick can now have a series of between 1 and 7 digits. * --lara */ - if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1 && !u->nick.find_ci(Config->NSGuestNickPrefix) && u->nick.substr(prefixlen).find_first_not_of("1234567890") == Anope::string::npos) + if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1 && !u_nick.find_ci(Config->NSGuestNickPrefix) && u_nick.substr(prefixlen).find_first_not_of("1234567890") == Anope::string::npos) { - source.Reply(NICK_CANNOT_BE_REGISTERED, u->nick.c_str()); + source.Reply(NICK_CANNOT_BE_REGISTERED, u_nick.c_str()); return; } - if (!ircdproto->IsNickValid(u->nick)) + if (!ircdproto->IsNickValid(u_nick)) { - source.Reply(NICK_CANNOT_BE_REGISTERED, u->nick.c_str()); + source.Reply(NICK_CANNOT_BE_REGISTERED, u_nick.c_str()); return; } @@ -161,20 +163,20 @@ class CommandNSRegister : public Command { Oper *o = Config->Opers[i]; - if (!u->HasMode(UMODE_OPER) && u->nick.find_ci(o->name) != Anope::string::npos) + if (!source.IsOper() && u_nick.find_ci(o->name) != Anope::string::npos) { - source.Reply(NICK_CANNOT_BE_REGISTERED, u->nick.c_str()); + source.Reply(NICK_CANNOT_BE_REGISTERED, u_nick.c_str()); return; } } if (Config->NSForceEmail && email.empty()) this->OnSyntaxError(source, ""); - else if (Anope::CurTime < u->lastnickreg + Config->NSRegDelay) + else if (u && Anope::CurTime < u->lastnickreg + Config->NSRegDelay) source.Reply(_("Please wait %d seconds before using the REGISTER command again."), (u->lastnickreg + Config->NSRegDelay) - Anope::CurTime); - else if ((na = findnick(u->nick))) - source.Reply(NICK_ALREADY_REGISTERED, u->nick.c_str()); - else if (pass.equals_ci(u->nick) || (Config->StrictPasswords && pass.length() < 5)) + else if ((na = findnick(u_nick))) + source.Reply(NICK_ALREADY_REGISTERED, u_nick.c_str()); + else if (pass.equals_ci(u_nick) || (Config->StrictPasswords && pass.length() < 5)) source.Reply(MORE_OBSCURE_PASSWORD); else if (pass.length() > Config->PassLen) source.Reply(PASSWORD_TOO_LONG); @@ -182,28 +184,30 @@ class CommandNSRegister : public Command source.Reply(MAIL_X_INVALID, email.c_str()); else { - NickCore *nc = new NickCore(u->nick); - na = new NickAlias(u->nick, nc); + NickCore *nc = new NickCore(u_nick); + na = new NickAlias(u_nick, nc); enc_encrypt(pass, nc->pass); if (!email.empty()) nc->email = email; - Anope::string last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost(); - na->last_usermask = last_usermask; - na->last_realname = u->realname; + if (u) + { + na->last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost(); + na->last_realname = u->realname; + + u->Login(nc); + } if (Config->NSAddAccessOnReg) nc->AddAccess(create_mask(u)); - u->Login(nc); - - Log(LOG_COMMAND, u, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; + Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; FOREACH_MOD(I_OnNickRegister, OnNickRegister(na)); if (Config->NSAddAccessOnReg) - source.Reply(_("Nickname \002%s\002 registered under your account: %s"), u->nick.c_str(), na->nc->GetAccess(0).c_str()); + source.Reply(_("Nickname \002%s\002 registered under your account: %s"), u_nick.c_str(), na->nc->GetAccess(0).c_str()); else - source.Reply(_("Nickname \002%s\002 registered."), u->nick.c_str()); + source.Reply(_("Nickname \002%s\002 registered."), u_nick.c_str()); Anope::string tmp_pass; if (enc_decrypt(na->nc->pass, tmp_pass) == 1) @@ -226,14 +230,13 @@ class CommandNSRegister : public Command else if (Config->NSRegistration.equals_ci("none")) { ircdproto->SendLogin(u); - if (!Config->NoNicknameOwnership && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false) + if (!Config->NoNicknameOwnership && u && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false) u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); } - u->lastnickreg = Anope::CurTime; + if (u) + u->lastnickreg = Anope::CurTime; } - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -288,25 +291,24 @@ class CommandNSResend : public Command if (Config->NSRegistration.equals_ci("mail")) return; - User *u = source.u; - const NickAlias *na = findnick(u->nick); + const NickAlias *na = findnick(source.GetNick()); if (na == NULL) source.Reply(NICK_NOT_REGISTERED); - else if (na->nc != u->Account() || u->Account()->HasFlag(NI_UNCONFIRMED) == false) + else if (na->nc != source.nc || source.nc->HasFlag(NI_UNCONFIRMED) == false) source.Reply(_("Your account is already confirmed.")); else { - if (Anope::CurTime < u->Account()->lastmail + Config->NSResendDelay) + if (Anope::CurTime < source.nc->lastmail + Config->NSResendDelay) source.Reply(_("Cannot send mail now; please retry a little later.")); - else if (SendRegmail(u, na, source.owner)) + else if (SendRegmail(source.GetUser(), na, source.owner)) { na->nc->lastmail = Anope::CurTime; source.Reply(_("Your passcode has been re-sent to %s."), na->nc->email.c_str()); - Log(LOG_COMMAND, u, this) << "to resend registration verification code"; + Log(LOG_COMMAND, source, this) << "to resend registration verification code"; } else - Log() << "Unable to resend registration verification code for " << u->nick; + Log() << "Unable to resend registration verification code for " << source.GetNick(); } return; diff --git a/modules/commands/ns_release.cpp b/modules/commands/ns_release.cpp index 3c5a230b3..44c89fbf7 100644 --- a/modules/commands/ns_release.cpp +++ b/modules/commands/ns_release.cpp @@ -25,7 +25,6 @@ class CommandNSRelease : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; Anope::string pass = params.size() > 1 ? params[1] : ""; NickAlias *na; @@ -45,26 +44,32 @@ class CommandNSRelease : public Command if (MOD_RESULT == EVENT_ALLOW) { - Log(LOG_COMMAND, u, this) << "for nickname " << na->nick; + Log(LOG_COMMAND, source, this) << "for nickname " << na->nick; na->Release(); source.Reply(_("Services' hold on \002%s\002 has been released."), nick.c_str()); } else { source.Reply(ACCESS_DENIED); - Log(LOG_COMMAND, u, this) << "invalid password for " << nick; - bad_password(u); + Log(LOG_COMMAND, source, this) << "invalid password for " << nick; + if (source.GetUser()) + bad_password(source.GetUser()); } } else { - bool override = u->Account() != na->nc && u->HasPriv("nickserv/release"); + bool override = source.nc != na->nc && source.HasPriv("nickserv/release"); - if (override || u->Account() == na->nc || - (!na->nc->HasFlag(NI_SECURE) && is_on_access(u, na->nc)) || - (!u->fingerprint.empty() && na->nc->FindCert(u->fingerprint))) + bool ok = override; + if (source.nc == na->nc) + ok = true; + else if (source.GetUser() && !na->nc->HasFlag(NI_SECURE) && is_on_access(source.GetUser(), na->nc)) + ok = true; + else if (source.GetUser() && !source.GetUser()->fingerprint.empty() && na->nc->FindCert(source.GetUser()->fingerprint)) + ok = true; + if (ok) { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this) << "for nickname " << na->nick; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this) << "for nickname " << na->nick; na->Release(); source.Reply(_("Services' hold on \002%s\002 has been released."), nick.c_str()); } diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index 21c5d7a4f..6102c2d85 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -27,18 +27,17 @@ class CommandNSResetPass : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const NickAlias *na; - if (Config->RestrictMail && (!u->Account() || !u->HasCommand("nickserv/resetpass"))) + if (Config->RestrictMail && source.HasCommand("nickserv/resetpass")) source.Reply(ACCESS_DENIED); else if (!(na = findnick(params[0]))) source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str()); else { - if (SendResetEmail(u, na, source.owner)) + if (SendResetEmail(source.GetUser(), na, source.owner)) { - Log(LOG_COMMAND, u, this) << "for " << na->nick << " (group: " << na->nc->display << ")"; + Log(LOG_COMMAND, source, this) << "for " << na->nick << " (group: " << na->nc->display << ")"; source.Reply(_("Password reset email for \002%s\002 has been sent."), na->nick.c_str()); } } @@ -83,7 +82,6 @@ class NSResetPass : public Module { if (command->name == "nickserv/confirm" && params.size() > 1) { - User *u = source.u; NickAlias *na = findnick(params[0]); ResetInfo *ri = na ? na->nc->GetExt<ResetInfo *>("ns_resetpass") : NULL; @@ -100,13 +98,15 @@ class NSResetPass : public Module { nc->Shrink("ns_resetpass"); - Log(LOG_COMMAND, u, &commandnsresetpass) << "confirmed RESETPASS to forcefully identify to " << na->nick; + Log(LOG_COMMAND, source, &commandnsresetpass) << "confirmed RESETPASS to forcefully identify to " << na->nick; nc->UnsetFlag(NI_UNCONFIRMED); - u->Identify(na); - - source.Reply(_("You are now identified for your nick. Change your password now.")); + if (source.GetUser()) + { + source.GetUser()->Identify(na); + source.Reply(_("You are now identified for your nick. Change your password now.")); + } } else return EVENT_CONTINUE; diff --git a/modules/commands/ns_saset.cpp b/modules/commands/ns_saset.cpp index 240ef0e07..f49af06e9 100644 --- a/modules/commands/ns_saset.cpp +++ b/modules/commands/ns_saset.cpp @@ -66,7 +66,6 @@ class CommandNSSASetPassword : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const NickAlias *setter_na = findnick(params[0]); if (setter_na == NULL) { @@ -77,7 +76,7 @@ class CommandNSSASetPassword : public Command size_t len = params[1].length(); - if (Config->NSSecureAdmins && u->Account() != nc && nc->IsServicesOper()) + if (Config->NSSecureAdmins && source.nc != nc && nc->IsServicesOper()) { source.Reply(_("You may not change the password of other services operators.")); return; diff --git a/modules/commands/ns_sendpass.cpp b/modules/commands/ns_sendpass.cpp index deff5419c..6b2b2533b 100644 --- a/modules/commands/ns_sendpass.cpp +++ b/modules/commands/ns_sendpass.cpp @@ -27,11 +27,10 @@ class CommandNSSendPass : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; const NickAlias *na; - if (Config->RestrictMail && (!u->Account() || !u->HasCommand("nickserv/sendpass"))) + if (Config->RestrictMail && !source.HasCommand("nickserv/sendpass")) source.Reply(ACCESS_DENIED); else if (!(na = findnick(nick))) source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -40,9 +39,9 @@ class CommandNSSendPass : public Command Anope::string tmp_pass; if (enc_decrypt(na->nc->pass, tmp_pass) == 1) { - if (SendPassMail(u, na, source.owner, tmp_pass)) + if (SendPassMail(source.GetUser(), na, source.owner, tmp_pass)) { - Log(Config->RestrictMail ? LOG_ADMIN : LOG_COMMAND, u, this) << "for " << na->nick; + Log(Config->RestrictMail ? LOG_ADMIN : LOG_COMMAND, source, this) << "for " << na->nick; source.Reply(_("Password of \002%s\002 has been sent."), nick.c_str()); } } diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 110373853..719ddc4f3 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -66,12 +66,11 @@ class CommandNSSetPassword : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string ¶m = params[1]; unsigned len = param.length(); - if (u->Account()->display.equals_ci(param) || (Config->StrictPasswords && len < 5)) + if (source.GetNick().equals_ci(param) || (Config->StrictPasswords && len < 5)) { source.Reply(MORE_OBSCURE_PASSWORD); return; @@ -82,12 +81,12 @@ class CommandNSSetPassword : public Command return; } - enc_encrypt(param, u->Account()->pass); + enc_encrypt(param, source.nc->pass); Anope::string tmp_pass; - if (enc_decrypt(u->Account()->pass, tmp_pass) == 1) - source.Reply(_("Password for \002%s\002 changed to \002%s\002."), u->Account()->display.c_str(), tmp_pass.c_str()); + if (enc_decrypt(source.nc->pass, tmp_pass) == 1) + source.Reply(_("Password for \002%s\002 changed to \002%s\002."), source.nc->display.c_str(), tmp_pass.c_str()); else - source.Reply(_("Password for \002%s\002 changed."), u->Account()->display.c_str()); + source.Reply(_("Password for \002%s\002 changed."), source.nc->display.c_str()); return; } diff --git a/modules/commands/ns_set_autoop.cpp b/modules/commands/ns_set_autoop.cpp index 0cf9c649a..f69264add 100644 --- a/modules/commands/ns_set_autoop.cpp +++ b/modules/commands/ns_set_autoop.cpp @@ -50,7 +50,7 @@ class CommandNSSetAutoOp : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params[0]); + this->Run(source, source.nc->display, params[0]); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_set_chanstats.cpp b/modules/commands/ns_set_chanstats.cpp index 3d5064839..d624e52c6 100644 --- a/modules/commands/ns_set_chanstats.cpp +++ b/modules/commands/ns_set_chanstats.cpp @@ -48,7 +48,7 @@ class CommandNSSetChanstats : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params[0]); + this->Run(source, source.nc->display, params[0]); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_set_display.cpp b/modules/commands/ns_set_display.cpp index 3a4973181..9c70cfa07 100644 --- a/modules/commands/ns_set_display.cpp +++ b/modules/commands/ns_set_display.cpp @@ -43,7 +43,7 @@ class CommandNSSetDisplay : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params[0]); + this->Run(source, source.nc->display, params[0]); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_set_email.cpp b/modules/commands/ns_set_email.cpp index 16a622db1..0d5b5d27c 100644 --- a/modules/commands/ns_set_email.cpp +++ b/modules/commands/ns_set_email.cpp @@ -59,7 +59,6 @@ class CommandNSSetEmail : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - User *u = source.u; const NickAlias *na = findnick(user); if (!na) { @@ -73,7 +72,7 @@ class CommandNSSetEmail : public Command source.Reply(_("You cannot unset the e-mail on this network.")); return; } - else if (Config->NSSecureAdmins && u->Account() != nc && nc->IsServicesOper()) + else if (Config->NSSecureAdmins && source.nc != nc && nc->IsServicesOper()) { source.Reply(_("You may not change the email of other services operators.")); return; @@ -84,14 +83,14 @@ class CommandNSSetEmail : public Command return; } - if (!param.empty() && Config->NSConfirmEmailChanges && !u->IsServicesOper()) + if (!param.empty() && Config->NSConfirmEmailChanges && !source.IsServicesOper()) { - u->Account()->Extend("ns_set_email", new ExtensibleString(param)); - Anope::string old = u->Account()->email; - u->Account()->email = param; - if (SendConfirmMail(u, source.owner)) + source.nc->Extend("ns_set_email", new ExtensibleString(param)); + Anope::string old = source.nc->email; + source.nc->email = param; + if (SendConfirmMail(source.GetUser(), source.owner)) source.Reply(_("A confirmation email has been sent to \002%s\002. Follow the instructions in it to change your email address."), param.c_str()); - u->Account()->email = old; + source.nc->email = old; } else { @@ -112,7 +111,7 @@ class CommandNSSetEmail : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params.size() ? params[0] : ""); + this->Run(source, source.nc->display, params.size() ? params[0] : ""); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override @@ -166,18 +165,17 @@ class NSSetEmail : public Module EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - if (command->name == "nickserv/confirm" && !params.empty() && u->IsIdentified()) + NickCore *uac = source.nc; + if (command->name == "nickserv/confirm" && !params.empty() && uac) { - Anope::string *new_email = u->Account()->GetExt<ExtensibleString *>("ns_set_email"), *passcode = u->Account()->GetExt<ExtensibleString *>("ns_set_email_passcode"); + Anope::string *new_email = uac->GetExt<ExtensibleString *>("ns_set_email"), *passcode = uac->GetExt<ExtensibleString *>("ns_set_email_passcode"); if (new_email && passcode) { if (params[0] == *passcode) { - NickCore *uac = u->Account(); uac->email = *new_email; - Log(LOG_COMMAND, u, command) << "to confirm their email address change to " << u->Account()->email; - source.Reply(_("Your email address has been changed to \002%s\002."), u->Account()->email.c_str()); + Log(LOG_COMMAND, source, command) << "to confirm their email address change to " << uac->email; + source.Reply(_("Your email address has been changed to \002%s\002."), uac->email.c_str()); uac->Shrink("ns_set_email"); uac->Shrink("ns_set_email_passcode"); return EVENT_STOP; diff --git a/modules/commands/ns_set_greet.cpp b/modules/commands/ns_set_greet.cpp index 0bdb1b371..65e8ffd7f 100644 --- a/modules/commands/ns_set_greet.cpp +++ b/modules/commands/ns_set_greet.cpp @@ -48,7 +48,7 @@ class CommandNSSetGreet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params.size() > 0 ? params[0] : ""); + this->Run(source, source.nc->display, params.size() > 0 ? params[0] : ""); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_set_hide.cpp b/modules/commands/ns_set_hide.cpp index 1bdecb181..063200d15 100644 --- a/modules/commands/ns_set_hide.cpp +++ b/modules/commands/ns_set_hide.cpp @@ -83,7 +83,7 @@ class CommandNSSetHide : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params[0], params[1]); + this->Run(source, source.nc->display, params[0], params[1]); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_set_kill.cpp b/modules/commands/ns_set_kill.cpp index d2e40268e..8d0ea08cf 100644 --- a/modules/commands/ns_set_kill.cpp +++ b/modules/commands/ns_set_kill.cpp @@ -73,7 +73,7 @@ class CommandNSSetKill : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params[0]); + this->Run(source, source.nc->display, params[0]); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_set_language.cpp b/modules/commands/ns_set_language.cpp index 4d3ba2c0e..a4b7d5aef 100644 --- a/modules/commands/ns_set_language.cpp +++ b/modules/commands/ns_set_language.cpp @@ -51,7 +51,7 @@ class CommandNSSetLanguage : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶m) anope_override { - this->Run(source, source.u->Account()->display, param[0]); + this->Run(source, source.nc->display, param[0]); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_set_message.cpp b/modules/commands/ns_set_message.cpp index a56c3fd77..ccc204189 100644 --- a/modules/commands/ns_set_message.cpp +++ b/modules/commands/ns_set_message.cpp @@ -56,7 +56,7 @@ class CommandNSSetMessage : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params[0]); + this->Run(source, source.nc->display, params[0]); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index f9000f387..c4c7b4ae3 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -105,7 +105,7 @@ class CommandNSSetMisc : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, !params.empty() ? params[0] : ""); + this->Run(source, source.nc->display, !params.empty() ? params[0] : ""); } }; diff --git a/modules/commands/ns_set_private.cpp b/modules/commands/ns_set_private.cpp index 7b175942d..ae9b6a473 100644 --- a/modules/commands/ns_set_private.cpp +++ b/modules/commands/ns_set_private.cpp @@ -50,7 +50,7 @@ class CommandNSSetPrivate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params[0]); + this->Run(source, source.nc->display, params[0]); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_set_secure.cpp b/modules/commands/ns_set_secure.cpp index 46be1a250..9b94451cc 100644 --- a/modules/commands/ns_set_secure.cpp +++ b/modules/commands/ns_set_secure.cpp @@ -48,7 +48,7 @@ class CommandNSSetSecure : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - this->Run(source, source.u->Account()->display, params[0]); + this->Run(source, source.nc->display, params[0]); } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/ns_status.cpp b/modules/commands/ns_status.cpp index b6a06b7a0..7a5a68a5a 100644 --- a/modules/commands/ns_status.cpp +++ b/modules/commands/ns_status.cpp @@ -25,8 +25,7 @@ class CommandNSStatus : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - const Anope::string &nick = !params.empty() ? params[0] : u->nick; + const Anope::string &nick = !params.empty() ? params[0] : source.GetNick(); const NickAlias *na = findnick(nick); spacesepstream sep(nick); Anope::string nickbuf; diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index 4fcbe6c38..dd3da66f6 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -70,7 +70,6 @@ class CommandNSSuspend : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; Anope::string expiry = params[1]; @@ -139,7 +138,7 @@ class CommandNSSuspend : public Command nc->Extend("ns_suspend_expire", ns); } - Log(LOG_ADMIN, u, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << "), expires in " << (expiry_secs ? do_strftime(Anope::CurTime + expiry_secs) : "never"); + Log(LOG_ADMIN, source, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << "), expires in " << (expiry_secs ? do_strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("Nick %s is now suspended."), nick.c_str()); FOREACH_MOD(I_OnNickSuspended, OnNickSuspend(na)); @@ -170,7 +169,6 @@ class CommandNSUnSuspend : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; if (readonly) @@ -195,7 +193,7 @@ class CommandNSUnSuspend : public Command na->nc->UnsetFlag(NI_SUSPENDED); na->nc->Shrink("ns_suspend_expire"); - Log(LOG_ADMIN, u, this) << "for " << na->nick; + Log(LOG_ADMIN, source, this) << "for " << na->nick; source.Reply(_("Nick %s is now released."), nick.c_str()); FOREACH_MOD(I_OnNickUnsuspended, OnNickUnsuspended(na)); diff --git a/modules/commands/ns_update.cpp b/modules/commands/ns_update.cpp index 5297bc4d3..b4affe547 100644 --- a/modules/commands/ns_update.cpp +++ b/modules/commands/ns_update.cpp @@ -24,22 +24,21 @@ class CommandNSUpdate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; + User *u = source.GetUser(); + if (!u) + return; + NickAlias *na = findnick(u->nick); - if (!na) + if (na && na->nc == source.nc) { - source.Reply(NICK_NOT_REGISTERED); - return; + na->last_realname = u->realname; + na->last_seen = Anope::CurTime; } - na->last_realname = u->realname; - na->last_seen = Anope::CurTime; - FOREACH_MOD(I_OnNickUpdate, OnNickUpdate(u)); source.Reply(_("Status updated (memos, vhost, chmodes, flags)."), Config->NickServ.c_str()); - return; } bool OnHelp(CommandSource &source, const Anope::string &) anope_override diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp index dec9b9ae9..ff840d353 100644 --- a/modules/commands/os_akill.cpp +++ b/modules/commands/os_akill.cpp @@ -59,7 +59,6 @@ class CommandOSAKill : public Command private: void DoAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) { - User *u = source.u; Anope::string expiry, mask; if (params.size() < 2) @@ -159,7 +158,7 @@ class CommandOSAKill : public Command return; } - XLine *x = new XLine(mask, u->nick, expires, reason); + XLine *x = new XLine(mask, source.GetNick(), expires, reason); if (Config->AkillIds) x->UID = XLineManager::GenerateUID(); @@ -172,13 +171,13 @@ class CommandOSAKill : public Command if (percent > 95) { source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str()); - Log(LOG_ADMIN, u, this) << "tried to akill " << percent << "% of the network (" << affected << " users)"; + Log(LOG_ADMIN, source, this) << "tried to akill " << percent << "% of the network (" << affected << " users)"; x->destroy(); return; } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, akills)); + FOREACH_RESULT(I_OnAddXLine, OnAddXLine(source, x, akills)); if (MOD_RESULT == EVENT_STOP) { x->destroy(); @@ -191,14 +190,13 @@ class CommandOSAKill : public Command source.Reply(_("\002%s\002 added to the AKILL list."), mask.c_str()); - Log(LOG_ADMIN, u, this) << "on " << mask << " (" << x->Reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + Log(LOG_ADMIN, source, this) << "on " << mask << " (" << x->Reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; if (readonly) source.Reply(READ_ONLY_MODE); } void DoDel(CommandSource &source, const std::vector<Anope::string> ¶ms) { - User *u = source.u; const Anope::string &mask = params.size() > 1 ? params[1] : ""; if (mask.empty()) @@ -230,7 +228,7 @@ class CommandOSAKill : public Command do { - FOREACH_MOD(I_OnDelXLine, OnDelXLine(u, x, akills)); + FOREACH_MOD(I_OnDelXLine, OnDelXLine(source, x, akills)); source.Reply(_("\002%s\002 deleted from the AKILL list."), x->Mask.c_str()); AkillDelCallback::DoDel(source, x); @@ -295,7 +293,7 @@ class CommandOSAKill : public Command entry["Mask"] = x->Mask; entry["Creator"] = x->By; entry["Created"] = do_strftime(x->Created, NULL, true); - entry["Expires"] = expire_left(source.u->Account(), x->Expires); + entry["Expires"] = expire_left(source.nc, x->Expires); entry["Reason"] = x->Reason; list.addEntry(entry); } @@ -348,12 +346,11 @@ class CommandOSAKill : public Command void DoClear(CommandSource &source) { - User *u = source.u; for (unsigned i = akills->GetCount(); i > 0; --i) { XLine *x = akills->GetEntry(i - 1); - FOREACH_MOD(I_OnDelXLine, OnDelXLine(u, x, akills)); + FOREACH_MOD(I_OnDelXLine, OnDelXLine(source, x, akills)); akills->DelXLine(x); } diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp index bbfb5121b..456525a46 100644 --- a/modules/commands/os_chankill.cpp +++ b/modules/commands/os_chankill.cpp @@ -29,7 +29,6 @@ class CommandOSChanKill : public Command if (!akills) return; - User *u = source.u; Anope::string expiry, channel; time_t expires; unsigned last_param = 1; @@ -67,7 +66,7 @@ class CommandOSChanKill : public Command { Anope::string realreason; if (Config->AddAkiller) - realreason = "[" + u->nick + "] " + reason; + realreason = "[" + source.GetNick() + "] " + reason; else realreason = reason; @@ -80,12 +79,12 @@ class CommandOSChanKill : public Command if (uc->user->server == Me || uc->user->HasMode(UMODE_OPER)) continue; - XLine *x = new XLine("*@" + uc->user->host, u->nick, expires, realreason, XLineManager::GenerateUID()); + XLine *x = new XLine("*@" + uc->user->host, source.GetNick(), expires, realreason, XLineManager::GenerateUID()); akills->AddXLine(x); akills->OnMatch(uc->user, x); } - Log(LOG_ADMIN, u, this) << "on " << c->name << " (" << realreason << ")"; + Log(LOG_ADMIN, source, this) << "on " << c->name << " (" << realreason << ")"; } else source.Reply(CHAN_X_NOT_IN_USE, channel.c_str()); diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index d1a890106..11437a087 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -141,7 +141,7 @@ class CommandOSConfig : public Command ChangeHash(Config->config_data, params[1], params[2], params[3]); - Log(LOG_ADMIN, source.u, this) << "to change the configuration value of " << params[1] << ":" << params[2] << " to " << params[3]; + Log(LOG_ADMIN, source, this) << "to change the configuration value of " << params[1] << ":" << params[2] << " to " << params[3]; source.Reply(_("Value of %s:%s changed to %s"), params[1].c_str(), params[2].c_str(), params[3].c_str()); return; } @@ -154,7 +154,7 @@ class CommandOSConfig : public Command /* Blocks we should show */ const Anope::string show_blocks[] = { "botserv", "chanserv", "defcon", "global", "memoserv", "nickserv", "networkinfo", "operserv", "options", "" }; - Log(LOG_ADMIN, source.u, this) << "VIEW"; + Log(LOG_ADMIN, source, this) << "VIEW"; for (ConfigDataHash::const_iterator it = Config->config_data.begin(), it_end = Config->config_data.end(); it != it_end; ++it) { diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index ee167e079..bc3265512 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -171,7 +171,6 @@ class CommandOSDefcon : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &lvl = params[0]; if (lvl.empty()) @@ -209,7 +208,7 @@ class CommandOSDefcon : public Command source.Reply(_("Services are now at DEFCON \002%d\002"), DConfig.defaultlevel); this->SendLevels(source); - Log(LOG_ADMIN, u, this) << "to change defcon level to " << newLevel; + Log(LOG_ADMIN, source, this) << "to change defcon level to " << newLevel; /* Global notice the user what is happening. Also any Message that the Admin would like to add. Set in config file. */ diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index bd67d13da..b9609b00a 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -136,7 +136,7 @@ class CommandOSForbid : public Command } d->mask = entry; - d->creator = source.u->nick; + d->creator = source.GetNick(); d->reason = reason; d->created = Anope::CurTime; d->expires = expiryt; @@ -144,7 +144,7 @@ class CommandOSForbid : public Command if (created) this->fs->AddForbid(d); - Log(LOG_ADMIN, source.u, this) << "to add a forbid on " << entry << " of type " << subcommand; + Log(LOG_ADMIN, source, this) << "to add a forbid on " << entry << " of type " << subcommand; source.Reply(_("Added a%s forbid on %s to expire on %s"), ftype == FT_CHAN ? "n" : "", entry.c_str(), d->expires ? do_strftime(d->expires).c_str() : "never"); } else if (command.equals_ci("DEL") && params.size() > 2 && ftype != FT_NONE) @@ -154,7 +154,7 @@ class CommandOSForbid : public Command ForbidData *d = this->fs->FindForbid(entry, ftype); if (d != NULL) { - Log(LOG_ADMIN, source.u, this) << "to remove forbid " << d->mask << " of type " << subcommand; + Log(LOG_ADMIN, source, this) << "to remove forbid " << d->mask << " of type " << subcommand; source.Reply(_("%s deleted from the %s forbid list."), d->mask.c_str(), subcommand.c_str()); this->fs->RemoveForbid(d); } @@ -304,7 +304,7 @@ class OSForbid : public Module EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override { - if (source.u->HasMode(UMODE_OPER)) + if (source.IsOper()) return EVENT_CONTINUE; else if (command->name == "nickserv/register" && params.size() > 1) { diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp index 68f4c5517..2377c28be 100644 --- a/modules/commands/os_ignore.cpp +++ b/modules/commands/os_ignore.cpp @@ -170,7 +170,7 @@ class CommandOSIgnore : public Command return; } - ignore_service->AddIgnore(nick, source.u->nick, reason, t); + ignore_service->AddIgnore(nick, source.GetNick(), reason, t); if (!t) source.Reply(_("\002%s\002 will now permanently be ignored."), nick.c_str()); else diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp index e11ed9f04..34c28a864 100644 --- a/modules/commands/os_jupe.cpp +++ b/modules/commands/os_jupe.cpp @@ -24,7 +24,6 @@ class CommandOSJupe : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &jserver = params[0]; const Anope::string &reason = params.size() > 1 ? params[1] : ""; Server *server = Server::Find(jserver); @@ -35,13 +34,13 @@ class CommandOSJupe : public Command source.Reply(_("You can not jupe your services server or your uplink server.")); else { - Anope::string rbuf = "Juped by " + u->nick + (!reason.empty() ? ": " + reason : ""); + Anope::string rbuf = "Juped by " + source.GetNick() + (!reason.empty() ? ": " + reason : ""); if (server) ircdproto->SendSquit(server, rbuf); Server *juped_server = new Server(Me, jserver, 1, rbuf, ircd->ts6 ? ts6_sid_retrieve() : "", SERVER_JUPED); ircdproto->SendServer(juped_server); - Log(LOG_ADMIN, u, this) << "on " << jserver << " (" << rbuf << ")"; + Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")"; } return; } diff --git a/modules/commands/os_kick.cpp b/modules/commands/os_kick.cpp index f5dce15c7..e3dd8cf8d 100644 --- a/modules/commands/os_kick.cpp +++ b/modules/commands/os_kick.cpp @@ -24,7 +24,6 @@ class CommandOSKick : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &chan = params[0]; const Anope::string &nick = params[1]; const Anope::string &s = params[2]; @@ -47,8 +46,8 @@ class CommandOSKick : public Command return; } - c->Kick(source.owner, u2, "%s (%s)", u->nick.c_str(), s.c_str()); - Log(LOG_ADMIN, u, this) << "on " << u2->nick << " in " << c->name << " (" << s << ")"; + c->Kick(source.owner, u2, "%s (%s)", source.GetNick().c_str(), s.c_str()); + Log(LOG_ADMIN, source, this) << "on " << u2->nick << " in " << c->name << " (" << s << ")"; return; } diff --git a/modules/commands/os_kill.cpp b/modules/commands/os_kill.cpp index bee5777ea..e7f78b1b5 100644 --- a/modules/commands/os_kill.cpp +++ b/modules/commands/os_kill.cpp @@ -24,7 +24,6 @@ class CommandOSKill : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; Anope::string reason = params.size() > 1 ? params[1] : ""; @@ -38,8 +37,8 @@ class CommandOSKill : public Command if (reason.empty()) reason = "No reason specified"; if (Config->AddAkiller) - reason = "(" + u->nick + ") " + reason; - Log(LOG_ADMIN, u, this) << "on " << u2->nick << " for " << reason; + reason = "(" + source.GetNick() + ") " + reason; + Log(LOG_ADMIN, source, this) << "on " << u2->nick << " for " << reason; u2->Kill(Config->OperServ, reason); } } diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp index 1bae1cf58..0ceac6428 100644 --- a/modules/commands/os_login.cpp +++ b/modules/commands/os_login.cpp @@ -27,22 +27,26 @@ class CommandOSLogin : public Command { const Anope::string &password = params[0]; - Oper *o = source.u->Account()->o; + User *u = source.GetUser(); + if (!u) + return; + + Oper *o = source.nc->o; if (o == NULL) source.Reply(_("No oper block for your nick.")); else if (o->password.empty()) source.Reply(_("Your oper block doesn't require logging in.")); - else if (source.u->HasExt("os_login_password_correct")) + else if (u->HasExt("os_login_password_correct")) source.Reply(_("You are already identified.")); else if (o->password != password) { source.Reply(PASSWORD_INCORRECT); - bad_password(source.u); + bad_password(u); } else { - Log(LOG_ADMIN, source.u, this) << "and successfully identified to " << source.owner->nick; - source.u->Extend("os_login_password_correct", NULL); + Log(LOG_ADMIN, source, this) << "and successfully identified to " << source.owner->nick; + u->Extend("os_login_password_correct", NULL); source.Reply(_("Password accepted.")); } @@ -71,17 +75,21 @@ class CommandOSLogout : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Oper *o = source.u->Account()->o; + User *u = source.GetUser(); + if (!u) + return; + + Oper *o = source.nc->o; if (o == NULL) source.Reply(_("No oper block for your nick.")); else if (o->password.empty()) source.Reply(_("Your oper block doesn't require logging in.")); - else if (!source.u->HasExt("os_login_password_correct")) + else if (!u->HasExt("os_login_password_correct")) source.Reply(_("You are not identified.")); else { - Log(LOG_ADMIN, source.u, this); - source.u->Shrink("os_login_password_correct"); + Log(LOG_ADMIN, source, this); + u->Shrink("os_login_password_correct"); source.Reply(_("You have been logged out.")); } } diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index d5836fe51..55e5145c2 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -24,7 +24,6 @@ class CommandOSMode : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &target = params[0]; const Anope::string &modes = params[1]; @@ -37,7 +36,7 @@ class CommandOSMode : public Command { c->SetModes(source.owner, false, modes.c_str()); - Log(LOG_ADMIN, u, this) << modes << " on " << target; + Log(LOG_ADMIN, source, this) << modes << " on " << target; } } @@ -62,7 +61,6 @@ class CommandOSUMode : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &target = params[0]; const Anope::string &modes = params[1]; @@ -74,9 +72,9 @@ class CommandOSUMode : public Command u2->SetModes(source.owner, "%s", modes.c_str()); source.Reply(_("Changed usermodes of \002%s\002 to %s."), u2->nick.c_str(), modes.c_str()); - u2->SendMessage(source.owner, _("\002%s\002 changed your usermodes to %s."), u->nick.c_str(), modes.c_str()); + u2->SendMessage(source.owner, _("\002%s\002 changed your usermodes to %s."), source.GetNick().c_str(), modes.c_str()); - Log(LOG_ADMIN, u, this) << modes << " on " << target; + Log(LOG_ADMIN, source, this) << modes << " on " << target; } } diff --git a/modules/commands/os_module.cpp b/modules/commands/os_module.cpp index 6d7a5db04..1d3c1d30a 100644 --- a/modules/commands/os_module.cpp +++ b/modules/commands/os_module.cpp @@ -24,13 +24,12 @@ class CommandOSModLoad : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &mname = params[0]; - ModuleReturn status = ModuleManager::LoadModule(mname, u); + ModuleReturn status = ModuleManager::LoadModule(mname, source.GetUser()); if (status == MOD_ERR_OK) { - Log(LOG_ADMIN, u, this) << "to load module " << mname; + Log(LOG_ADMIN, source, this) << "to load module " << mname; source.Reply(_("Module \002%s\002 loaded"), mname.c_str()); } else if (status == MOD_ERR_EXISTS) @@ -62,7 +61,6 @@ class CommandOSModReLoad : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &mname = params[0]; Module *m = ModuleManager::FindModule(mname); @@ -80,7 +78,7 @@ class CommandOSModReLoad : public Command /* Unrecoverable */ bool fatal = m->type == PROTOCOL; - ModuleReturn status = ModuleManager::UnloadModule(m, u); + ModuleReturn status = ModuleManager::UnloadModule(m, source.GetUser()); if (status != MOD_ERR_OK) { @@ -88,10 +86,10 @@ class CommandOSModReLoad : public Command return; } - status = ModuleManager::LoadModule(mname, u); + status = ModuleManager::LoadModule(mname, source.GetUser()); if (status == MOD_ERR_OK) { - Log(LOG_ADMIN, u, this) << "to reload module " << mname; + Log(LOG_ADMIN, source, this) << "to reload module " << mname; source.Reply(_("Module \002%s\002 reloaded"), mname.c_str()); } else @@ -128,7 +126,6 @@ class CommandOSModUnLoad : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &mname = params[0]; Module *m = ModuleManager::FindModule(mname); @@ -146,11 +143,11 @@ class CommandOSModUnLoad : public Command Log() << "Trying to unload module [" << mname << "]"; - ModuleReturn status = ModuleManager::UnloadModule(m, u); + ModuleReturn status = ModuleManager::UnloadModule(m, source.GetUser()); if (status == MOD_ERR_OK) { - Log(LOG_ADMIN, u, this) << "to unload module " << mname; + Log(LOG_ADMIN, source, this) << "to unload module " << mname; source.Reply(_("Module \002%s\002 unloaded"), mname.c_str()); } else diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index 456661c46..ba23c431d 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -158,7 +158,7 @@ class NewsBase : public Command news->type = ntype; news->text = text; news->time = Anope::CurTime; - news->who = source.u->nick; + news->who = source.GetNick(); this->ns->AddNewsItem(news); diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp index 454299c89..21ec0dd91 100644 --- a/modules/commands/os_noop.cpp +++ b/modules/commands/os_noop.cpp @@ -25,7 +25,6 @@ class CommandOSNOOP : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &cmd = params[0]; const Anope::string &server = params[1]; @@ -37,10 +36,10 @@ class CommandOSNOOP : public Command /* Remove the O:lines */ ircdproto->SendSVSNOOP(s, true); - Log(LOG_ADMIN, u, this) << "SET on " << s->GetName(); + Log(LOG_ADMIN, source, this) << "SET on " << s->GetName(); source.Reply(_("All O:lines of \002%s\002 have been removed."), s->GetName().c_str()); - Anope::string reason = "NOOP command used by " + u->nick; + Anope::string reason = "NOOP command used by " + source.GetNick(); /* Kill all the IRCops of the server */ for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end();) { @@ -53,7 +52,7 @@ class CommandOSNOOP : public Command } else if (cmd.equals_ci("REVOKE")) { - Log(LOG_ADMIN, u, this) << "REVOKE on " << s->GetName(); + Log(LOG_ADMIN, source, this) << "REVOKE on " << s->GetName(); ircdproto->SendSVSNOOP(s, false); source.Reply(_("All O:lines of \002%s\002 have been reset."), s->GetName().c_str()); } diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp index 3076da434..a468281e0 100644 --- a/modules/commands/os_oline.cpp +++ b/modules/commands/os_oline.cpp @@ -24,7 +24,6 @@ class CommandOSOLine : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; const Anope::string &flag = params[1]; User *u2 = NULL; @@ -38,13 +37,13 @@ class CommandOSOLine : public Command u2->SetMode(source.owner, UMODE_OPER); u2->SendMessage(source.owner, _("You are now an IRC Operator.")); source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str()); - Log(LOG_ADMIN, u, this) << "for " << nick; + Log(LOG_ADMIN, source, this) << "for " << nick; } else if (u2 && flag[0] == '-') { ircdproto->SendSVSO(source.owner, nick, flag); source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str()); - Log(LOG_ADMIN, u, this) << "for " << nick; + Log(LOG_ADMIN, source, this) << "for " << nick; } else this->OnSyntaxError(source, ""); diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp index fe9b06f9f..528ff7382 100644 --- a/modules/commands/os_oper.cpp +++ b/modules/commands/os_oper.cpp @@ -87,7 +87,7 @@ class CommandOSOper : public Command { na->nc->o = new MyOper(na->nc->display, ot); - Log(LOG_ADMIN, source.u, this) << "ADD " << na->nick << " as type " << ot->GetName(); + Log(LOG_ADMIN, source, this) << "ADD " << na->nick << " as type " << ot->GetName(); source.Reply("%s (%s) added to the \2%s\2 list.", na->nick.c_str(), na->nc->display.c_str(), ot->GetName().c_str()); } } @@ -106,7 +106,7 @@ class CommandOSOper : public Command delete na->nc->o; na->nc->o = NULL; - Log(LOG_ADMIN, source.u, this) << "DEL " << na->nick; + Log(LOG_ADMIN, source, this) << "DEL " << na->nick; source.Reply(_("Oper privileges removed from %s (%s)."), na->nick.c_str(), na->nc->display.c_str()); } } diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 8383a88f8..0de82d05a 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -140,7 +140,7 @@ class ExceptionDelCallback : public NumberList static void DoDel(CommandSource &source, unsigned index) { Exception *e = session_service->GetExceptions()[index]; - FOREACH_MOD(I_OnExceptionDel, OnExceptionDel(source.u, e)); + FOREACH_MOD(I_OnExceptionDel, OnExceptionDel(source, e)); session_service->DelException(e); e->destroy(); @@ -261,7 +261,6 @@ class CommandOSException : public Command private: void DoAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) { - User *u = source.u; Anope::string mask, expiry, limitstr; unsigned last_param = 3; @@ -340,7 +339,7 @@ class CommandOSException : public Command exception->limit = limit; exception->reason = reason; exception->time = Anope::CurTime; - exception->who = u->nick; + exception->who = source.GetNick(); exception->expires = expires; EventReturn MOD_RESULT; diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp index ec08e0322..9ecae3105 100644 --- a/modules/commands/os_set.cpp +++ b/modules/commands/os_set.cpp @@ -18,7 +18,7 @@ class CommandOSSet : public Command private: void DoList(CommandSource &source) { - Log(LOG_ADMIN, source.u, this); + Log(LOG_ADMIN, source, this); Anope::string index; @@ -34,7 +34,6 @@ class CommandOSSet : public Command void DoSetReadOnly(CommandSource &source, const std::vector<Anope::string> ¶ms) { - User *u = source.u; const Anope::string &setting = params.size() > 1 ? params[1] : ""; if (setting.empty()) @@ -46,13 +45,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { readonly = true; - Log(LOG_ADMIN, u, this) << "READONLY ON"; + Log(LOG_ADMIN, source, this) << "READONLY ON"; source.Reply(_("Services are now in \002read-only\002 mode.")); } else if (setting.equals_ci("OFF")) { readonly = false; - Log(LOG_ADMIN, u, this) << "READONLY OFF"; + Log(LOG_ADMIN, source, this) << "READONLY OFF"; source.Reply(_("Services are now in \002read-write\002 mode.")); } else @@ -63,9 +62,11 @@ class CommandOSSet : public Command void DoSetSuperAdmin(CommandSource &source, const std::vector<Anope::string> ¶ms) { - User *u = source.u; const Anope::string &setting = params.size() > 1 ? params[1] : ""; + if (!source.GetUser()) + return; + if (setting.empty()) { this->OnSyntaxError(source, "SUPERADMIN"); @@ -81,15 +82,15 @@ class CommandOSSet : public Command source.Reply(_("SuperAdmin setting not enabled in services.conf")); else if (setting.equals_ci("ON")) { - u->SuperAdmin = true; + source.GetUser()->SuperAdmin = true; source.Reply(_("You are now a SuperAdmin")); - Log(LOG_ADMIN, u, this) << "SUPERADMIN ON"; + Log(LOG_ADMIN, source, this) << "SUPERADMIN ON"; } else if (setting.equals_ci("OFF")) { - u->SuperAdmin = false; + source.GetUser()->SuperAdmin = false; source.Reply(_("You are no longer a SuperAdmin")); - Log(LOG_ADMIN, u, this) << "SUPERADMIN OFF"; + Log(LOG_ADMIN, source, this) << "SUPERADMIN OFF"; } else source.Reply(_("Setting for SuperAdmin must be \002on\002 or \002off\002 (must be enabled in services.conf)")); @@ -99,7 +100,6 @@ class CommandOSSet : public Command void DoSetDebug(CommandSource &source, const std::vector<Anope::string> ¶ms) { - User *u = source.u; const Anope::string &setting = params.size() > 1 ? params[1] : ""; if (setting.empty()) @@ -111,12 +111,12 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { debug = 1; - Log(LOG_ADMIN, u, this) << "DEBUG ON"; + Log(LOG_ADMIN, source, this) << "DEBUG ON"; source.Reply(_("Services are now in debug mode.")); } else if (setting.equals_ci("OFF") || (setting[0] == '0' && setting.is_number_only() && !convertTo<int>(setting))) { - Log(LOG_ADMIN, u, this) << "DEBUG OFF"; + Log(LOG_ADMIN, source, this) << "DEBUG OFF"; debug = 0; source.Reply(_("Services are now in non-debug mode.")); } @@ -125,7 +125,7 @@ class CommandOSSet : public Command try { debug = convertTo<int>(setting); - Log(LOG_ADMIN, u, this) << "DEBUG " << debug; + Log(LOG_ADMIN, source, this) << "DEBUG " << debug; source.Reply(_("Services are now in debug mode (level %d)."), debug); return; } @@ -139,7 +139,6 @@ class CommandOSSet : public Command void DoSetNoExpire(CommandSource &source, const std::vector<Anope::string> ¶ms) { - User *u = source.u; const Anope::string &setting = params.size() > 1 ? params[1] : ""; if (setting.empty()) @@ -151,13 +150,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { noexpire = true; - Log(LOG_ADMIN, u, this) << "NOEXPIRE ON"; + Log(LOG_ADMIN, source, this) << "NOEXPIRE ON"; source.Reply(_("Services are now in \002no expire\002 mode.")); } else if (setting.equals_ci("OFF")) { noexpire = false; - Log(LOG_ADMIN, u, this) << "NOEXPIRE OFF"; + Log(LOG_ADMIN, source, this) << "NOEXPIRE OFF"; source.Reply(_("Services are now in \002expire\002 mode.")); } else diff --git a/modules/commands/os_shutdown.cpp b/modules/commands/os_shutdown.cpp index b7ead98b3..6edb3a64d 100644 --- a/modules/commands/os_shutdown.cpp +++ b/modules/commands/os_shutdown.cpp @@ -24,8 +24,7 @@ class CommandOSQuit : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - quitmsg = "QUIT command received from " + u->nick; + quitmsg = source.command + " command received from " + source.GetNick(); quitting = true; return; } @@ -53,8 +52,7 @@ class CommandOSRestart : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - quitmsg = "RESTART command received from " + u->nick; + quitmsg = source.command + " command received from " + source.GetNick(); quitting = restarting = true; save_databases(); return; @@ -80,8 +78,7 @@ class CommandOSShutdown : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; - quitmsg = source.command + " command received from " + u->nick; + quitmsg = source.command + " command received from " + source.GetNick(); quitting = true; save_databases(); return; diff --git a/modules/commands/os_svsnick.cpp b/modules/commands/os_svsnick.cpp index ef5d151f9..aeaa38a59 100644 --- a/modules/commands/os_svsnick.cpp +++ b/modules/commands/os_svsnick.cpp @@ -24,7 +24,6 @@ class CommandOSSVSNick : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = source.u; const Anope::string &nick = params[0]; Anope::string newnick = params[1]; User *u2; @@ -57,7 +56,7 @@ class CommandOSSVSNick : public Command else { source.Reply(_("The nick \002%s\002 is now being changed to \002%s\002."), nick.c_str(), newnick.c_str()); - Log(LOG_ADMIN, u, this) << "to change " << nick << " to " << newnick; + Log(LOG_ADMIN, source, this) << "to change " << nick << " to " << newnick; ircdproto->SendForceNickChange(u2, newnick, Anope::CurTime); } return; diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp index c828b8d52..20e76a94d 100644 --- a/modules/commands/os_sxline.cpp +++ b/modules/commands/os_sxline.cpp @@ -63,7 +63,6 @@ class CommandOSSXLineBase : public Command void OnDel(CommandSource &source, const std::vector<Anope::string> ¶ms) { - User *u = source.u; if (!this->xlm() || this->xlm()->GetList().empty()) { @@ -94,7 +93,7 @@ class CommandOSSXLineBase : public Command return; } - FOREACH_MOD(I_OnDelXLine, OnDelXLine(u, x, this->xlm())); + FOREACH_MOD(I_OnDelXLine, OnDelXLine(source, x, this->xlm())); SXLineDelCallback::DoDel(this->xlm(), source, x); source.Reply(_("\002%s\002 deleted from the %s list."), mask.c_str(), source.command.c_str()); @@ -163,7 +162,7 @@ class CommandOSSXLineBase : public Command entry["Mask"] = x->Mask; entry["By"] = x->By; entry["Created"] = do_strftime(x->Created, NULL, true); - entry["Expires"] = expire_left(source.u->Account(), x->Expires); + entry["Expires"] = expire_left(source.nc, x->Expires); entry["Reason"] = x->Reason; list.addEntry(entry); } @@ -201,8 +200,7 @@ class CommandOSSXLineBase : public Command void OnClear(CommandSource &source) { - User *u = source.u; - FOREACH_MOD(I_OnDelXLine, OnDelXLine(u, NULL, this->xlm())); + FOREACH_MOD(I_OnDelXLine, OnDelXLine(source, NULL, this->xlm())); for (unsigned i = this->xlm()->GetCount(); i > 0; --i) { @@ -258,7 +256,6 @@ class CommandOSSNLine : public CommandOSSXLineBase return; } - User *u = source.u; unsigned last_param = 2; Anope::string param, expiry; time_t expires; @@ -355,7 +352,7 @@ class CommandOSSNLine : public CommandOSSXLineBase if (mask[masklen - 1] == ' ') mask.erase(masklen - 1); - XLine *x = new XLine(mask, u->nick, expires, reason); + XLine *x = new XLine(mask, source.GetNick(), expires, reason); if (Config->AkillIds) x->UID = XLineManager::GenerateUID(); @@ -368,13 +365,13 @@ class CommandOSSNLine : public CommandOSSXLineBase if (percent > 95) { source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str()); - Log(LOG_ADMIN, u, this) << "tried to " << source.command << " " << percent << "% of the network (" << affected << " users)"; + Log(LOG_ADMIN, source, this) << "tried to " << source.command << " " << percent << "% of the network (" << affected << " users)"; x->destroy(); return; } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, this->xlm())); + FOREACH_RESULT(I_OnAddXLine, OnAddXLine(source, x, this->xlm())); if (MOD_RESULT == EVENT_STOP) { x->destroy(); @@ -385,7 +382,7 @@ class CommandOSSNLine : public CommandOSSXLineBase if (Config->KillonSNline) { - this->xlm()->Send(u, x); + this->xlm()->Send(source.GetUser(), x); if (!ircd->sglineenforce) { @@ -403,7 +400,7 @@ class CommandOSSNLine : public CommandOSSXLineBase } source.Reply(_("\002%s\002 added to the %s list."), mask.c_str(), source.command.c_str()); - Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; if (readonly) source.Reply(READ_ONLY_MODE); } @@ -483,7 +480,6 @@ class CommandOSSQLine : public CommandOSSXLineBase return; } - User *u = source.u; unsigned last_param = 2; Anope::string expiry, mask; time_t expires; @@ -562,7 +558,7 @@ class CommandOSSQLine : public CommandOSSXLineBase return; } - XLine *x = new XLine(mask, u->nick, expires, reason); + XLine *x = new XLine(mask, source.GetNick(), expires, reason); if (Config->AkillIds) x->UID = XLineManager::GenerateUID(); @@ -575,13 +571,13 @@ class CommandOSSQLine : public CommandOSSXLineBase if (percent > 95) { source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str()); - Log(LOG_ADMIN, u, this) << "tried to SQLine " << percent << "% of the network (" << affected << " users)"; + Log(LOG_ADMIN, source, this) << "tried to SQLine " << percent << "% of the network (" << affected << " users)"; x->destroy(); return; } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, this->xlm())); + FOREACH_RESULT(I_OnAddXLine, OnAddXLine(source, x, this->xlm())); if (MOD_RESULT == EVENT_STOP) { x->destroy(); @@ -624,11 +620,11 @@ class CommandOSSQLine : public CommandOSSXLineBase } } - this->xlm()->Send(u, x); + this->xlm()->Send(source.GetUser(), x); } source.Reply(_("\002%s\002 added to the SQLINE list."), mask.c_str()); - Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; if (readonly) source.Reply(READ_ONLY_MODE); diff --git a/modules/extra/m_chanstats.cpp b/modules/extra/m_chanstats.cpp index 5cde232d0..ed9a5f444 100644 --- a/modules/extra/m_chanstats.cpp +++ b/modules/extra/m_chanstats.cpp @@ -444,10 +444,10 @@ class MChanstats : public Module query.setValue("smileys_other", smileys_other); this->RunQuery(query); } - void OnDelCore(User *u) anope_override + void OnDelCore(NickCore *nc) anope_override { query = "DELETE FROM `" + prefix + "chanstats` WHERE `nick` = @nick@;"; - query.setValue("nick", GetDisplay(u)); + query.setValue("nick", nc->display); this->RunQuery(query); } void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) anope_override diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp index e1a214561..97583ece3 100644 --- a/modules/extra/m_ldap_authentication.cpp +++ b/modules/extra/m_ldap_authentication.cpp @@ -264,7 +264,10 @@ class NSIdentifyLDAP : public Module if (c == NULL || source == NULL || !this->ldap) return EVENT_CONTINUE; - User *u = source->u; + User *u = source->GetUser(); + if (!u) + return EVENT_CONTINUE; + if (u->HasExt("m_ldap_authentication_authenticated")) { u->Shrink("m_ldap_authentication_authenticated"); diff --git a/modules/extra/m_statusupdate.cpp b/modules/extra/m_statusupdate.cpp index 3caf09f64..3c6e60246 100644 --- a/modules/extra/m_statusupdate.cpp +++ b/modules/extra/m_statusupdate.cpp @@ -31,7 +31,7 @@ class StatusUpdate : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnAccessAdd(ChannelInfo *ci, User *u, ChanAccess *access) anope_override + void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override { if (ci->c) for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -48,7 +48,7 @@ class StatusUpdate : public Module } } - void OnAccessDel(ChannelInfo *ci, User *u, ChanAccess *access) anope_override + void OnAccessDel(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override { if (ci->c) for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index 544935f7f..da2d09f22 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -1,45 +1,6 @@ #include "module.h" #include "xmlrpc.h" -// XXX We no longer need this, we need to modify CommandSource to allow commands to go back here -class XMLRPCUser : public User -{ - Anope::string out; - NickAlias *na; - - public: - XMLRPCUser(const Anope::string &nnick) : User(nnick, Config->NSEnforcerUser, Config->NSEnforcerHost, ""), na(findnick(nick)) - { - this->realname = "XMLRPC User"; - this->server = Me; - } - - void SendMessage(const BotInfo *, Anope::string msg) anope_override - { - this->out += msg + "\n"; - } - - NickCore *Account() const anope_override - { - return (na ? *na->nc : NULL); - } - - bool IsIdentified(bool CheckNick = false) const anope_override - { - return na; - } - - bool IsRecognized(bool CheckSecure = true) const anope_override - { - return na; - } - - const Anope::string &GetOut() - { - return this->out; - } -}; - class MyXMLRPCEvent : public XMLRPCEvent { public: @@ -60,7 +21,7 @@ class MyXMLRPCEvent : public XMLRPCEvent } private: - void DoCommand(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request) + void DoCommand(XMLRPCServiceInterface *iface, XMLRPCClientSocket *, XMLRPCRequest *request) { Anope::string service = request->data.size() > 0 ? request->data[0] : ""; Anope::string user = request->data.size() > 1 ? request->data[1] : ""; @@ -77,27 +38,32 @@ class MyXMLRPCEvent : public XMLRPCEvent { request->reply("result", "Success"); - dynamic_reference<User> u = finduser(user); - bool created = false; - if (!u) - { - u = new XMLRPCUser(user); - created = true; - request->reply("online", "no"); - } - else - request->reply("online", "yes"); + NickAlias *na = findnick(user); - bi->OnMessage(u, command); + Anope::string out; - if (created && u) + struct XMLRPCommandReply : CommandReply { - User *useru = u; - XMLRPCUser *myu = anope_dynamic_static_cast<XMLRPCUser *>(useru); - if (!myu->GetOut().empty()) - request->reply("return", iface->Sanitize(myu->GetOut())); - delete u; + Anope::string &str; + + XMLRPCommandReply(Anope::string &s) : str(s) { } + + void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override + { + str += msg + "\n"; + }; } + reply(out); + + CommandSource source(user, NULL, na ? *na->nc : NULL, &reply); + source.c = NULL; + source.owner = bi; + source.service = bi; + + RunCommand(source, command); + + if (!out.empty()) + request->reply("return", iface->Sanitize(out)); } } } diff --git a/modules/extra/ns_maxemail.cpp b/modules/extra/ns_maxemail.cpp index d8d7d3ec6..121da057b 100644 --- a/modules/extra/ns_maxemail.cpp +++ b/modules/extra/ns_maxemail.cpp @@ -24,7 +24,7 @@ class NSMaxEmail : public Module if (this->NSEmailMax < 1 || email.empty()) return false; - if (this->CountEmail(email, source.u) < this->NSEmailMax) + if (this->CountEmail(email, source.nc) < this->NSEmailMax) return false; if (this->NSEmailMax == 1) @@ -35,7 +35,7 @@ class NSMaxEmail : public Module return true; } - int CountEmail(const Anope::string &email, User *u) + int CountEmail(const Anope::string &email, NickCore *unc) { int count = 0; @@ -46,7 +46,7 @@ class NSMaxEmail : public Module { const NickCore *nc = it->second; - if (!(u->Account() && u->Account() == nc) && !nc->email.empty() && nc->email.equals_ci(email)) + if (unc != nc && !nc->email.empty() && nc->email.equals_ci(email)) ++count; } diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index 408815afc..181baa7b8 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -173,7 +173,7 @@ class ChanServCore : public Module "Note that any channel which is not used for %d days\n" "(i.e. which no user on the channel's access list enters\n" "for that period of time) will be automatically dropped."), Config->CSExpire / 86400); - if (source.u->IsServicesOper()) + if (source.IsServicesOper()) source.Reply(_(" \n" "Services Operators can also, depending on their access drop\n" "any channel, view (and modify) the access, levels and akick\n" diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index dd0501cd4..027317b7c 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -334,7 +334,7 @@ class NickServCore : public Module { if (!params.empty() || source.owner->nick != Config->NickServ) return; - if (source.u->IsServicesOper()) + if (source.IsServicesOper()) source.Reply(_(" \n" "Services Operators can also drop any nickname without needing\n" "to identify for the nick, and may view the access list for\n" diff --git a/src/bots.cpp b/src/bots.cpp index a4db8b5a3..85d6e0700 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -238,94 +238,12 @@ void BotInfo::OnMessage(User *u, const Anope::string &message) if (this->commands.empty()) return; - std::vector<Anope::string> params = BuildStringVector(message); - bool has_help = this->commands.find("HELP") != this->commands.end(); - - BotInfo::command_map::const_iterator it = this->commands.end(); - unsigned count = 0; - for (unsigned max = params.size(); it == this->commands.end() && max > 0; --max) - { - Anope::string full_command; - for (unsigned i = 0; i < max; ++i) - full_command += " " + params[i]; - full_command.erase(full_command.begin()); - - ++count; - it = this->commands.find(full_command); - } - - if (it == this->commands.end()) - { - if (has_help) - u->SendMessage(this, _("Unknown command \002%s\002. \"%s%s HELP\" for help."), message.c_str(), Config->UseStrictPrivMsgString.c_str(), this->nick.c_str()); - else - u->SendMessage(this, _("Unknown command \002%s\002."), message.c_str()); - return; - } - - const CommandInfo &info = it->second; - service_reference<Command> c("Command", info.name); - if (!c) - { - if (has_help) - u->SendMessage(this, _("Unknown command \002%s\002. \"%s%s HELP\" for help."), message.c_str(), Config->UseStrictPrivMsgString.c_str(), this->nick.c_str()); - else - u->SendMessage(this, _("Unknown command \002%s\002."), message.c_str()); - Log(this) << "Command " << it->first << " exists on me, but its service " << info.name << " was not found!"; - return; - } - - // Command requires registered users only - if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->IsIdentified()) - { - u->SendMessage(this, NICK_IDENTIFY_REQUIRED); - Log(LOG_NORMAL, "access_denied", this) << "Access denied for unregistered user " << u->GetMask() << " with command " << c->name; - return; - } - - for (unsigned i = 0, j = params.size() - (count - 1); i < j; ++i) - params.erase(params.begin()); - - while (c->MaxParams > 0 && params.size() > c->MaxParams) - { - params[c->MaxParams - 1] += " " + params[c->MaxParams]; - params.erase(params.begin() + c->MaxParams); - } - - CommandSource source; - source.u = u; + CommandSource source(u->nick, u, u->Account(), u); source.c = NULL; source.owner = this; source.service = this; - source.command = it->first; - source.permission = info.permission; - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreCommand, OnPreCommand(source, c, params)); - if (MOD_RESULT == EVENT_STOP) - return; - - - if (params.size() < c->MinParams) - { - c->OnSyntaxError(source, !params.empty() ? params[params.size() - 1] : ""); - return; - } - - // If the command requires a permission, and they aren't registered or don't have the required perm, DENIED - if (!info.permission.empty() && !u->HasCommand(info.permission)) - { - u->SendMessage(this, ACCESS_DENIED); - Log(LOG_NORMAL, "access_denied", this) << "Access denied for user " << u->GetMask() << " with command " << c->name; - return; - } - - dynamic_reference<User> user_reference(u); - c->Execute(source, params); - if (user_reference) - { - FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, c, params)); - } + RunCommand(source, message); } /** Link a command name to a command in services diff --git a/src/command.cpp b/src/command.cpp index 309611a92..ae01ecda4 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -12,6 +12,78 @@ #include "language.h" #include "config.h" #include "bots.h" +#include "opertype.h" +#include "access.h" +#include "regchannel.h" + +CommandSource::CommandSource(const Anope::string &n, User *user, NickCore *core, CommandReply *r) : nick(n), u(user), nc(core), reply(r) +{ +} + +const Anope::string &CommandSource::GetNick() const +{ + return this->nick; +} + +User *CommandSource::GetUser() const +{ + return this->u; +} + +AccessGroup CommandSource::AccessFor(ChannelInfo *ci) const +{ + if (this->u) + return ci->AccessFor(this->u); + else if (this->nc) + return ci->AccessFor(this->nc); + else + return AccessGroup(); +} + +bool CommandSource::IsFounder(ChannelInfo *ci) const +{ + if (this->u) + return ::IsFounder(this->u, ci); + else if (this->nc) + return this->nc == ci->GetFounder(); + return false; +} + +bool CommandSource::HasCommand(const Anope::string &cmd) +{ + if (this->u) + return this->u->HasCommand(cmd); + else if (this->nc && this->nc->o) + return this->nc->o->ot->HasCommand(cmd); + return false; +} + +bool CommandSource::HasPriv(const Anope::string &cmd) +{ + if (this->u) + return this->u->HasPriv(cmd); + else if (this->nc && this->nc->o) + return this->nc->o->ot->HasPriv(cmd); + return false; +} + +bool CommandSource::IsServicesOper() const +{ + if (this->u) + return this->u->IsServicesOper(); + else if (this->nc) + return this->nc->IsServicesOper(); + return false; +} + +bool CommandSource::IsOper() const +{ + if (this->u) + return this->u->HasMode(UMODE_OPER); + else if (this->nc) + return this->nc->IsServicesOper(); + return false; +} void CommandSource::Reply(const char *message, ...) { @@ -35,7 +107,7 @@ void CommandSource::Reply(const Anope::string &message) sepstream sep(translated_message, '\n'); Anope::string tok; while (sep.GetToken(tok)) - u->SendMessage(this->service, tok); + this->reply->SendMessage(this->service, tok); } Command::Command(Module *o, const Anope::string &sname, size_t min_params, size_t max_params) : Service(o, "Command", sname), Flags<CommandFlag>(CommandFlagStrings), MaxParams(max_params), MinParams(min_params), module(owner) @@ -84,7 +156,7 @@ const Anope::string &Command::GetDesc() const void Command::OnServHelp(CommandSource &source) { - source.Reply(" %-14s %s", source.command.c_str(), translate(source.u, (this->GetDesc().c_str()))); + source.Reply(" %-14s %s", source.command.c_str(), translate(source.nc, (this->GetDesc().c_str()))); } bool Command::OnHelp(CommandSource &source, const Anope::string &subcommand) { return false; } @@ -95,3 +167,94 @@ void Command::OnSyntaxError(CommandSource &source, const Anope::string &subcomma source.Reply(MORE_INFO, Config->UseStrictPrivMsgString.c_str(), source.owner->nick.c_str(), source.command.c_str()); } +void RunCommand(CommandSource &source, const Anope::string &message) +{ + std::vector<Anope::string> params = BuildStringVector(message); + bool has_help = source.service->commands.find("HELP") != source.service->commands.end(); + + BotInfo::command_map::const_iterator it = source.service->commands.end(); + unsigned count = 0; + for (unsigned max = params.size(); it == source.service->commands.end() && max > 0; --max) + { + Anope::string full_command; + for (unsigned i = 0; i < max; ++i) + full_command += " " + params[i]; + full_command.erase(full_command.begin()); + + ++count; + it = source.service->commands.find(full_command); + } + + if (it == source.service->commands.end()) + { + if (has_help) + source.Reply(_("Unknown command \002%s\002. \"%s%s HELP\" for help."), message.c_str(), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str()); + else + source.Reply(_("Unknown command \002%s\002."), message.c_str()); + return; + } + + const CommandInfo &info = it->second; + service_reference<Command> c("Command", info.name); + if (!c) + { + if (has_help) + source.Reply(_("Unknown command \002%s\002. \"%s%s HELP\" for help."), message.c_str(), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str()); + else + source.Reply(_("Unknown command \002%s\002."), message.c_str()); + Log(source.service) << "Command " << it->first << " exists on me, but its service " << info.name << " was not found!"; + return; + } + + // Command requires registered users only + if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !source.nc) + { + source.Reply(NICK_IDENTIFY_REQUIRED); + if (source.GetUser()) + Log(LOG_NORMAL, "access_denied", source.service) << "Access denied for unregistered user " << source.GetUser()->GetMask() << " with command " << c->name; + return; + } + + for (unsigned i = 0, j = params.size() - (count - 1); i < j; ++i) + params.erase(params.begin()); + + while (c->MaxParams > 0 && params.size() > c->MaxParams) + { + params[c->MaxParams - 1] += " " + params[c->MaxParams]; + params.erase(params.begin() + c->MaxParams); + } + + source.command = it->first; + source.permission = info.permission; + + EventReturn MOD_RESULT; + FOREACH_RESULT(I_OnPreCommand, OnPreCommand(source, c, params)); + if (MOD_RESULT == EVENT_STOP) + return; + + + if (params.size() < c->MinParams) + { + c->OnSyntaxError(source, !params.empty() ? params[params.size() - 1] : ""); + return; + } + + // If the command requires a permission, and they aren't registered or don't have the required perm, DENIED + if (!info.permission.empty() && !source.HasCommand(info.permission)) + { + source.Reply(ACCESS_DENIED); + if (source.GetUser()) + Log(LOG_NORMAL, "access_denied", source.service) << "Access denied for user " << source.GetUser()->GetMask() << " with command " << c->name; + return; + } + + bool had_u = source.GetUser(), had_nc = source.nc; + dynamic_reference<User> user_reference(source.GetUser()); + dynamic_reference<NickCore> nc_reference(source.nc); + c->Execute(source, params); + if (had_u == user_reference && had_nc == nc_reference) + { + FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, c, params)); + } +} + diff --git a/src/logger.cpp b/src/logger.cpp index 1b7c48f78..d18b0731e 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -75,7 +75,7 @@ Anope::string LogFile::GetName() const return this->filename; } -Log::Log(LogType type, const Anope::string &category, const BotInfo *b) : bi(b), u(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(type), Category(category) +Log::Log(LogType type, const Anope::string &category, const BotInfo *b) : bi(b), u(NULL), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(type), Category(category) { if (!bi && Config) bi = findbot(Config->Global); @@ -83,9 +83,9 @@ Log::Log(LogType type, const Anope::string &category, const BotInfo *b) : bi(b), this->Sources.push_back(bi->nick); } -Log::Log(LogType type, const User *_u, Command *_c, const ChannelInfo *_ci) : u(_u), c(_c), chan(NULL), ci(_ci), s(NULL), Type(type) +Log::Log(LogType type, const CommandSource &source, Command *_c, const ChannelInfo *_ci) : u(source.GetUser()), nc(source.nc), c(_c), chan(NULL), ci(_ci), s(NULL), Type(type) { - if (!u || !c) + if (!c) throw CoreException("Invalid pointers passed to Log::Log"); if (type != LOG_COMMAND && type != LOG_OVERRIDE && type != LOG_ADMIN) @@ -100,13 +100,14 @@ Log::Log(LogType type, const User *_u, Command *_c, const ChannelInfo *_ci) : u( this->Category = c->name; if (this->bi) this->Sources.push_back(this->bi->nick); - this->Sources.push_back(u->nick); + if (u) + this->Sources.push_back(u->nick); this->Sources.push_back(c->name); if (ci) this->Sources.push_back(ci->name); } -Log::Log(const User *_u, Channel *ch, const Anope::string &category) : bi(NULL), u(_u), c(NULL), chan(ch), ci(chan ? *chan->ci : NULL), s(NULL), Type(LOG_CHANNEL) +Log::Log(const User *_u, Channel *ch, const Anope::string &category) : bi(NULL), u(_u), nc(NULL), c(NULL), chan(ch), ci(chan ? *chan->ci : NULL), s(NULL), Type(LOG_CHANNEL) { if (!chan) throw CoreException("Invalid pointers passed to Log::Log"); @@ -121,7 +122,7 @@ Log::Log(const User *_u, Channel *ch, const Anope::string &category) : bi(NULL), this->Sources.push_back(chan->name); } -Log::Log(const User *_u, const Anope::string &category, const BotInfo *_bi) : bi(_bi), u(_u), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(LOG_USER), Category(category) +Log::Log(const User *_u, const Anope::string &category, const BotInfo *_bi) : bi(_bi), u(_u), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(LOG_USER), Category(category) { if (!u) throw CoreException("Invalid pointers passed to Log::Log"); @@ -133,7 +134,7 @@ Log::Log(const User *_u, const Anope::string &category, const BotInfo *_bi) : bi this->Sources.push_back(u->nick); } -Log::Log(Server *serv, const Anope::string &category, const BotInfo *_bi) : bi(_bi), u(NULL), c(NULL), chan(NULL), ci(NULL), s(serv), Type(LOG_SERVER), Category(category) +Log::Log(Server *serv, const Anope::string &category, const BotInfo *_bi) : bi(_bi), u(NULL), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(serv), Type(LOG_SERVER), Category(category) { if (!s) throw CoreException("Invalid pointer passed to Log::Log"); @@ -147,7 +148,7 @@ Log::Log(Server *serv, const Anope::string &category, const BotInfo *_bi) : bi(_ this->Sources.push_back(s->GetName()); } -Log::Log(const BotInfo *b, const Anope::string &category) : bi(b), u(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(LOG_NORMAL), Category(category) +Log::Log(const BotInfo *b, const Anope::string &category) : bi(b), u(NULL), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), Type(LOG_NORMAL), Category(category) { if (!this->bi && Config) this->bi = findbot(Config->Global); @@ -179,36 +180,45 @@ Anope::string Log::BuildPrefix() const { case LOG_ADMIN: { - if (!this->c || !this->u) + if (!this->c && !(this->u || this->nc)) break; buffer += "ADMIN: "; size_t sl = this->c->name.find('/'); Anope::string cname = sl != Anope::string::npos ? this->c->name.substr(sl + 1) : this->c->name; - buffer += this->u->GetMask() + " used " + cname + " "; + if (this->u) + buffer += this->u->GetMask() + " used " + cname + " "; + else if (this->nc) + buffer += this->nc->display + " used " + cname + " "; if (this->ci) buffer += "on " + this->ci->name + " "; break; } case LOG_OVERRIDE: { - if (!this->c || !this->u) + if (!this->c && !(this->u || this->nc)) break; buffer += "OVERRIDE: "; size_t sl = this->c->name.find('/'); Anope::string cname = sl != Anope::string::npos ? this->c->name.substr(sl + 1) : this->c->name; - buffer += this->u->GetMask() + " used " + cname + " "; + if (this->u) + buffer += this->u->GetMask() + " used " + cname + " "; + else if (this->nc) + buffer += this->nc->display + " used " + cname + " "; if (this->ci) buffer += "on " + this->ci->name + " "; break; } case LOG_COMMAND: { - if (!this->c || !this->u) + if (!this->c || !(this->u || this->nc)) break; buffer += "COMMAND: "; size_t sl = this->c->name.find('/'); Anope::string cname = sl != Anope::string::npos ? this->c->name.substr(sl + 1) : this->c->name; - buffer += this->u->GetMask() + " used " + cname + " "; + if (this->u) + buffer += this->u->GetMask() + " used " + cname + " "; + else if (this->nc) + buffer += this->nc->display + " used " + cname + " "; if (this->ci) buffer += "on " + this->ci->name + " "; break; diff --git a/src/mail.cpp b/src/mail.cpp index aaf564bc6..0a9273ebc 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -53,24 +53,39 @@ void MailThread::Run() bool Mail(User *u, NickCore *nc, const BotInfo *service, const Anope::string &subject, const Anope::string &message) { - if (!u || !nc || !service || subject.empty() || message.empty()) + if (!nc || !service || subject.empty() || message.empty()) return false; - - if (!Config->UseMail) - u->SendMessage(service, _("Services have been configured to not send mail.")); - else if (Anope::CurTime - u->lastmail < Config->MailDelay) - u->SendMessage(service, _("Please wait \002%d\002 seconds and retry."), Config->MailDelay - (Anope::CurTime - u->lastmail)); - else if (nc->email.empty()) - u->SendMessage(service, _("E-mail for \002%s\002 is invalid."), nc->display.c_str()); - else + + if (!u) { - u->lastmail = nc->lastmail = Anope::CurTime; + if (!Config->UseMail) + return false; + else if (nc->email.empty()) + return false; + + nc->lastmail = Anope::CurTime; Thread *t = new MailThread(nc->display, nc->email, subject, message); t->Start(); return true; } + else + { + if (!Config->UseMail) + u->SendMessage(service, _("Services have been configured to not send mail.")); + else if (Anope::CurTime - u->lastmail < Config->MailDelay) + u->SendMessage(service, _("Please wait \002%d\002 seconds and retry."), Config->MailDelay - (Anope::CurTime - u->lastmail)); + else if (nc->email.empty()) + u->SendMessage(service, _("E-mail for \002%s\002 is invalid."), nc->display.c_str()); + else + { + u->lastmail = nc->lastmail = Anope::CurTime; + Thread *t = new MailThread(nc->display, nc->email, subject, message); + t->Start(); + return true; + } - return false; + return false; + } } bool Mail(NickCore *nc, const Anope::string &subject, const Anope::string &message) diff --git a/src/misc.cpp b/src/misc.cpp index e5ad71d45..41f1370a1 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -222,7 +222,7 @@ void ListFormatter::Process(std::vector<Anope::string> &buffer) } } -InfoFormatter::InfoFormatter(User *u) : user(u), longest(0) +InfoFormatter::InfoFormatter(NickCore *acc) : nc(acc), longest(0) { } @@ -235,7 +235,7 @@ void InfoFormatter::Process(std::vector<Anope::string> &buffer) Anope::string s; for (unsigned i = it->first.length(); i < this->longest; ++i) s += " "; - s += Anope::string(translate(this->user, it->first.c_str())) + ": " + it->second; + s += Anope::string(translate(this->nc, it->first.c_str())) + ": " + it->second; buffer.push_back(s); } @@ -360,7 +360,7 @@ Anope::string do_strftime(const time_t &t, const NickCore *nc, bool short_output * @param seconds time in seconds * @return buffer */ -Anope::string expire_left(NickCore *nc, time_t expires) +Anope::string expire_left(const NickCore *nc, time_t expires) { if (!expires) return translate(nc, NO_EXPIRE); diff --git a/src/users.cpp b/src/users.cpp index bbe26a11a..18bafd032 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -234,12 +234,13 @@ void User::SendMessage(const BotInfo *source, const char *fmt, ...) va_start(args, fmt); vsnprintf(buf, BUFSIZE - 1, translated_message, args); - this->SendMessage(source, Anope::string(buf)); + Anope::string m = buf; + this->SendMessage(source, buf); va_end(args); } -void User::SendMessage(const BotInfo *source, Anope::string msg) +void User::SendMessage(const BotInfo *source, const Anope::string &msg) { const char *translated_message = translate(this, msg.c_str()); @@ -472,7 +473,7 @@ bool User::IsRecognized(bool CheckSecure) const */ bool User::IsServicesOper() { - if (!this->nc || !this->nc->o) + if (!this->nc || !this->nc->IsServicesOper()) // No opertype. return false; else if (this->nc->o->require_oper && !this->HasMode(UMODE_OPER)) |