diff options
50 files changed, 452 insertions, 485 deletions
diff --git a/include/channels.h b/include/channels.h index 377b4eebf..9add089bc 100644 --- a/include/channels.h +++ b/include/channels.h @@ -225,7 +225,7 @@ class CoreExport Channel : public Base, public Extensible * @param nick The nick being kicked * @param reason The reason for the kick */ - void KickInternal(MessageSource &source, const Anope::string &nick, const Anope::string &reason); + void KickInternal(const MessageSource &source, const Anope::string &nick, const Anope::string &reason); /** Kick a user from the channel * @param bi The sender, can be NULL for the service bot for this channel diff --git a/include/commands.h b/include/commands.h index 06bb74c7b..abd01e41f 100644 --- a/include/commands.h +++ b/include/commands.h @@ -46,7 +46,7 @@ struct CommandInfo struct CoreExport CommandReply { virtual ~CommandReply() { } - virtual void SendMessage(const BotInfo *source, const Anope::string &msg) = 0; + virtual void SendMessage(BotInfo *source, const Anope::string &msg) = 0; }; /* The source for a command */ diff --git a/include/logger.h b/include/logger.h index b24d7bbd6..8bba26aeb 100644 --- a/include/logger.h +++ b/include/logger.h @@ -54,11 +54,11 @@ class CoreExport Log { public: /* Bot that should log this message */ - const BotInfo *bi; + BotInfo *bi; /* For commands, the user executing the command, but might not always exist */ - const User *u; - /* For commands, the account executing teh command, but will not always exist */ - const NickCore *nc; + User *u; + /* For commands, the account executing the command, but will not always exist */ + NickCore *nc; /* For commands, the command being executed */ Command *c; /* For commands, the command source */ @@ -76,21 +76,21 @@ class CoreExport Log std::stringstream buf; - Log(LogType type = LOG_NORMAL, const Anope::string &category = "", const BotInfo *bi = NULL); + Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = NULL); /* LOG_COMMAND/OVERRIDE/ADMIN */ - Log(LogType type, CommandSource &source, Command *c, const ChannelInfo *ci = NULL); + Log(LogType type, CommandSource &source, Command *c, ChannelInfo *ci = NULL); /* LOG_CHANNEL */ - Log(const User *u, Channel *c, const Anope::string &category = ""); + Log(User *u, Channel *c, const Anope::string &category = ""); /* LOG_USER */ - explicit Log(const User *u, const Anope::string &category = "", const BotInfo *bi = NULL); + Log(User *u, const Anope::string &category = "", BotInfo *bi = NULL); /* LOG_SERVER */ - explicit Log(Server *s, const Anope::string &category = "", const BotInfo *bi = NULL); + Log(Server *s, const Anope::string &category = "", BotInfo *bi = NULL); - explicit Log(const BotInfo *b, const Anope::string &category = ""); + Log(BotInfo *b, const Anope::string &category = ""); Log(Module *m, const Anope::string &category = ""); diff --git a/include/mail.h b/include/mail.h index 5f4809d51..59e33c8b9 100644 --- a/include/mail.h +++ b/include/mail.h @@ -20,7 +20,7 @@ namespace Mail { - extern CoreExport bool Send(User *from, NickCore *to, const BotInfo *service, const Anope::string &subject, const Anope::string &message); + extern CoreExport bool Send(User *from, NickCore *to, BotInfo *service, const Anope::string &subject, const Anope::string &message); extern CoreExport bool Send(NickCore *to, const Anope::string &subject, const Anope::string &message); extern CoreExport bool Validate(const Anope::string &email); diff --git a/include/modes.h b/include/modes.h index 807b91c25..66cbcfdc5 100644 --- a/include/modes.h +++ b/include/modes.h @@ -56,6 +56,11 @@ class CoreExport Mode : public Base */ Mode(const Anope::string &mname, ModeClass mclass, char mc, ModeType type); virtual ~Mode(); + + /** Can a user set this mode, used for mlock + * @param u The user + */ + virtual bool CanSet(User *u) const; }; /** This class is a user mode, all user modes use this/inherit from this @@ -68,7 +73,6 @@ class CoreExport UserMode : public Mode * @param mc The mode char */ UserMode(const Anope::string &name, char mc); - virtual ~UserMode(); }; class CoreExport UserModeParam : public UserMode @@ -97,16 +101,10 @@ class CoreExport ChannelMode : public Mode * @param mc The mode char */ ChannelMode(const Anope::string &name, char mc); - virtual ~ChannelMode(); - /** Can a user set this mode, used for mlock - * NOTE: User CAN be NULL, this is for checking if it can be locked with defcon - * @param u The user, or NULL - */ - virtual bool CanSet(User *u) const; + bool CanSet(User *u) const anope_override; }; - /** This is a mode for lists, eg b/e/I. These modes should inherit from this */ class CoreExport ChannelModeList : public ChannelMode @@ -118,10 +116,6 @@ class CoreExport ChannelModeList : public ChannelMode */ ChannelModeList(const Anope::string &name, char mc); - /** destructor - */ - virtual ~ChannelModeList(); - /** Is the mask valid * @param mask The mask * @return true for yes, false for no @@ -161,10 +155,6 @@ class CoreExport ChannelModeParam : public ChannelMode */ ChannelModeParam(const Anope::string &name, char mc, bool minus_no_arg = false); - /** destructor - */ - virtual ~ChannelModeParam(); - /* Should we send an arg when unsetting this mode? */ bool minus_no_arg; @@ -194,10 +184,6 @@ class CoreExport ChannelModeStatus : public ChannelMode * @param mlevel A level for the mode, which is usually determined by the PREFIX capab */ ChannelModeStatus(const Anope::string &name, char mc, char msymbol, short mlevel); - - /** destructor - */ - virtual ~ChannelModeStatus(); }; /* The status a user has on a channel (+v, +h, +o) etc */ @@ -216,49 +202,50 @@ class CoreExport ChannelStatus Anope::string BuildModePrefixList() const; }; -/** Channel mode +k (key) - */ -class CoreExport ChannelModeKey : public ChannelModeParam +class CoreExport UserModeOperOnly : public UserMode { public: - ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { } + UserModeOperOnly(const Anope::string &mname, char um) : UserMode(mname, um) { } - bool IsValid(const Anope::string &value) const anope_override; + bool CanSet(User *u) const anope_override; }; -/** This class is used for channel mode +A (Admin only) - * Only opers can mlock it - */ -class CoreExport ChannelModeAdmin : public ChannelMode +class CoreExport UserModeNoone : public UserMode { public: - ChannelModeAdmin(char mc) : ChannelMode("ADMINONLY", mc) { } + UserModeNoone(const Anope::string &mname, char um) : UserMode(mname, um) { } - /* Opers only */ bool CanSet(User *u) const anope_override; }; -/** This class is used for channel mode +O (Opers only) - * Only opers can mlock it +/** Channel mode +k (key) + */ +class CoreExport ChannelModeKey : public ChannelModeParam +{ + public: + ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { } + + bool IsValid(const Anope::string &value) const anope_override; +}; + +/** This class is used for oper only channel modes */ -class CoreExport ChannelModeOper : public ChannelMode +class CoreExport ChannelModeOperOnly : public ChannelMode { public: - ChannelModeOper(char mc) : ChannelMode("OPERONLY", mc) { } + ChannelModeOperOnly(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { } /* Opers only */ bool CanSet(User *u) const anope_override; }; -/** This class is used for channel mode +r (registered channel) - * No one may mlock r +/** This class is used for channel modes only servers may set */ -class CoreExport ChannelModeRegistered : public ChannelMode +class CoreExport ChannelModeNoone : public ChannelMode { public: - ChannelModeRegistered(char mc) : ChannelMode("REGISTERED", mc) { } + ChannelModeNoone(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { } - /* No one mlocks +r */ bool CanSet(User *u) const anope_override; }; @@ -347,7 +334,7 @@ class CoreExport ModeManager * @param set true for setting, false for removing * @param param The param, if there is one */ - static void StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, bool set, const Anope::string ¶m = ""); + static void StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool set, const Anope::string ¶m = ""); /** Add a mode to the stacker to be set on a user * @param bi The client to set the modes from @@ -356,7 +343,7 @@ class CoreExport ModeManager * @param set true for setting, false for removing * @param param The param, if there is one */ - static void StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool set, const Anope::string ¶m = ""); + static void StackerAdd(BotInfo *bi, User *u, UserMode *um, bool set, const Anope::string ¶m = ""); /** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users */ diff --git a/include/modules.h b/include/modules.h index 98bb02f23..b217b1b0e 100644 --- a/include/modules.h +++ b/include/modules.h @@ -294,7 +294,7 @@ class CoreExport Module : public Extensible * @param cu The user, channel, and status of the user being kicked * @param kickmsg The reason for the kick. */ - virtual void OnPreUserKicked(MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) { throw NotImplementedException(); } + virtual void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) { throw NotImplementedException(); } /** Called when a user has been kicked from a channel. * @param source The kicker @@ -303,7 +303,7 @@ class CoreExport Module : public Extensible * @param status The status the kicked user had on the channel before they were kicked * @param kickmsg The reason for the kick. */ - virtual void OnUserKicked(MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) { throw NotImplementedException(); } + virtual void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) { throw NotImplementedException(); } /** Called when Services' configuration is being (re)loaded. * @param conf The config that is being built now and will replace the global Config object @@ -908,16 +908,18 @@ class CoreExport Module : public Extensible virtual EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) { throw NotImplementedException(); } /** Called when a mode is set on a user + * @param setter who/what is setting the mode * @param u The user * @param mname The mode name */ - virtual void OnUserModeSet(User *u, const Anope::string &mname) { throw NotImplementedException(); } + virtual void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) { throw NotImplementedException(); } /** Called when a mode is unset from a user + * @param setter who/what is setting the mode * @param u The user * @param mname The mode name */ - virtual void OnUserModeUnset(User *u, const Anope::string &mname) { throw NotImplementedException(); } + virtual void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) { throw NotImplementedException(); } /** Called when a channel mode is introducted into Anope * @param cm The mode diff --git a/include/modules/pseudoclients/global.h b/include/modules/pseudoclients/global.h index 52afc4a23..1511214c9 100644 --- a/include/modules/pseudoclients/global.h +++ b/include/modules/pseudoclients/global.h @@ -13,7 +13,7 @@ class GlobalService : public Service * @param source The sender of the global * @param message The message */ - virtual void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0; + virtual void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0; }; #endif // GLOBAL_H diff --git a/include/protocol.h b/include/protocol.h index 874fbbe2c..2744dde0d 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -27,16 +27,16 @@ class CoreExport IRCDProto : public Service public: virtual ~IRCDProto(); - virtual void SendSVSKillInternal(const BotInfo *, User *, const Anope::string &); - virtual void SendModeInternal(const BotInfo *, const Channel *, const Anope::string &); - virtual void SendModeInternal(const BotInfo *, const User *, const Anope::string &); - virtual void SendKickInternal(const BotInfo *, const Channel *, const User *, const Anope::string &); - virtual void SendNoticeInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &msg); - virtual void SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf); - virtual void SendQuitInternal(const User *u, const Anope::string &buf); - virtual void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf); - virtual void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf); - virtual void SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf); + virtual void SendSVSKillInternal(const MessageSource &, User *, const Anope::string &); + virtual void SendModeInternal(const MessageSource &, const Channel *, const Anope::string &); + virtual void SendModeInternal(const MessageSource &, User *, const Anope::string &); + virtual void SendKickInternal(const MessageSource &, const Channel *, User *, const Anope::string &); + virtual void SendNoticeInternal(const MessageSource &, const Anope::string &dest, const Anope::string &msg); + virtual void SendPrivmsgInternal(const MessageSource &, const Anope::string &dest, const Anope::string &buf); + virtual void SendQuitInternal(User *, const Anope::string &buf); + virtual void SendPartInternal(User *, const Channel *chan, const Anope::string &buf); + virtual void SendGlobopsInternal(const MessageSource &, const Anope::string &buf); + virtual void SendCTCPInternal(const MessageSource &, const Anope::string &dest, const Anope::string &buf); virtual void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf); const Anope::string &GetProtocolName(); @@ -78,7 +78,7 @@ class CoreExport IRCDProto : public Service * @param bi The bot to set the topic from * @param c The channel to set the topic on. The topic being set is Channel::topic */ - virtual void SendTopic(BotInfo *, Channel *); + virtual void SendTopic(const MessageSource &, Channel *); /** Sets a vhost on a user. * @param u The user @@ -110,31 +110,31 @@ class CoreExport IRCDProto : public Service virtual void SendSQLineDel(const XLine *x) { } /** Kills a user - * @param source The client used to kill the user, if any + * @param source Who is doing the kill * @param user The user to be killed * @param fmt Kill reason */ - virtual void SendSVSKill(const BotInfo *source, User *user, const char *fmt, ...); + virtual void SendSVSKill(const MessageSource &source, User *user, const char *fmt, ...); - virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...); - virtual void SendMode(const BotInfo *bi, const User *u, const char *fmt, ...); + virtual void SendMode(const MessageSource &source, const Channel *dest, const char *fmt, ...); + virtual void SendMode(const MessageSource &source, User *u, const char *fmt, ...); /** Introduces a client to the rest of the network * @param u The client to introduce */ - virtual void SendClientIntroduction(const User *u) = 0; + virtual void SendClientIntroduction(User *u) = 0; - virtual void SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...); + virtual void SendKick(const MessageSource &source, const Channel *chan, User *user, const char *fmt, ...); - virtual void SendNotice(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...); - virtual void SendPrivmsg(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...); - virtual void SendAction(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...); - virtual void SendCTCP(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...); + virtual void SendNotice(const MessageSource &source, const Anope::string &dest, const char *fmt, ...); + virtual void SendPrivmsg(const MessageSource &source, const Anope::string &dest, const char *fmt, ...); + virtual void SendAction(const MessageSource &source, const Anope::string &dest, const char *fmt, ...); + virtual void SendCTCP(const MessageSource &source, const Anope::string &dest, const char *fmt, ...); - virtual void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) = 0; - virtual void SendGlobalPrivmsg(const BotInfo *bi, const Server *desc, const Anope::string &msg) = 0; + virtual void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) = 0; + virtual void SendGlobalPrivmsg(BotInfo *bi, const Server *desc, const Anope::string &msg) = 0; - virtual void SendQuit(const User *u, const char *fmt, ...); + virtual void SendQuit(User *u, const char *fmt, ...); virtual void SendPing(const Anope::string &servname, const Anope::string &who); virtual void SendPong(const Anope::string &servname, const Anope::string &who); @@ -146,7 +146,7 @@ class CoreExport IRCDProto : public Service * stacker to be set "soon". */ virtual void SendJoin(User *u, Channel *c, const ChannelStatus *status) = 0; - virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...); + virtual void SendPart(User *u, const Channel *chan, const char *fmt, ...); /** Force joins a user that isn't ours to a channel. * @param bi The source of the message @@ -154,30 +154,30 @@ class CoreExport IRCDProto : public Service * @param chan The channel to join the user to * @param param Channel key? */ - virtual void SendSVSJoin(const BotInfo *bi, const User *u, const Anope::string &chan, const Anope::string ¶m) { } + virtual void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) { } /** Force parts a user that isn't ours from a channel. - * @param bi The source of the message + * @param source The source of the message * @param u The user to part * @param chan The channel to part the user from * @param param part reason, some IRCds don't support this */ - virtual void SendSVSPart(const BotInfo *bi, const User *u, const Anope::string &chan, const Anope::string ¶m) { } + virtual void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) { } - virtual void SendInvite(const BotInfo *bi, const Channel *c, const User *u); - virtual void SendGlobops(const BotInfo *source, const char *fmt, ...); + virtual void SendInvite(const MessageSource &source, const Channel *c, User *u); + virtual void SendGlobops(const MessageSource &source, const char *fmt, ...); /** Sets oper flags on a user, currently only supported by Unreal */ - virtual void SendSVSO(const BotInfo *, const Anope::string &, const Anope::string &) { } + virtual void SendSVSO(BotInfo *, const Anope::string &, const Anope::string &) { } /** Sends a nick change of one of our clients. */ - virtual void SendNickChange(const User *u, const Anope::string &newnick); + virtual void SendNickChange(User *u, const Anope::string &newnick); /** Forces a nick change of a user that isn't ours (SVSNICK) */ - virtual void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when); + virtual void SendForceNickChange(User *u, const Anope::string &newnick, time_t when); /** Used to introduce ourselves to our uplink. Usually will SendServer(Me) and any other * initial handshake requirements. @@ -193,7 +193,7 @@ class CoreExport IRCDProto : public Service virtual void SendSVSHold(const Anope::string &, time_t) { } virtual void SendSVSHoldDel(const Anope::string &) { } - virtual void SendSWhois(const BotInfo *bi, const Anope::string &, const Anope::string &) { } + virtual void SendSWhois(const MessageSource &, const Anope::string &, const Anope::string &) { } /** Introduces a server to the uplink */ @@ -237,10 +237,11 @@ class CoreExport MessageSource MessageSource(const Anope::string &); MessageSource(User *u); MessageSource(Server *s); - const Anope::string GetName(); - const Anope::string &GetSource(); - User *GetUser(); - Server *GetServer(); + const Anope::string &GetName() const; + const Anope::string &GetSource() const; + User *GetUser() const; + BotInfo *GetBot() const; + Server *GetServer() const; }; enum IRCDMessageFlag diff --git a/include/servers.h b/include/servers.h index fe5f40365..04a174e5b 100644 --- a/include/servers.h +++ b/include/servers.h @@ -173,7 +173,7 @@ class CoreExport Server : public Extensible * @param source The source of the message * @param message The message */ - void Notice(const BotInfo *source, const Anope::string &message); + void Notice(BotInfo *source, const Anope::string &message); /** Find a server * @param name The name or SID/numeric diff --git a/include/uplink.h b/include/uplink.h index 1c92f6941..ac62e659d 100644 --- a/include/uplink.h +++ b/include/uplink.h @@ -14,6 +14,7 @@ #define UPLINK_H #include "sockets.h" +#include "protocol.h" namespace Uplink { @@ -33,16 +34,12 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket /* A message sent over the uplink socket */ class CoreExport Message { - private: - /* The source of the message, can be a server (Me), or any user (one of our bots) */ - const Server *server; - const User *user; + MessageSource source; std::stringstream buffer; public: Message(); - explicit Message(const Server *); - explicit Message(const User *); + Message(const MessageSource &); ~Message(); template<typename T> Message &operator<<(const T &val) { diff --git a/include/users.h b/include/users.h index 4a4ea845f..26aeb24bb 100644 --- a/include/users.h +++ b/include/users.h @@ -36,6 +36,9 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe bool quit; /* Users that are in the process of quitting */ static std::list<User *> quitting_users; + + public: + typedef std::map<Anope::string, Anope::string> ModeList; protected: Anope::string vident; Anope::string ident; @@ -43,7 +46,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe /* If the user is on the access list of the nick theyre on */ bool on_access; /* Map of user modes and the params this user has (if any) */ - std::map<Anope::string, Anope::string> modes; + ModeList modes; /* NickCore account the user is currently loggged in as, if they are logged in */ Serialize::Reference<NickCore> nc; @@ -185,8 +188,8 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe * @param fmt Format of the Message * @param ... any number of parameters */ - void SendMessage(const BotInfo *source, const char *fmt, ...); - void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override; + void SendMessage(BotInfo *source, const char *fmt, ...); + void SendMessage(BotInfo *source, const Anope::string &msg) anope_override; /** Identify the user to a nick. * updates last_seen, logs the user in, @@ -250,58 +253,63 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe bool HasMode(const Anope::string &name) const; /** Set a mode internally on the user, the IRCd is not informed + * @param setter who/what is setting the mode * @param um The user mode * @param Param The param, if there is one */ - void SetModeInternal(UserMode *um, const Anope::string ¶m = ""); + void SetModeInternal(const MessageSource &setter, UserMode *um, const Anope::string ¶m = ""); /** Remove a mode internally on the user, the IRCd is not informed + * @param setter who/what is setting the mode * @param um The user mode */ - void RemoveModeInternal(UserMode *um); + void RemoveModeInternal(const MessageSource &setter, UserMode *um); /** Set a mode on the user * @param bi The client setting the mode * @param um The user mode * @param Param Optional param for the mode */ - void SetMode(const BotInfo *bi, UserMode *um, const Anope::string ¶m = ""); + void SetMode(BotInfo *bi, UserMode *um, const Anope::string ¶m = ""); /** Set a mode on the user * @param bi The client setting the mode * @param name The mode name * @param Param Optional param for the mode */ - void SetMode(const BotInfo *bi, const Anope::string &name, const Anope::string ¶m = ""); + void SetMode(BotInfo *bi, const Anope::string &name, const Anope::string ¶m = ""); /** Remove a mode on the user * @param bi The client setting the mode * @param um The user mode */ - void RemoveMode(const BotInfo *bi, UserMode *um); + void RemoveMode(BotInfo *bi, UserMode *um); /** Remove a mode from the user * @param bi The client setting the mode * @param name The mode name */ - void RemoveMode(const BotInfo *bi, const Anope::string &name); + void RemoveMode(BotInfo *bi, const Anope::string &name); /** Set a string of modes on a user * @param bi The client setting the modes * @param umodes The modes */ - void SetModes(const BotInfo *bi, const char *umodes, ...); + void SetModes(BotInfo *bi, const char *umodes, ...); /** Set a string of modes on a user internally + * @param setter who/what is setting the mode * @param umodes The modes */ - void SetModesInternal(const char *umodes, ...); + void SetModesInternal(const MessageSource &source, const char *umodes, ...); /** Get modes set for this user. * @return A string of modes set on the user */ Anope::string GetModes() const; + const ModeList &GetModeList() const; + /** Find the channel container for Channel c that the user is on * This is preferred over using FindUser in Channel, as there are usually more users in a channel * than channels a user is in @@ -319,13 +327,13 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe * @param source The user/server doing the kill * @param reason The reason for the kill */ - void Kill(const Anope::string &source, const Anope::string &reason); + void Kill(const MessageSource &source, const Anope::string &reason); /** Process a kill for a user * @param source The user/server doing the kill * @param reason The reason for the kill */ - void KillInternal(const Anope::string &source, const Anope::string &reason); + void KillInternal(const MessageSource &source, const Anope::string &reason); /** Processes a quit for the user, and marks them as quit * @param reason The reason for the quit diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 94186c13b..c0f702a94 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -55,7 +55,7 @@ class CommandBSSay : public Command return; } - IRCD->SendPrivmsg(ci->bi, ci->name, "%s", text.c_str()); + IRCD->SendPrivmsg(*ci->bi, ci->name, "%s", text.c_str()); ci->bi->lastmsg = Anope::CurTime; bool override = !source.AccessFor(ci).HasPriv("SAY"); @@ -113,7 +113,7 @@ class CommandBSAct : public Command if (message.empty()) return; - IRCD->SendAction(ci->bi, ci->name, "%s", message.c_str()); + IRCD->SendAction(*ci->bi, ci->name, "%s", message.c_str()); ci->bi->lastmsg = Anope::CurTime; bool override = !source.AccessFor(ci).HasPriv("SAY"); diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 7fa7d3c7a..c3f40c799 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -351,7 +351,7 @@ class CSSeen : public Module UpdateUser(u, PART, u->nick, "", channel, msg); } - void OnPreUserKicked(MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) anope_override + void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) anope_override { UpdateUser(cu->user, KICK, cu->user->nick, source.GetSource(), cu->chan->name, msg); } diff --git a/modules/commands/greet.cpp b/modules/commands/greet.cpp index dd3fce66f..90f263557 100644 --- a/modules/commands/greet.cpp +++ b/modules/commands/greet.cpp @@ -188,7 +188,7 @@ class Greet : public Module Anope::string *greet = ns_greet.Get(user->Account()); if (bs_greet.HasExt(c->ci) && greet != NULL && !greet->empty() && c->FindUser(c->ci->bi) && c->ci->AccessFor(user).HasPriv("GREET")) { - IRCD->SendPrivmsg(c->ci->bi, c->name, "[%s] %s", user->Account()->display.c_str(), greet->c_str()); + IRCD->SendPrivmsg(*c->ci->bi, c->name, "[%s] %s", user->Account()->display.c_str(), greet->c_str()); c->ci->bi->lastmsg = Anope::CurTime; } } diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index fd19590e8..abe3d314b 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -11,7 +11,7 @@ #include "module.h" -static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi); +static bool SendRegmail(User *u, const NickAlias *na, BotInfo *bi); class CommandNSConfirm : public Command { @@ -381,7 +381,7 @@ class NSRegister : public Module } }; -static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi) +static bool SendRegmail(User *u, const NickAlias *na, BotInfo *bi) { NickCore *nc = na->nc; diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index 871864b6d..6af3af0c2 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -11,7 +11,7 @@ #include "module.h" -static bool SendResetEmail(User *u, const NickAlias *na, const BotInfo *bi); +static bool SendResetEmail(User *u, const NickAlias *na, BotInfo *bi); class CommandNSResetPass : public Command { @@ -112,7 +112,7 @@ class NSResetPass : public Module } }; -static bool SendResetEmail(User *u, const NickAlias *na, const BotInfo *bi) +static bool SendResetEmail(User *u, const NickAlias *na, BotInfo *bi) { int min = 1, max = 62; int chars[] = { diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index df35f0582..83c03924d 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -367,7 +367,7 @@ class CommandNSSASetDisplay : public CommandNSSetDisplay class CommandNSSetEmail : public Command { - static bool SendConfirmMail(User *u, const BotInfo *bi, const Anope::string &new_email) + static bool SendConfirmMail(User *u, BotInfo *bi, const Anope::string &new_email) { int chars[] = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index 6ea3ab71b..45a857474 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -65,6 +65,8 @@ struct NSMiscData : Serializable ExtensibleItem<NSMiscData> *item = GetItem(sname); if (item) d = item->Set(nc, NSMiscData(nc, sname, sdata)); + else + d = NULL; } return d; diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 58d18558b..1a335bc04 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -284,7 +284,7 @@ class OSDefcon : public Module if ((cm = ModeManager::FindChannelModeByChar(mode))) { - if (cm->type == MODE_STATUS || cm->type == MODE_LIST || !cm->CanSet(NULL)) + if (cm->type == MODE_STATUS || cm->type == MODE_LIST) { Log(this) << "DefConChanModes mode character '" << mode << "' cannot be locked"; continue; diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index cb6a9fcfa..bdff3c5eb 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -387,7 +387,7 @@ class OSNews : public Module { } - void OnUserModeSet(User *u, const Anope::string &mname) anope_override + void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override { if (mname == "OPER") DisplayNews(u, NEWS_OPER); diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp index 0b5dc74d9..cae4d6f68 100644 --- a/modules/commands/os_noop.cpp +++ b/modules/commands/os_noop.cpp @@ -85,7 +85,7 @@ class OSNOOP : public Module } - void OnUserModeSet(User *u, const Anope::string &mname) anope_override + void OnUserModeSet(const MessageSource &, User *u, const Anope::string &mname) anope_override { Anope::string *setter; if (mname == "OPER" && (setter = noop.Get(u->server))) diff --git a/modules/commands/os_svs.cpp b/modules/commands/os_svs.cpp index 4e9a31e6b..1c492579c 100644 --- a/modules/commands/os_svs.cpp +++ b/modules/commands/os_svs.cpp @@ -99,7 +99,7 @@ class CommandOSSVSJoin : public Command source.Reply(_("\002%s\002 is already in \002%s\002."), target->nick.c_str(), c->name.c_str()); else { - IRCD->SendSVSJoin(source.service, target, params[1], ""); + IRCD->SendSVSJoin(*source.service, target, params[1], ""); Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to join " << params[1]; source.Reply(_("\002%s\002 has been joined to \002%s\002."), target->nick.c_str(), params[1].c_str()); } @@ -143,7 +143,7 @@ class CommandOSSVSPart : public Command source.Reply(_("\002%s\002 is not in \002%s\002."), target->nick.c_str(), c->name.c_str()); else { - IRCD->SendSVSPart(source.service, target, params[1], ""); + IRCD->SendSVSPart(*source.service, target, params[1], ""); Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name; source.Reply(_("\002%s\002 has been parted from \002%s\002."), target->nick.c_str(), c->name.c_str()); } diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp index 7f8adb60e..c772a28a0 100644 --- a/modules/extra/m_proxyscan.cpp +++ b/modules/extra/m_proxyscan.cpp @@ -341,7 +341,7 @@ class ModuleProxyScan : public Module if (!this->con_notice.empty() && !this->con_source.empty()) { - const BotInfo *bi = BotInfo::Find(this->con_source); + BotInfo *bi = BotInfo::Find(this->con_source); if (bi) user->SendMessage(bi, this->con_notice); } diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index c1db97603..17dd8b96f 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -91,7 +91,7 @@ class MyXMLRPCEvent : public XMLRPCEvent XMLRPCommandReply(Anope::string &s) : str(s) { } - void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override + void SendMessage(BotInfo *, const Anope::string &msg) anope_override { str += msg + "\n"; }; diff --git a/modules/extra/webcpanel/webcpanel.cpp b/modules/extra/webcpanel/webcpanel.cpp index c8926a150..f92dda579 100644 --- a/modules/extra/webcpanel/webcpanel.cpp +++ b/modules/extra/webcpanel/webcpanel.cpp @@ -247,7 +247,7 @@ namespace WebPanel MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { } - void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override + void SendMessage(BotInfo *source, const Anope::string &msg) anope_override { re[k] = msg; } diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 162b80e0b..c9ad9c5fd 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -45,33 +45,27 @@ class BahamutIRCdProto : public IRCDProto MaxModes = 60; } - void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override + void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) anope_override { if (Servers::Capab.count("TSMODE") > 0) { - if (source) - UplinkSocket::Message(source) << "MODE " << dest->name << " " << dest->creation_time << " " << buf; - else - UplinkSocket::Message(Me) << "MODE " << dest->name << " " << dest->creation_time << " " << buf; + UplinkSocket::Message(source) << "MODE " << dest->name << " " << dest->creation_time << " " << buf; } else IRCDProto::SendModeInternal(source, dest, buf); } - void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override + void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override { - if (bi) - UplinkSocket::Message(bi) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf; - else - UplinkSocket::Message(Me) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf; + UplinkSocket::Message(source) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg; } - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; } @@ -155,9 +149,9 @@ class BahamutIRCdProto : public IRCDProto } /* TOPIC */ - void SendTopic(BotInfo *whosets, Channel *c) anope_override + void SendTopic(const MessageSource &source, Channel *c) anope_override { - UplinkSocket::Message(whosets) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic; + UplinkSocket::Message(source) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic; } /* UNSQLINE */ @@ -233,12 +227,9 @@ class BahamutIRCdProto : public IRCDProto /* Note: if the stamp is null 0, the below usage is correct of Bahamut */ - void SendSVSKillInternal(const BotInfo *source, User *user, const Anope::string &buf) anope_override + void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override { - if (source) - UplinkSocket::Message(source) << "SVSKILL " << user->nick << " :" << buf; - else - UplinkSocket::Message() << "SVSKILL " << user->nick << " :" << buf; + UplinkSocket::Message(source) << "SVSKILL " << user->nick << " :" << buf; } void SendBOB() anope_override @@ -251,7 +242,7 @@ class BahamutIRCdProto : public IRCDProto UplinkSocket::Message() << "BURST 0"; } - void SendClientIntroduction(const User *u) anope_override + void SendClientIntroduction(User *u) anope_override { Anope::string modes = "+" + u->GetModes(); UplinkSocket::Message() << "NICK " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " " << u->server->GetName() << " 0 0 :" << u->realname; @@ -341,7 +332,7 @@ struct IRCDMessageMode : IRCDMessage { User *u = User::Find(params[0]); if (u) - u->SetModesInternal("%s", params[1].c_str()); + u->SetModesInternal(source, "%s", params[1].c_str()); } } }; @@ -506,14 +497,14 @@ class ProtoBahamut : public Module void AddModes() { /* Add user modes */ - ModeManager::AddUserMode(new UserMode("SERV_ADMIN", 'A')); + ModeManager::AddUserMode(new UserModeOperOnly("SERV_ADMIN", 'A')); ModeManager::AddUserMode(new UserMode("REGPRIV", 'R')); - ModeManager::AddUserMode(new UserMode("ADMIN", 'a')); + ModeManager::AddUserMode(new UserModeOperOnly("ADMIN", 'a')); ModeManager::AddUserMode(new UserMode("INVIS", 'i')); - ModeManager::AddUserMode(new UserMode("OPER", 'o')); - ModeManager::AddUserMode(new UserMode("REGISTERED", 'r')); - ModeManager::AddUserMode(new UserMode("SNOMASK", 's')); - ModeManager::AddUserMode(new UserMode("WALLOPS", 'w')); + ModeManager::AddUserMode(new UserModeOperOnly("OPER", 'o')); + ModeManager::AddUserMode(new UserModeNoone("REGISTERED", 'r')); + ModeManager::AddUserMode(new UserModeOperOnly("SNOMASK", 's')); + ModeManager::AddUserMode(new UserModeOperOnly("WALLOPS", 'w')); ModeManager::AddUserMode(new UserMode("DEAF", 'd')); /* b/e/I */ @@ -532,11 +523,11 @@ class ProtoBahamut : public Module ModeManager::AddChannelMode(new ChannelMode("MODERATED", 'm')); ModeManager::AddChannelMode(new ChannelMode("NOEXTERNAL", 'n')); ModeManager::AddChannelMode(new ChannelMode("PRIVATE", 'p')); - ModeManager::AddChannelMode(new ChannelModeRegistered('r')); + ModeManager::AddChannelMode(new ChannelModeNoone("REGISTERED", 'r')); ModeManager::AddChannelMode(new ChannelMode("SECRET", 's')); ModeManager::AddChannelMode(new ChannelMode("TOPIC", 't')); ModeManager::AddChannelMode(new ChannelMode("REGMODERATED", 'M')); - ModeManager::AddChannelMode(new ChannelModeOper('O')); + ModeManager::AddChannelMode(new ChannelModeOperOnly("OPERONLY", 'O')); ModeManager::AddChannelMode(new ChannelMode("REGISTEREDONLY", 'R')); } @@ -558,7 +549,7 @@ class ProtoBahamut : public Module void OnUserNickChange(User *u, const Anope::string &) anope_override { - u->RemoveModeInternal(ModeManager::FindUserModeByName("REGISTERED")); + u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED")); IRCD->SendLogout(u); } }; diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index 0ef438b7d..490092a67 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -46,9 +46,9 @@ class CharybdisProto : public IRCDProto MaxModes = 4; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { ratbox->SendGlobalNotice(bi, dest, msg); } - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { ratbox->SendGlobalPrivmsg(bi, dest, msg); } - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override { ratbox->SendGlobopsInternal(source, buf); } + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { ratbox->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { ratbox->SendGlobalPrivmsg(bi, dest, msg); } + void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override { ratbox->SendGlobopsInternal(source, buf); } void SendSGLine(User *u, const XLine *x) anope_override { ratbox->SendSGLine(u, x); } void SendSGLineDel(const XLine *x) anope_override { ratbox->SendSGLineDel(x); } void SendAkill(User *u, XLine *x) anope_override { ratbox->SendAkill(u, x); } @@ -57,7 +57,7 @@ class CharybdisProto : public IRCDProto void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { ratbox->SendJoin(user, c, status); } void SendServer(const Server *server) anope_override { ratbox->SendServer(server); } void SendChannel(Channel *c) anope_override { ratbox->SendChannel(c); } - void SendTopic(BotInfo *bi, Channel *c) anope_override { ratbox->SendTopic(bi, c); } + void SendTopic(const MessageSource &source, Channel *c) anope_override { ratbox->SendTopic(source, c); } void SendSQLine(User *, const XLine *x) anope_override { @@ -105,7 +105,7 @@ class CharybdisProto : public IRCDProto UplinkSocket::Message() << "SVINFO 6 6 0 :" << Anope::CurTime; } - void SendClientIntroduction(const User *u) anope_override + void SendClientIntroduction(User *u) anope_override { Anope::string modes = "+" + u->GetModes(); UplinkSocket::Message(Me) << "EUID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " * * :" << u->realname; @@ -124,7 +124,7 @@ class CharybdisProto : public IRCDProto UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID(); } - void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when) anope_override + void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override { UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " RSFNC " << u->GetUID() << " " << newnick << " " << when << " " << u->timestamp; @@ -362,13 +362,13 @@ class ProtoCharybdis : public Module void AddModes() { /* Add user modes */ - ModeManager::AddUserMode(new UserMode("DEAF", 'D')); + ModeManager::AddUserMode(new UserModeOperOnly("DEAF", 'D')); ModeManager::AddUserMode(new UserMode("CALLERID", 'g')); ModeManager::AddUserMode(new UserMode("REGPRIV", 'R')); - ModeManager::AddUserMode(new UserMode("SSL", 'Z')); - ModeManager::AddUserMode(new UserMode("LOCOPS", 'l')); - ModeManager::AddUserMode(new UserMode("OPERWALLS", 'z')); - ModeManager::AddUserMode(new UserMode("PROTECTED", 'S')); + ModeManager::AddUserMode(new UserModeNoone("SSL", 'Z')); + ModeManager::AddUserMode(new UserModeOperOnly("LOCOPS", 'l')); + ModeManager::AddUserMode(new UserModeOperOnly("OPERWALLS", 'z')); + ModeManager::AddUserMode(new UserModeNoone("PROTECTED", 'S')); ModeManager::AddUserMode(new UserMode("NOFORWARD", 'Q')); // charybdis has no usermode for registered users diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 41c1a37f1..07977b961 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -30,17 +30,17 @@ class HybridProto : public IRCDProto MaxModes = 4; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "NOTICE $$" << dest->GetName() << " :" << msg; } - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "PRIVMSG $$" << dest->GetName() << " :" << msg; } - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override + void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override { UplinkSocket::Message(source) << "GLOBOPS :" << buf; } @@ -186,7 +186,7 @@ class HybridProto : public IRCDProto UplinkSocket::Message() << "SVINFO 6 5 0 :" << Anope::CurTime; } - void SendClientIntroduction(const User *u) anope_override + void SendClientIntroduction(User *u) anope_override { Anope::string modes = "+" + u->GetModes(); @@ -199,12 +199,9 @@ class HybridProto : public IRCDProto UplinkSocket::Message(Me) << "EOB"; } - void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override + void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override { - if (bi) - UplinkSocket::Message(bi) << "SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf; - else - UplinkSocket::Message(Me) << "SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf; + UplinkSocket::Message(source) << "SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf; } void SendLogin(User *u) anope_override @@ -227,8 +224,9 @@ class HybridProto : public IRCDProto UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :"; } - void SendTopic(BotInfo *bi, Channel *c) anope_override + void SendTopic(const MessageSource &source, Channel *c) anope_override { + BotInfo *bi = source.GetBot(); bool needjoin = c->FindUser(bi) == NULL; if (needjoin) @@ -239,13 +237,13 @@ class HybridProto : public IRCDProto bi->Join(c, &status); } - IRCDProto::SendTopic(bi, c); + IRCDProto::SendTopic(source, c); if (needjoin) bi->Part(c); } - void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when) anope_override + void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override { UplinkSocket::Message(Me) << "SVSNICK " << u->nick << " " << newnick << " " << when; } @@ -440,7 +438,7 @@ struct IRCDMessageSVSMode : IRCDMessage if (!params[1].is_pos_number_only() || convertTo<time_t>(params[1]) != u->timestamp) return; - u->SetModesInternal("%s", params[2].c_str()); + u->SetModesInternal(source, "%s", params[2].c_str()); } }; @@ -569,19 +567,19 @@ class ProtoHybrid : public Module void AddModes() { /* Add user modes */ - ModeManager::AddUserMode(new UserMode("ADMIN", 'a')); - ModeManager::AddUserMode(new UserMode("CALLERID", 'g')); + ModeManager::AddUserMode(new UserModeOperOnly("ADMIN", 'a')); + ModeManager::AddUserMode(new UserModeOperOnly("CALLERID", 'g')); ModeManager::AddUserMode(new UserMode("INVIS", 'i')); - ModeManager::AddUserMode(new UserMode("LOCOPS", 'l')); + ModeManager::AddUserMode(new UserModeOperOnly("LOCOPS", 'l')); ModeManager::AddUserMode(new UserMode("OPER", 'o')); - ModeManager::AddUserMode(new UserMode("REGISTERED", 'r')); - ModeManager::AddUserMode(new UserMode("SNOMASK", 's')); + ModeManager::AddUserMode(new UserModeNoone("REGISTERED", 'r')); + ModeManager::AddUserMode(new UserModeOperOnly("SNOMASK", 's')); ModeManager::AddUserMode(new UserMode("WALLOPS", 'w')); - ModeManager::AddUserMode(new UserMode("OPERWALLS", 'z')); + ModeManager::AddUserMode(new UserModeOperOnly("OPERWALLS", 'z')); ModeManager::AddUserMode(new UserMode("DEAF", 'D')); - ModeManager::AddUserMode(new UserMode("HIDEOPER", 'H')); + ModeManager::AddUserMode(new UserModeOperOnly("HIDEOPER", 'H')); ModeManager::AddUserMode(new UserMode("REGPRIV", 'R')); - ModeManager::AddUserMode(new UserMode("SSL", 'S')); + ModeManager::AddUserMode(new UserModeNoone("SSL", 'S')); /* b/e/I */ ModeManager::AddChannelMode(new ChannelModeList("BAN", 'b')); @@ -603,10 +601,10 @@ class ProtoHybrid : public Module ModeManager::AddChannelMode(new ChannelMode("MODERATED", 'm')); ModeManager::AddChannelMode(new ChannelMode("NOEXTERNAL", 'n')); ModeManager::AddChannelMode(new ChannelMode("PRIVATE", 'p')); - ModeManager::AddChannelMode(new ChannelModeRegistered('r')); + ModeManager::AddChannelMode(new ChannelModeNoone("REGISTERED", 'r')); ModeManager::AddChannelMode(new ChannelMode("SECRET", 's')); ModeManager::AddChannelMode(new ChannelMode("TOPIC", 't')); - ModeManager::AddChannelMode(new ChannelModeOper('O')); + ModeManager::AddChannelMode(new ChannelModeOperOnly("OPERONLY", 'O')); ModeManager::AddChannelMode(new ChannelMode("REGMODERATED", 'M')); ModeManager::AddChannelMode(new ChannelMode("REGISTEREDONLY", 'R')); ModeManager::AddChannelMode(new ChannelMode("SSL", 'S')); @@ -629,7 +627,7 @@ public: void OnUserNickChange(User *u, const Anope::string &) anope_override { - u->RemoveModeInternal(ModeManager::FindUserModeByName("REGISTERED")); + u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED")); } }; diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index ca8fdc608..c4254537a 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -43,10 +43,10 @@ class ChannelModeFlood : public ChannelModeParam class InspIRCd12Proto : public IRCDProto { private: - void SendSVSKillInternal(const BotInfo *source, User *user, const Anope::string &buf) anope_override + void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override { IRCDProto::SendSVSKillInternal(source, user, buf); - user->KillInternal(source ? source->nick : Me->GetName(), buf); + user->KillInternal(source, buf); } void SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent) @@ -91,12 +91,12 @@ class InspIRCd12Proto : public IRCDProto MaxModes = 20; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg; } - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; } @@ -119,7 +119,7 @@ class InspIRCd12Proto : public IRCDProto SendDelLine("G", x->mask); } - void SendTopic(BotInfo *whosets, Channel *c) anope_override + void SendTopic(const MessageSource &source, Channel *c) anope_override { if (Servers::Capab.count("SVSTOPIC")) { @@ -132,7 +132,7 @@ class InspIRCd12Proto : public IRCDProto if (c->topic_time > ts) ts = Anope::CurTime; /* But don't modify c->topic_ts, it should remain set to the real TS we want as ci->last_topic_time pulls from it */ - UplinkSocket::Message(whosets) << "FTOPIC " << c->name << " " << ts << " " << c->topic_setter << " :" << c->topic; + UplinkSocket::Message(source) << "FTOPIC " << c->name << " " << ts << " " << c->topic_setter << " :" << c->topic; } } @@ -206,12 +206,12 @@ class InspIRCd12Proto : public IRCDProto UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << dest << " " << buf; } - void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override + void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) anope_override { UplinkSocket::Message(source) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf; } - void SendClientIntroduction(const User *u) anope_override + void SendClientIntroduction(User *u) anope_override { Anope::string modes = "+" + u->GetModes(); UplinkSocket::Message(Me) << "UID " << u->GetUID() << " " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " 0.0.0.0 " << u->timestamp << " " << modes << " :" << u->realname; @@ -319,12 +319,12 @@ class InspIRCd12Proto : public IRCDProto SendAddLine("Z", x->GetHost(), timeleft, x->by, x->GetReason()); } - void SendSVSJoin(const BotInfo *source, const User *u, const Anope::string &chan, const Anope::string &) anope_override + void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) anope_override { UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan; } - void SendSVSPart(const BotInfo *source, const User *u, const Anope::string &chan, const Anope::string ¶m) anope_override + void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) anope_override { if (!param.empty()) UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan << " :" << param; @@ -332,7 +332,7 @@ class InspIRCd12Proto : public IRCDProto UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan; } - void SendSWhois(const BotInfo *, const Anope::string &who, const Anope::string &mask) anope_override + void SendSWhois(const MessageSource &, const Anope::string &who, const Anope::string &mask) anope_override { User *u = User::Find(who); @@ -349,7 +349,7 @@ class InspIRCd12Proto : public IRCDProto UplinkSocket::Message(Me) << "ENDBURST"; } - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) + void SendGlobopsInternal(BotInfo *source, const Anope::string &buf) { if (Servers::Capab.count("GLOBOPS")) UplinkSocket::Message(source) << "SNONOTICE g :" << buf; @@ -577,7 +577,7 @@ struct IRCDMessageCapab : Message::Capab ModeManager::AddChannelMode(new ChannelMode("NONICK", 'N')); continue; case 'O': - ModeManager::AddChannelMode(new ChannelModeOper('O')); + ModeManager::AddChannelMode(new ChannelModeOperOnly("OPERONLY", 'O')); continue; case 'P': ModeManager::AddChannelMode(new ChannelMode("PERM", 'P')); @@ -610,7 +610,7 @@ struct IRCDMessageCapab : Message::Capab ModeManager::AddChannelMode(new ChannelMode("PRIVATE", 'p')); continue; case 'r': - ModeManager::AddChannelMode(new ChannelModeRegistered('r')); + ModeManager::AddChannelMode(new ChannelModeNoone("REGISTERED", 'r')); continue; case 's': ModeManager::AddChannelMode(new ChannelMode("SECRET", 's')); @@ -642,7 +642,7 @@ struct IRCDMessageCapab : Message::Capab switch (modebuf[t]) { case 'h': - ModeManager::AddUserMode(new UserMode("HELPOP", 'h')); + ModeManager::AddUserMode(new UserModeOperOnly("HELPOP", 'h')); continue; case 'B': ModeManager::AddUserMode(new UserMode("BOT", 'B')); @@ -651,13 +651,13 @@ struct IRCDMessageCapab : Message::Capab ModeManager::AddUserMode(new UserMode("FILTER", 'G')); continue; case 'H': - ModeManager::AddUserMode(new UserMode("HIDEOPER", 'H')); + ModeManager::AddUserMode(new UserModeOperOnly("HIDEOPER", 'H')); continue; case 'I': ModeManager::AddUserMode(new UserMode("PRIV", 'I')); continue; case 'Q': - ModeManager::AddUserMode(new UserMode("HIDDEN", 'Q')); + ModeManager::AddUserMode(new UserModeOperOnly("HIDDEN", 'Q')); continue; case 'R': ModeManager::AddUserMode(new UserMode("REGPRIV", 'R')); @@ -678,13 +678,13 @@ struct IRCDMessageCapab : Message::Capab ModeManager::AddUserMode(new UserMode("INVIS", 'i')); continue; case 'k': - ModeManager::AddUserMode(new UserMode("PROTECTED", 'k')); + ModeManager::AddUserMode(new UserModeNoone("PROTECTED", 'k')); continue; case 'o': - ModeManager::AddUserMode(new UserMode("OPER", 'o')); + ModeManager::AddUserMode(new UserModeOperOnly("OPER", 'o')); continue; case 'r': - ModeManager::AddUserMode(new UserMode("REGISTERED", 'r')); + ModeManager::AddUserMode(new UserModeNoone("REGISTERED", 'r')); continue; case 'w': ModeManager::AddUserMode(new UserMode("WALLOPS", 'w')); @@ -1008,7 +1008,7 @@ struct IRCDMessageIdle : IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - const BotInfo *bi = BotInfo::Find(params[0]); + BotInfo *bi = BotInfo::Find(params[0]); if (bi) UplinkSocket::Message(bi) << "IDLE " << source.GetSource() << " " << Anope::StartTime << " " << (Anope::CurTime - bi->lastmsg); } @@ -1145,7 +1145,7 @@ struct IRCDMessageMode : IRCDMessage // if it's still null, drop it like fire. // most likely situation was that server introduced a nick which we subsequently akilled if (u) - u->SetModesInternal("%s", params[1].c_str()); + u->SetModesInternal(source, "%s", params[1].c_str()); } } }; @@ -1170,7 +1170,7 @@ struct IRCDMessageOperType : IRCDMessage dont do this directly */ User *u = source.GetUser(); if (!u->HasMode("OPER")) - u->SetModesInternal("+o"); + u->SetModesInternal(source, "+o"); } }; diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index d4fac12aa..34e87935a 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -42,16 +42,16 @@ class InspIRCd20Proto : public IRCDProto insp12->SendConnect(); } - void SendSVSKillInternal(const BotInfo *source, User *user, const Anope::string &buf) anope_override { insp12->SendSVSKillInternal(source, user, buf); } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalNotice(bi, dest, msg); } - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalPrivmsg(bi, dest, msg); } + void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override { insp12->SendSVSKillInternal(source, user, buf); } + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalPrivmsg(bi, dest, msg); } void SendAkillDel(const XLine *x) anope_override { insp12->SendAkillDel(x); } - void SendTopic(BotInfo *whosets, Channel *c) anope_override { insp12->SendTopic(whosets, c); }; + void SendTopic(const MessageSource &whosets, Channel *c) anope_override { insp12->SendTopic(whosets, c); }; void SendVhostDel(User *u) anope_override { insp12->SendVhostDel(u); } void SendAkill(User *u, XLine *x) anope_override { insp12->SendAkill(u, x); } void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override { insp12->SendNumericInternal(numeric, dest, buf); } - void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override { insp12->SendModeInternal(source, dest, buf); } - void SendClientIntroduction(const User *u) anope_override { insp12->SendClientIntroduction(u); } + void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) anope_override { insp12->SendModeInternal(source, dest, buf); } + void SendClientIntroduction(User *u) anope_override { insp12->SendClientIntroduction(u); } void SendServer(const Server *server) anope_override { insp12->SendServer(server); } void SendSquit(Server *s, const Anope::string &message) anope_override { insp12->SendSquit(s, message); } void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { insp12->SendJoin(user, c, status); } @@ -62,12 +62,12 @@ class InspIRCd20Proto : public IRCDProto void SendSVSHoldDel(const Anope::string &nick) anope_override { insp12->SendSVSHoldDel(nick); } void SendSZLineDel(const XLine *x) anope_override { insp12->SendSZLineDel(x); } void SendSZLine(User *u, const XLine *x) anope_override { insp12->SendSZLine(u, x); } - void SendSVSJoin(const BotInfo *source, const User *u, const Anope::string &chan, const Anope::string &other) anope_override { insp12->SendSVSJoin(source, u, chan, other); } - void SendSVSPart(const BotInfo *source, const User *u, const Anope::string &chan, const Anope::string ¶m) anope_override { insp12->SendSVSPart(source, u, chan, param); } - void SendSWhois(const BotInfo *bi, const Anope::string &who, const Anope::string &mask) anope_override { insp12->SendSWhois(bi, who, mask); } + void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &other) anope_override { insp12->SendSVSJoin(source, u, chan, other); } + void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) anope_override { insp12->SendSVSPart(source, u, chan, param); } + void SendSWhois(const MessageSource &bi, const Anope::string &who, const Anope::string &mask) anope_override { insp12->SendSWhois(bi, who, mask); } void SendBOB() anope_override { insp12->SendBOB(); } void SendEOB() anope_override { insp12->SendEOB(); } - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) { insp12->SendGlobopsInternal(source, buf); } + void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) { insp12->SendGlobopsInternal(source, buf); } void SendLogin(User *u) anope_override { insp12->SendLogin(u); } void SendLogout(User *u) anope_override { insp12->SendLogout(u); } void SendChannel(Channel *c) anope_override { insp12->SendChannel(c); } @@ -313,7 +313,7 @@ struct IRCDMessageCapab : Message::Capab else if (modename.equals_cs("blockcolor")) cm = new ChannelMode("BLOCKCOLOR", modechar[0]); else if (modename.equals_cs("c_registered")) - cm = new ChannelModeRegistered(modechar[0]); + cm = new ChannelModeNoone("REGISTERED", modechar[0]); else if (modename.equals_cs("censor")) cm = new ChannelMode("FILTER", modechar[0]); else if (modename.equals_cs("delayjoin")) @@ -361,7 +361,7 @@ struct IRCDMessageCapab : Message::Capab else if (modename.equals_cs("op")) cm = new ChannelModeStatus("OP", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 2); else if (modename.equals_cs("operonly")) - cm = new ChannelModeOper(modechar[0]); + cm = new ChannelModeOperOnly("OPERONLY", modechar[0]); else if (modename.equals_cs("permanent")) cm = new ChannelMode("PERM", modechar[0]); else if (modename.equals_cs("private")) @@ -415,30 +415,30 @@ struct IRCDMessageCapab : Message::Capab else if (modename.equals_cs("deaf_commonchan")) um = new UserMode("COMMONCHANS", modechar[0]); else if (modename.equals_cs("helpop")) - um = new UserMode("HELPOP", modechar[0]); + um = new UserModeOperOnly("HELPOP", modechar[0]); else if (modename.equals_cs("hidechans")) um = new UserMode("PRIV", modechar[0]); else if (modename.equals_cs("hideoper")) - um = new UserMode("HIDEOPER", modechar[0]); + um = new UserModeOperOnly("HIDEOPER", modechar[0]); else if (modename.equals_cs("invisible")) um = new UserMode("INVIS", modechar[0]); else if (modename.equals_cs("invis-oper")) - um = new UserMode("INVISIBLE_OPER", modechar[0]); + um = new UserModeOperOnly("INVISIBLE_OPER", modechar[0]); else if (modename.equals_cs("oper")) - um = new UserMode("OPER", modechar[0]); + um = new UserModeOperOnly("OPER", modechar[0]); else if (modename.equals_cs("regdeaf")) um = new UserMode("REGPRIV", modechar[0]); else if (modename.equals_cs("servprotect")) { - um = new UserMode("PROTECTED", modechar[0]); - IRCD->DefaultPseudoclientModes += "k"; + um = new UserModeNoone("PROTECTED", modechar[0]); + IRCD->DefaultPseudoclientModes += modechar; } else if (modename.equals_cs("showwhois")) um = new UserMode("WHOIS", modechar[0]); else if (modename.equals_cs("u_censor")) um = new UserMode("FILTER", modechar[0]); else if (modename.equals_cs("u_registered")) - um = new UserMode("REGISTERED", modechar[0]); + um = new UserModeNoone("REGISTERED", modechar[0]); else if (modename.equals_cs("u_stripcolor")) um = new UserMode("STRIPCOLOR", modechar[0]); else if (modename.equals_cs("wallops")) @@ -751,7 +751,7 @@ class ProtoInspIRCd : public Module void OnUserNickChange(User *u, const Anope::string &) anope_override { - u->RemoveModeInternal(ModeManager::FindUserModeByName("REGISTERED")); + u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED")); } void OnChannelSync(Channel *c) anope_override diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 0b76cddb8..d5513aab7 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -45,7 +45,7 @@ class ngIRCdProto : public IRCDProto } // Received: :dev.anope.de NICK DukeP 1 ~DukePyro p57ABF9C9.dip.t-dialin.net 1 +i :DukePyrolator - void SendClientIntroduction(const User *u) anope_override + void SendClientIntroduction(User *u) anope_override { Anope::string modes = "+" + u->GetModes(); UplinkSocket::Message(Me) << "NICK " << u->nick << " 1 " << u->GetIdent() << " " << u->host << " 1 " << modes << " :" << u->realname; @@ -60,27 +60,24 @@ class ngIRCdProto : public IRCDProto this->SendNumeric(376, "*", ":End of MOTD command"); } - void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when) anope_override + void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override { UplinkSocket::Message(Me) << "SVSNICK " << u->nick << " " << newnick; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg; } - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; } - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override + void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override { - if (source) - UplinkSocket::Message(source) << "WALLOPS :" << buf; - else - UplinkSocket::Message(Me) << "WALLOPS :" << buf; + UplinkSocket::Message(source) << "WALLOPS :" << buf; } void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override @@ -103,32 +100,29 @@ class ngIRCdProto : public IRCDProto } } - void SendKickInternal(const BotInfo *bi, const Channel *chan, const User *user, const Anope::string &buf) anope_override + void SendKickInternal(const MessageSource &source, const Channel *chan, User *user, const Anope::string &buf) anope_override { if (!buf.empty()) - UplinkSocket::Message(bi) << "KICK " << chan->name << " " << user->nick << " :" << buf; + UplinkSocket::Message(source) << "KICK " << chan->name << " " << user->nick << " :" << buf; else - UplinkSocket::Message(bi) << "KICK " << chan->name << " " << user->nick; + UplinkSocket::Message(source) << "KICK " << chan->name << " " << user->nick; } void SendLogin(User *u) anope_override { } void SendLogout(User *u) anope_override { } - void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf) anope_override + void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) anope_override { - if (bi) - UplinkSocket::Message(bi) << "MODE " << dest->name << " " << buf; - else - UplinkSocket::Message(Me) << "MODE " << dest->name << " " << buf; + UplinkSocket::Message(source) << "MODE " << dest->name << " " << buf; } - void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf) anope_override + void SendPartInternal(User *u, const Channel *chan, const Anope::string &buf) anope_override { if (!buf.empty()) - UplinkSocket::Message(bi) << "PART " << chan->name << " :" << buf; + UplinkSocket::Message(u) << "PART " << chan->name << " :" << buf; else - UplinkSocket::Message(bi) << "PART " << chan->name; + UplinkSocket::Message(u) << "PART " << chan->name; } /* SERVER name hop descript */ @@ -137,9 +131,9 @@ class ngIRCdProto : public IRCDProto UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription(); } - void SendTopic(BotInfo *bi, Channel *c) anope_override + void SendTopic(const MessageSource &source, Channel *c) anope_override { - UplinkSocket::Message(bi) << "TOPIC " << c->name << " :" << c->topic; + UplinkSocket::Message(source) << "TOPIC " << c->name << " :" << c->topic; } void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override @@ -382,7 +376,7 @@ struct IRCDMessageMode : IRCDMessage User *u = User::Find(params[0]); if (u) - u->SetModesInternal("%s", params[1].c_str()); + u->SetModesInternal(source, "%s", params[1].c_str()); } } }; @@ -604,11 +598,11 @@ class ProtongIRCd : public Module ModeManager::AddUserMode(new UserMode("BOT", 'B')); ModeManager::AddUserMode(new UserMode("COMMONCHANS", 'C')); ModeManager::AddUserMode(new UserMode("INVIS", 'i')); - ModeManager::AddUserMode(new UserMode("OPER", 'o')); - ModeManager::AddUserMode(new UserMode("PROTECTED", 'q')); - ModeManager::AddUserMode(new UserMode("RESTRICTED", 'r')); - ModeManager::AddUserMode(new UserMode("REGISTERED", 'R')); - ModeManager::AddUserMode(new UserMode("SNOMASK", 's')); + ModeManager::AddUserMode(new UserModeOperOnly("OPER", 'o')); + ModeManager::AddUserMode(new UserModeOperOnly("PROTECTED", 'q')); + ModeManager::AddUserMode(new UserModeOperOnly("RESTRICTED", 'r')); + ModeManager::AddUserMode(new UserModeNoone("REGISTERED", 'R')); + ModeManager::AddUserMode(new UserModeOperOnly("SNOMASK", 's')); ModeManager::AddUserMode(new UserMode("WALLOPS", 'w')); ModeManager::AddUserMode(new UserMode("CLOAK", 'x')); @@ -634,7 +628,7 @@ class ProtongIRCd : public Module ModeManager::AddChannelMode(new ChannelMode("OPERONLY", 'O')); ModeManager::AddChannelMode(new ChannelMode("PERM", 'P')); ModeManager::AddChannelMode(new ChannelMode("NOKICK", 'Q')); - ModeManager::AddChannelMode(new ChannelModeRegistered('r')); + ModeManager::AddChannelMode(new ChannelModeNoone("REGISTERED", 'r')); ModeManager::AddChannelMode(new ChannelMode("REGISTEREDONLY", 'R')); ModeManager::AddChannelMode(new ChannelMode("SECRET", 's')); ModeManager::AddChannelMode(new ChannelMode("TOPIC", 't')); @@ -663,7 +657,7 @@ class ProtongIRCd : public Module void OnUserNickChange(User *u, const Anope::string &) anope_override { - u->RemoveModeInternal(ModeManager::FindUserModeByName("REGISTERED")); + u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED")); } }; diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index 91a588f5a..1839b1fb9 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -34,9 +34,9 @@ class PlexusProto : public IRCDProto MaxModes = 4; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); } - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override { hybrid->SendGlobopsInternal(source, buf); } + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } + void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override { hybrid->SendGlobopsInternal(source, buf); } void SendSQLine(User *u, const XLine *x) anope_override { hybrid->SendSQLine(u, x); } void SendSQLineDel(const XLine *x) anope_override { hybrid->SendSQLineDel(x); } void SendSGLineDel(const XLine *x) anope_override { hybrid->SendSGLineDel(x); } @@ -68,7 +68,7 @@ class PlexusProto : public IRCDProto } } - void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when) anope_override + void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override { UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when; } @@ -125,15 +125,15 @@ class PlexusProto : public IRCDProto UplinkSocket::Message() << "SVINFO 6 5 0 :" << Anope::CurTime; } - void SendClientIntroduction(const User *u) anope_override + void SendClientIntroduction(User *u) anope_override { Anope::string modes = "+" + u->GetModes(); UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 255.255.255.255 " << u->GetUID() << " 0 " << u->host << " :" << u->realname; } - void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override + void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override { - UplinkSocket::Message(bi) << "ENCAP * SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf; + UplinkSocket::Message(source) << "ENCAP * SVSMODE " << u->GetUID() << " " << u->timestamp << " " << buf; } void SendLogin(User *u) anope_override @@ -149,17 +149,17 @@ class PlexusProto : public IRCDProto UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID(); } - void SendTopic(BotInfo *bi, Channel *c) anope_override + void SendTopic(const MessageSource &source, Channel *c) anope_override { - UplinkSocket::Message(bi) << "ENCAP * TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic; + UplinkSocket::Message(source) << "ENCAP * TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic; } - void SendSVSJoin(const BotInfo *source, const User *user, const Anope::string &chan, const Anope::string ¶m) anope_override + void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) anope_override { UplinkSocket::Message(source) << "ENCAP " << user->server->GetName() << " SVSJOIN " << user->GetUID() << " " << chan; } - void SendSVSPart(const BotInfo *source, const User *user, const Anope::string &chan, const Anope::string ¶m) anope_override + void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) anope_override { UplinkSocket::Message(source) << "ENCAP " << user->server->GetName() << " SVSPART " << user->GetUID() << " " << chan; } @@ -325,15 +325,12 @@ class ProtoPlexus : public Module /* Add user modes */ ModeManager::RemoveUserMode(ModeManager::FindUserModeByName("HIDEOPER")); ModeManager::AddUserMode(new UserMode("NOCTCP", 'C')); - ModeManager::AddUserMode(new UserMode("DEAF", 'D')); ModeManager::AddUserMode(new UserMode("SOFTCALLERID", 'G')); - ModeManager::AddUserMode(new UserMode("NETADMIN", 'N')); - ModeManager::AddUserMode(new UserMode("SSL", 'S')); - ModeManager::AddUserMode(new UserMode("WEBIRC", 'W')); - ModeManager::AddUserMode(new UserMode("CALLERID", 'g')); + ModeManager::AddUserMode(new UserModeOperOnly("NETADMIN", 'N')); + ModeManager::AddUserMode(new UserModeNoone("WEBIRC", 'W')); ModeManager::AddUserMode(new UserMode("PRIV", 'p')); ModeManager::AddUserMode(new UserMode("CLOAK", 'x')); - ModeManager::AddUserMode(new UserMode("PROTECTED", 'U')); + ModeManager::AddUserMode(new UserModeNoone("PROTECTED", 'U')); /* v/h/o/a/q */ ModeManager::AddChannelMode(new ChannelModeStatus("PROTECT", 'a', '&', 3)); diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 570448db2..98b7bae6c 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -28,9 +28,9 @@ class RatboxProto : public IRCDProto MaxModes = 4; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); } - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override { hybrid->SendGlobopsInternal(source, buf); } + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } + void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override { hybrid->SendGlobopsInternal(source, buf); } void SendSQLine(User *u, const XLine *x) anope_override { hybrid->SendSQLine(u, x); } void SendSGLine(User *u, const XLine *x) anope_override { hybrid->SendSGLine(u, x); } void SendSGLineDel(const XLine *x) anope_override { hybrid->SendSGLineDel(x); } @@ -39,9 +39,9 @@ class RatboxProto : public IRCDProto void SendSQLineDel(const XLine *x) anope_override { hybrid->SendSQLineDel(x); } void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { hybrid->SendJoin(user, c, status); } void SendServer(const Server *server) anope_override { hybrid->SendServer(server); } - void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override { hybrid->SendModeInternal(bi, u, buf); } + void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override { hybrid->SendModeInternal(source, u, buf); } void SendChannel(Channel *c) anope_override { hybrid->SendChannel(c); } - void SendTopic(BotInfo *bi, Channel *c) anope_override { hybrid->SendTopic(bi, c); } + void SendTopic(const MessageSource &source, Channel *c) anope_override { hybrid->SendTopic(source, c); } void SendConnect() anope_override { @@ -70,7 +70,7 @@ class RatboxProto : public IRCDProto UplinkSocket::Message() << "SVINFO 6 3 0 :" << Anope::CurTime; } - void SendClientIntroduction(const User *u) anope_override + void SendClientIntroduction(User *u) anope_override { Anope::string modes = "+" + u->GetModes(); UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " :" << u->realname; @@ -221,7 +221,7 @@ class ProtoRatbox : public Module ModeManager::RemoveUserMode(ModeManager::FindUserModeByName("HIDEOPER")); ModeManager::RemoveUserMode(ModeManager::FindUserModeByName("REGPRIV")); ModeManager::RemoveUserMode(ModeManager::FindUserModeByName("SSL")); - ModeManager::AddUserMode(new UserMode("PROTECTED", 'S')); + ModeManager::AddUserMode(new UserModeNoone("PROTECTED", 'S')); /* v/h/o/a/q */ ModeManager::RemoveChannelMode(ModeManager::FindChannelModeByName("HALFOP")); diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 0f4147554..2da4af3e8 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -58,17 +58,17 @@ class UnrealIRCdProto : public IRCDProto UplinkSocket::Message() << "TKL - G " << x->GetUser() << " " << x->GetHost() << " " << x->by; } - void SendTopic(BotInfo *whosets, Channel *c) anope_override + void SendTopic(const MessageSource &source, Channel *c) anope_override { - UplinkSocket::Message(whosets) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic; + UplinkSocket::Message(source) << "TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg; } - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; } @@ -126,18 +126,18 @@ class UnrealIRCdProto : public IRCDProto UplinkSocket::Message() << "TKL + G " << x->GetUser() << " " << x->GetHost() << " " << x->by << " " << Anope::CurTime + timeleft << " " << x->created << " :" << x->GetReason(); } - void SendSVSKillInternal(const BotInfo *source, User *user, const Anope::string &buf) anope_override + void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override { UplinkSocket::Message(source) << "SVSKILL " << user->nick << " :" << buf; - user->KillInternal(source ? source->nick : Me->GetName(), buf); + user->KillInternal(source, buf); } - void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override + void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override { - UplinkSocket::Message(bi) << "SVS2MODE " << u->nick <<" " << buf; + UplinkSocket::Message(source) << "SVS2MODE " << u->nick <<" " << buf; } - void SendClientIntroduction(const User *u) anope_override + void SendClientIntroduction(User *u) anope_override { Anope::string modes = "+" + u->GetModes(); UplinkSocket::Message() << "NICK " << u->nick << " 1 " << u->timestamp << " " << u->GetIdent() << " " << u->host << " " << u->server->GetName() << " 0 " << modes << " " << u->host << " * :" << u->realname; @@ -197,7 +197,7 @@ class UnrealIRCdProto : public IRCDProto ** parv[1] = nick ** parv[2] = options */ - void SendSVSO(const BotInfo *source, const Anope::string &nick, const Anope::string &flag) anope_override + void SendSVSO(BotInfo *source, const Anope::string &nick, const Anope::string &flag) anope_override { UplinkSocket::Message(source) << "SVSO " << nick << " " << flag; } @@ -294,7 +294,7 @@ class UnrealIRCdProto : public IRCDProto /* In older Unreal SVSJOIN and SVSNLINE tokens were mixed so SVSJOIN and SVSNLINE are broken when coming from a none TOKEN'd server */ - void SendSVSJoin(const BotInfo *source, const User *user, const Anope::string &chan, const Anope::string ¶m) anope_override + void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) anope_override { if (!param.empty()) UplinkSocket::Message(source) << "SVSJOIN " << user->GetUID() << " " << chan << " :" << param; @@ -302,7 +302,7 @@ class UnrealIRCdProto : public IRCDProto UplinkSocket::Message(source) << "SVSJOIN " << user->GetUID() << " " << chan; } - void SendSVSPart(const BotInfo *source, const User *user, const Anope::string &chan, const Anope::string ¶m) anope_override + void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) anope_override { if (!param.empty()) UplinkSocket::Message(source) << "SVSPART " << user->GetUID() << " " << chan << " :" << param; @@ -310,7 +310,7 @@ class UnrealIRCdProto : public IRCDProto UplinkSocket::Message(source) << "SVSPART " << user->GetUID() << " " << chan; } - void SendSWhois(const BotInfo *source, const Anope::string &who, const Anope::string &mask) anope_override + void SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) anope_override { UplinkSocket::Message(source) << "SWHOIS " << who << " :" << mask; } @@ -600,7 +600,7 @@ struct IRCDMessageCapab : Message::Capab ModeManager::AddChannelMode(new ChannelMode("INVITE", 'i')); continue; case 'r': - ModeManager::AddChannelMode(new ChannelModeRegistered('r')); + ModeManager::AddChannelMode(new ChannelModeNoone("REGISTERED", 'r')); continue; case 'R': ModeManager::AddChannelMode(new ChannelMode("REGISTEREDONLY", 'R')); @@ -609,10 +609,10 @@ struct IRCDMessageCapab : Message::Capab ModeManager::AddChannelMode(new ChannelMode("BLOCKCOLOR", 'c')); continue; case 'O': - ModeManager::AddChannelMode(new ChannelModeOper('O')); + ModeManager::AddChannelMode(new ChannelModeOperOnly("OPERONLY", 'O')); continue; case 'A': - ModeManager::AddChannelMode(new ChannelModeAdmin('A')); + ModeManager::AddChannelMode(new ChannelModeOperOnly("ADMINONLY", 'A')); continue; case 'Q': ModeManager::AddChannelMode(new ChannelMode("NOKICK", 'Q')); @@ -727,7 +727,7 @@ struct IRCDMessageMode : IRCDMessage { User *u = User::Find(params[0]); if (u) - u->SetModesInternal("%s", params[1].c_str()); + u->SetModesInternal(source, "%s", params[1].c_str()); } } }; @@ -1108,7 +1108,7 @@ struct IRCDMessageUmode2 : IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - source.GetUser()->SetModesInternal("%s", params[0].c_str()); + source.GetUser()->SetModesInternal(source, "%s", params[0].c_str()); } }; @@ -1166,32 +1166,32 @@ class ProtoUnreal : public Module ModeManager::AddChannelMode(new ChannelModeStatus("OWNER", 'q', '*', 4)); /* Add user modes */ - ModeManager::AddUserMode(new UserMode("SERV_ADMIN", 'A')); + ModeManager::AddUserMode(new UserModeOperOnly("SERV_ADMIN", 'A')); ModeManager::AddUserMode(new UserMode("BOT", 'B')); - ModeManager::AddUserMode(new UserMode("CO_ADMIN", 'C')); + ModeManager::AddUserMode(new UserModeOperOnly("CO_ADMIN", 'C')); ModeManager::AddUserMode(new UserMode("FILTER", 'G')); - ModeManager::AddUserMode(new UserMode("HIDEOPER", 'H')); + ModeManager::AddUserMode(new UserModeOperOnly("HIDEOPER", 'H')); ModeManager::AddUserMode(new UserMode("HIDEIDLE", 'I')); - ModeManager::AddUserMode(new UserMode("NETADMIN", 'N')); + ModeManager::AddUserMode(new UserModeOperOnly("NETADMIN", 'N')); ModeManager::AddUserMode(new UserMode("REGPRIV", 'R')); - ModeManager::AddUserMode(new UserMode("PROTECTED", 'S')); + ModeManager::AddUserMode(new UserModeOperOnly("PROTECTED", 'S')); ModeManager::AddUserMode(new UserMode("NOCTCP", 'T')); ModeManager::AddUserMode(new UserMode("WEBTV", 'V')); - ModeManager::AddUserMode(new UserMode("WHOIS", 'W')); - ModeManager::AddUserMode(new UserMode("ADMIN", 'a')); + ModeManager::AddUserMode(new UserModeOperOnly("WHOIS", 'W')); + ModeManager::AddUserMode(new UserModeOperOnly("ADMIN", 'a')); ModeManager::AddUserMode(new UserMode("DEAF", 'd')); - ModeManager::AddUserMode(new UserMode("GLOBOPS", 'g')); - ModeManager::AddUserMode(new UserMode("HELPOP", 'h')); + ModeManager::AddUserMode(new UserModeOperOnly("GLOBOPS", 'g')); + ModeManager::AddUserMode(new UserModeOperOnly("HELPOP", 'h')); ModeManager::AddUserMode(new UserMode("INVIS", 'i')); - ModeManager::AddUserMode(new UserMode("OPER", 'o')); + ModeManager::AddUserMode(new UserModeOperOnly("OPER", 'o')); ModeManager::AddUserMode(new UserMode("PRIV", 'p')); - ModeManager::AddUserMode(new UserMode("GOD", 'q')); - ModeManager::AddUserMode(new UserMode("REGISTERED", 'r')); - ModeManager::AddUserMode(new UserMode("SNOMASK", 's')); - ModeManager::AddUserMode(new UserMode("VHOST", 't')); + ModeManager::AddUserMode(new UserModeOperOnly("GOD", 'q')); + ModeManager::AddUserMode(new UserModeNoone("REGISTERED", 'r')); + ModeManager::AddUserMode(new UserModeOperOnly("SNOMASK", 's')); + ModeManager::AddUserMode(new UserModeNoone("VHOST", 't')); ModeManager::AddUserMode(new UserMode("WALLOPS", 'w')); ModeManager::AddUserMode(new UserMode("CLOAK", 'x')); - ModeManager::AddUserMode(new UserMode("SSL", 'z')); + ModeManager::AddUserMode(new UserModeNoone("SSL", 'z')); } public: @@ -1221,7 +1221,7 @@ class ProtoUnreal : public Module void OnUserNickChange(User *u, const Anope::string &) anope_override { - u->RemoveModeInternal(ModeManager::FindUserModeByName("REGISTERED")); + u->RemoveModeInternal(Me, ModeManager::FindUserModeByName("REGISTERED")); if (Servers::Capab.count("ESVID") == 0) IRCD->SendLogout(u); } diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp index dac89a2f7..aec5631d8 100644 --- a/modules/pseudoclients/botserv.cpp +++ b/modules/pseudoclients/botserv.cpp @@ -204,7 +204,7 @@ class BotServCore : public Module ci->Extend<bool>("BS_" + token.upper()); } - void OnUserKicked(MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) anope_override + void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) anope_override { BotInfo *bi = BotInfo::Find(target->nick); if (bi) diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index be2c074ec..7222c9b80 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -105,7 +105,7 @@ class ChanServCore : public Module, public ChanServService defaults.push_back("SIGNKICK"); } else if (defaults[0].equals_ci("none")) - defaults.erase(defaults.begin()); + defaults.clear(); } void OnBotDelete(BotInfo *bi) anope_override diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp index 1500ebb17..aeb7f0e62 100644 --- a/modules/pseudoclients/global.cpp +++ b/modules/pseudoclients/global.cpp @@ -15,7 +15,7 @@ class GlobalCore : public Module, public GlobalService { Reference<BotInfo> Global; - void ServerGlobal(const BotInfo *sender, Server *s, const Anope::string &message) + void ServerGlobal(BotInfo *sender, Server *s, const Anope::string &message) { if (s != Me && !s->IsJuped()) s->Notice(sender, message); @@ -29,7 +29,7 @@ class GlobalCore : public Module, public GlobalService { } - void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) anope_override + void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) anope_override { if (Me->GetLinks().empty()) return; diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index 4b9f016df..f5c94fa7d 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -407,7 +407,7 @@ class NickServCore : public Module, public NickServService OnCancel(u, old_na); } - void OnUserModeSet(User *u, const Anope::string &mname) anope_override + void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override { if (mname == "REGISTERED" && !u->IsIdentified()) u->RemoveMode(NickServ, mname); diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp index dc463e50b..1b21fc4eb 100644 --- a/modules/pseudoclients/operserv.cpp +++ b/modules/pseudoclients/operserv.cpp @@ -209,13 +209,13 @@ class OperServCore : public Module Log(server, "squit", OperServ) << "Received SQUIT for juped server " << server->GetName(); } - void OnUserModeSet(User *u, const Anope::string &mname) anope_override + void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override { if (mname == "OPER") Log(u, "oper", OperServ) << "is now an IRC operator."; } - void OnUserModeUnset(User *u, const Anope::string &mname) anope_override + void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) anope_override { if (mname == "OPER") Log(u, "oper", OperServ) << "is no longer an IRC operator"; diff --git a/modules/stats/m_chanstats.cpp b/modules/stats/m_chanstats.cpp index 810a0d5c2..d03d295ed 100644 --- a/modules/stats/m_chanstats.cpp +++ b/modules/stats/m_chanstats.cpp @@ -545,7 +545,7 @@ class MChanstats : public Module } public: - void OnPreUserKicked(MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) anope_override + void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) anope_override { if (!cu->chan->ci || !cs_stats.HasExt(cu->chan->ci)) return; diff --git a/src/bots.cpp b/src/bots.cpp index 315045b86..ddffe53fe 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -38,7 +38,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A { Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : (IRCD ? IRCD->DefaultPseudoclientModes : ""); if (!tmodes.empty()) - this->SetModesInternal(tmodes.c_str()); + this->SetModesInternal(this, tmodes.c_str()); XLine x(this->nick, "Reserved for services"); IRCD->SendSQLine(NULL, &x); diff --git a/src/channels.cpp b/src/channels.cpp index 58083df00..84e90792d 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -24,6 +24,7 @@ #include "access.h" #include "sockets.h" #include "language.h" +#include "uplink.h" channel_map ChannelList; @@ -681,7 +682,7 @@ bool Channel::MatchesList(User *u, const Anope::string &mode) return false; } -void Channel::KickInternal(MessageSource &source, const Anope::string &nick, const Anope::string &reason) +void Channel::KickInternal(const MessageSource &source, const Anope::string &nick, const Anope::string &reason) { User *sender = source.GetUser(); User *target = User::Find(nick); @@ -737,8 +738,7 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...) if (MOD_RESULT == EVENT_STOP) return false; IRCD->SendKick(bi, this, u, "%s", buf); - MessageSource ms(bi); - this->KickInternal(ms, u->nick, buf); + this->KickInternal(bi, u->nick, buf); return true; } diff --git a/src/logger.cpp b/src/logger.cpp index cd2dbd504..dca46f6d8 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -75,11 +75,11 @@ const Anope::string &LogFile::GetName() const return this->filename; } -Log::Log(LogType t, const Anope::string &cat, const BotInfo *b) : bi(b), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), type(t), category(cat) +Log::Log(LogType t, const Anope::string &cat, BotInfo *b) : bi(b), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), type(t), category(cat) { } -Log::Log(LogType t, CommandSource &src, Command *_c, const ChannelInfo *_ci) : u(src.GetUser()), nc(src.nc), c(_c), source(&src), chan(NULL), ci(_ci), s(NULL), m(NULL), type(t) +Log::Log(LogType t, CommandSource &src, Command *_c, ChannelInfo *_ci) : u(src.GetUser()), nc(src.nc), c(_c), source(&src), chan(NULL), ci(_ci), s(NULL), m(NULL), type(t) { if (!c) throw CoreException("Invalid pointers passed to Log::Log"); @@ -94,25 +94,25 @@ Log::Log(LogType t, CommandSource &src, Command *_c, const ChannelInfo *_ci) : u this->category = c->name; } -Log::Log(const User *_u, Channel *ch, const Anope::string &cat) : bi(NULL), u(_u), nc(NULL), c(NULL), source(NULL), chan(ch), ci(chan ? *chan->ci : NULL), s(NULL), m(NULL), type(LOG_CHANNEL), category(cat) +Log::Log(User *_u, Channel *ch, const Anope::string &cat) : bi(NULL), u(_u), nc(NULL), c(NULL), source(NULL), chan(ch), ci(chan ? *chan->ci : NULL), s(NULL), m(NULL), type(LOG_CHANNEL), category(cat) { if (!chan) throw CoreException("Invalid pointers passed to Log::Log"); } -Log::Log(const User *_u, const Anope::string &cat, const BotInfo *_bi) : bi(_bi), u(_u), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_USER), category(cat) +Log::Log(User *_u, const Anope::string &cat, BotInfo *_bi) : bi(_bi), u(_u), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_USER), category(cat) { if (!u) throw CoreException("Invalid pointers passed to Log::Log"); } -Log::Log(Server *serv, const Anope::string &cat, const BotInfo *_bi) : bi(_bi), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(serv), m(NULL), type(LOG_SERVER), category(cat) +Log::Log(Server *serv, const Anope::string &cat, BotInfo *_bi) : bi(_bi), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(serv), m(NULL), type(LOG_SERVER), category(cat) { if (!s) throw CoreException("Invalid pointer passed to Log::Log"); } -Log::Log(const BotInfo *b, const Anope::string &cat) : bi(b), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_NORMAL), category(cat) +Log::Log(BotInfo *b, const Anope::string &cat) : bi(b), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_NORMAL), category(cat) { } @@ -362,7 +362,7 @@ void LogInfo::ProcessMessage(const Log *l) if (!c) continue; - const BotInfo *bi = l->bi; + BotInfo *bi = l->bi; if (!bi) bi = this->bot; if (!bi) diff --git a/src/mail.cpp b/src/mail.cpp index d52089a7a..7b30b7403 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -51,7 +51,7 @@ void Mail::Message::Run() SetExitState(); } -bool Mail::Send(User *u, NickCore *nc, const BotInfo *service, const Anope::string &subject, const Anope::string &message) +bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &subject, const Anope::string &message) { if (!nc || !service || subject.empty() || message.empty()) return false; diff --git a/src/messages.cpp b/src/messages.cpp index a41cd6ba3..b5332f716 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -216,7 +216,7 @@ void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string> User *u = User::Find(params[0]); if (u) - u->SetModesInternal("%s", params[1].c_str()); + u->SetModesInternal(source, "%s", params[1].c_str()); } } @@ -318,7 +318,7 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m } else if (!IRCD->RequiresID && Config->UseStrictPrivmsg) { - const BotInfo *bi = BotInfo::Find(receiver); + BotInfo *bi = BotInfo::Find(receiver); if (!bi) return; Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << u->nick; diff --git a/src/modes.cpp b/src/modes.cpp index fc343c0d2..41c2ac663 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -13,6 +13,7 @@ #include "sockets.h" #include "protocol.h" #include "channels.h" +#include "uplink.h" struct StackerInfo; @@ -40,7 +41,7 @@ struct StackerInfo /* Modes to be deleted */ std::list<std::pair<Mode *, Anope::string> > DelModes; /* Bot this is sent from */ - const BotInfo *bi; + BotInfo *bi; StackerInfo() : bi(NULL) { } @@ -116,11 +117,12 @@ Mode::~Mode() { } -UserMode::UserMode(const Anope::string &un, char mch) : Mode(un, MC_USER, mch, MODE_REGULAR) +bool Mode::CanSet(User *u) const { + return true; } -UserMode::~UserMode() +UserMode::UserMode(const Anope::string &un, char mch) : Mode(un, MC_USER, mch, MODE_REGULAR) { } @@ -133,10 +135,6 @@ ChannelMode::ChannelMode(const Anope::string &cm, char mch) : Mode(cm, MC_CHANNE { } -ChannelMode::~ChannelMode() -{ -} - bool ChannelMode::CanSet(User *u) const { EventReturn MOD_RESULT; @@ -149,53 +147,40 @@ ChannelModeList::ChannelModeList(const Anope::string &cm, char mch) : ChannelMod this->type = MODE_LIST; } -ChannelModeList::~ChannelModeList() -{ -} - ChannelModeParam::ChannelModeParam(const Anope::string &cm, char mch, bool ma) : ChannelMode(cm, mch), minus_no_arg(ma) { this->type = MODE_PARAM; } -ChannelModeParam::~ChannelModeParam() -{ -} - ChannelModeStatus::ChannelModeStatus(const Anope::string &mname, char modeChar, char msymbol, short mlevel) : ChannelMode(mname, modeChar), symbol(msymbol), level(mlevel) { this->type = MODE_STATUS; } -ChannelModeStatus::~ChannelModeStatus() +bool UserModeOperOnly::CanSet(User *u) const { + return u && u->HasMode("OPER"); } -bool ChannelModeKey::IsValid(const Anope::string &value) const +bool UserModeNoone::CanSet(User *u) const { - if (!value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos) - return true; - return false; } -bool ChannelModeAdmin::CanSet(User *u) const +bool ChannelModeKey::IsValid(const Anope::string &value) const { - if (u && u->HasMode("OPER")) + if (!value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos) return true; return false; } -bool ChannelModeOper::CanSet(User *u) const +bool ChannelModeOperOnly::CanSet(User *u) const { - if (u && u->HasMode("OPER")) - return true; - - return false; + return u && u->HasMode("OPER"); } -bool ChannelModeRegistered::CanSet(User *u) const +bool ChannelModeNoone::CanSet(User *u) const { return false; } @@ -526,7 +511,7 @@ void ModeManager::RebuildStatusModes() std::sort(ChannelModesByStatus.begin(), ChannelModesByStatus.end(), statuscmp); } -void ModeManager::StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param) +void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param) { StackerInfo *s = GetInfo(ChannelStackerObjects, c); s->AddMode(cm, Set, Param); @@ -540,7 +525,7 @@ void ModeManager::StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, boo modePipe->Notify(); } -void ModeManager::StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param) +void ModeManager::StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param) { StackerInfo *s = GetInfo(UserStackerObjects, u); s->AddMode(um, Set, Param); diff --git a/src/protocol.cpp b/src/protocol.cpp index b5ee8da3f..9ece3b529 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -44,40 +44,40 @@ const Anope::string &IRCDProto::GetProtocolName() return this->proto_name; } -void IRCDProto::SendSVSKillInternal(const BotInfo *source, User *user, const Anope::string &buf) +void IRCDProto::SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) { UplinkSocket::Message(source) << "KILL " << user->GetUID() << " :" << buf; } -void IRCDProto::SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf) +void IRCDProto::SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) { - UplinkSocket::Message(bi) << "MODE " << dest->name << " " << buf; + UplinkSocket::Message(source) << "MODE " << dest->name << " " << buf; } -void IRCDProto::SendModeInternal(const BotInfo *bi, const User *dest, const Anope::string &buf) +void IRCDProto::SendModeInternal(const MessageSource &source, User *dest, const Anope::string &buf) { - UplinkSocket::Message(bi) << "MODE " << dest->GetUID() << " " << buf; + UplinkSocket::Message(source) << "MODE " << dest->GetUID() << " " << buf; } -void IRCDProto::SendKickInternal(const BotInfo *bi, const Channel *c, const User *u, const Anope::string &r) +void IRCDProto::SendKickInternal(const MessageSource &source, const Channel *c, User *u, const Anope::string &r) { if (!r.empty()) - UplinkSocket::Message(bi) << "KICK " << c->name << " " << u->GetUID() << " :" << r; + UplinkSocket::Message(source) << "KICK " << c->name << " " << u->GetUID() << " :" << r; else - UplinkSocket::Message(bi) << "KICK " << c->name << " " << u->GetUID(); + UplinkSocket::Message(source) << "KICK " << c->name << " " << u->GetUID(); } -void IRCDProto::SendNoticeInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &msg) +void IRCDProto::SendNoticeInternal(const MessageSource &source, const Anope::string &dest, const Anope::string &msg) { - UplinkSocket::Message(bi) << "NOTICE " << dest << " :" << msg; + UplinkSocket::Message(source) << "NOTICE " << dest << " :" << msg; } -void IRCDProto::SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf) +void IRCDProto::SendPrivmsgInternal(const MessageSource &source, const Anope::string &dest, const Anope::string &buf) { - UplinkSocket::Message(bi) << "PRIVMSG " << dest << " :" << buf; + UplinkSocket::Message(source) << "PRIVMSG " << dest << " :" << buf; } -void IRCDProto::SendQuitInternal(const User *u, const Anope::string &buf) +void IRCDProto::SendQuitInternal(User *u, const Anope::string &buf) { if (!buf.empty()) UplinkSocket::Message(u) << "QUIT :" << buf; @@ -85,26 +85,23 @@ void IRCDProto::SendQuitInternal(const User *u, const Anope::string &buf) UplinkSocket::Message(u) << "QUIT"; } -void IRCDProto::SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf) +void IRCDProto::SendPartInternal(User *u, const Channel *chan, const Anope::string &buf) { if (!buf.empty()) - UplinkSocket::Message(bi) << "PART " << chan->name << " :" << buf; + UplinkSocket::Message(u) << "PART " << chan->name << " :" << buf; else - UplinkSocket::Message(bi) << "PART " << chan->name; + UplinkSocket::Message(u) << "PART " << chan->name; } -void IRCDProto::SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) +void IRCDProto::SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) { - if (source) - UplinkSocket::Message(source) << "GLOBOPS :" << buf; - else - UplinkSocket::Message(Me) << "GLOBOPS :" << buf; + UplinkSocket::Message(source) << "GLOBOPS :" << buf; } -void IRCDProto::SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf) +void IRCDProto::SendCTCPInternal(const MessageSource &source, const Anope::string &dest, const Anope::string &buf) { Anope::string s = Anope::NormalizeBuffer(buf); - this->SendNoticeInternal(bi, dest, "\1" + s + "\1"); + this->SendNoticeInternal(source, dest, "\1" + s + "\1"); } void IRCDProto::SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) @@ -117,12 +114,12 @@ void IRCDProto::SendNumericInternal(int numeric, const Anope::string &dest, cons UplinkSocket::Message(Me) << n << " " << dest << " " << buf; } -void IRCDProto::SendTopic(BotInfo *bi, Channel *c) +void IRCDProto::SendTopic(const MessageSource &source, Channel *c) { - UplinkSocket::Message(bi) << "TOPIC " << c->name << " :" << c->topic; + UplinkSocket::Message(source) << "TOPIC " << c->name << " :" << c->topic; } -void IRCDProto::SendSVSKill(const BotInfo *source, User *user, const char *fmt, ...) +void IRCDProto::SendSVSKill(const MessageSource &source, User *user, const char *fmt, ...) { if (!user || !fmt) return; @@ -135,29 +132,29 @@ void IRCDProto::SendSVSKill(const BotInfo *source, User *user, const char *fmt, SendSVSKillInternal(source, user, buf); } -void IRCDProto::SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...) +void IRCDProto::SendMode(const MessageSource &source, const Channel *dest, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; va_start(args, fmt); vsnprintf(buf, BUFSIZE - 1, fmt, args); va_end(args); - SendModeInternal(bi, dest, buf); + SendModeInternal(source, dest, buf); } -void IRCDProto::SendMode(const BotInfo *bi, const User *u, const char *fmt, ...) +void IRCDProto::SendMode(const MessageSource &source, User *u, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; va_start(args, fmt); vsnprintf(buf, BUFSIZE - 1, fmt, args); va_end(args); - SendModeInternal(bi, u, buf); + SendModeInternal(source, u, buf); } -void IRCDProto::SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...) +void IRCDProto::SendKick(const MessageSource &source, const Channel *chan, User *user, const char *fmt, ...) { - if (!bi || !chan || !user) + if (!chan || !user) return; va_list args; @@ -165,20 +162,20 @@ void IRCDProto::SendKick(const BotInfo *bi, const Channel *chan, const User *use va_start(args, fmt); vsnprintf(buf, BUFSIZE - 1, fmt, args); va_end(args); - SendKickInternal(bi, chan, user, buf); + SendKickInternal(source, chan, user, buf); } -void IRCDProto::SendNotice(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...) +void IRCDProto::SendNotice(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; va_start(args, fmt); vsnprintf(buf, BUFSIZE - 1, fmt, args); va_end(args); - SendNoticeInternal(bi, dest, buf); + SendNoticeInternal(source, dest, buf); } -void IRCDProto::SendAction(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...) +void IRCDProto::SendAction(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; @@ -186,20 +183,20 @@ void IRCDProto::SendAction(const BotInfo *bi, const Anope::string &dest, const c vsnprintf(buf, BUFSIZE - 1, fmt, args); va_end(args); Anope::string actionbuf = Anope::string("\1ACTION ") + buf + '\1'; - SendPrivmsgInternal(bi, dest, actionbuf); + SendPrivmsgInternal(source, dest, actionbuf); } -void IRCDProto::SendPrivmsg(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...) +void IRCDProto::SendPrivmsg(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; va_start(args, fmt); vsnprintf(buf, BUFSIZE - 1, fmt, args); va_end(args); - SendPrivmsgInternal(bi, dest, buf); + SendPrivmsgInternal(source, dest, buf); } -void IRCDProto::SendQuit(const User *u, const char *fmt, ...) +void IRCDProto::SendQuit(User *u, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; @@ -231,12 +228,12 @@ void IRCDProto::SendPong(const Anope::string &servname, const Anope::string &who UplinkSocket::Message(Me) << "PONG " << servname << " " << who; } -void IRCDProto::SendInvite(const BotInfo *bi, const Channel *c, const User *u) +void IRCDProto::SendInvite(const MessageSource &source, const Channel *c, User *u) { - UplinkSocket::Message(bi) << "INVITE " << u->GetUID() << " " << c->name; + UplinkSocket::Message(source) << "INVITE " << u->GetUID() << " " << c->name; } -void IRCDProto::SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...) +void IRCDProto::SendPart(User *user, const Channel *chan, const char *fmt, ...) { if (fmt) { @@ -245,13 +242,13 @@ void IRCDProto::SendPart(const BotInfo *bi, const Channel *chan, const char *fmt va_start(args, fmt); vsnprintf(buf, BUFSIZE - 1, fmt, args); va_end(args); - SendPartInternal(bi, chan, buf); + SendPartInternal(user, chan, buf); } else - SendPartInternal(bi, chan, ""); + SendPartInternal(user, chan, ""); } -void IRCDProto::SendGlobops(const BotInfo *source, const char *fmt, ...) +void IRCDProto::SendGlobops(const MessageSource &source, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; @@ -266,24 +263,24 @@ void IRCDProto::SendSquit(Server *s, const Anope::string &message) UplinkSocket::Message() << "SQUIT " << s->GetSID() << " :" << message; } -void IRCDProto::SendNickChange(const User *u, const Anope::string &newnick) +void IRCDProto::SendNickChange(User *u, const Anope::string &newnick) { UplinkSocket::Message(u) << "NICK " << newnick << " " << Anope::CurTime; } -void IRCDProto::SendForceNickChange(const User *u, const Anope::string &newnick, time_t when) +void IRCDProto::SendForceNickChange(User *u, const Anope::string &newnick, time_t when) { UplinkSocket::Message() << "SVSNICK " << u->nick << " " << newnick << " " << when; } -void IRCDProto::SendCTCP(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...) +void IRCDProto::SendCTCP(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; va_start(args, fmt); vsnprintf(buf, BUFSIZE - 1, fmt, args); va_end(args); - SendCTCPInternal(bi, dest, buf); + SendCTCPInternal(source, dest, buf); } void IRCDProto::SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...) @@ -382,6 +379,7 @@ unsigned IRCDProto::GetMaxListFor(Channel *c) MessageSource::MessageSource(const Anope::string &src) : source(src), u(NULL), s(NULL) { + /* no source for incoming message is our uplink */ if (src.empty()) this->s = Servers::GetUplink(); else if (IRCD->RequiresID || src.find('.') != Anope::string::npos) @@ -398,7 +396,7 @@ MessageSource::MessageSource(Server *_s) : source(_s ? _s->GetName() : ""), u(NU { } -const Anope::string MessageSource::GetName() +const Anope::string &MessageSource::GetName() const { if (this->s) return this->s->GetName(); @@ -408,17 +406,22 @@ const Anope::string MessageSource::GetName() return this->source; } -const Anope::string &MessageSource::GetSource() +const Anope::string &MessageSource::GetSource() const { return this->source; } -User *MessageSource::GetUser() +User *MessageSource::GetUser() const { return this->u; } -Server *MessageSource::GetServer() +BotInfo *MessageSource::GetBot() const +{ + return BotInfo::Find(this->GetName(), true); +} + +Server *MessageSource::GetServer() const { return this->s; } diff --git a/src/servers.cpp b/src/servers.cpp index 77431eeab..c3ec328f9 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -53,7 +53,7 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano BotInfo *bi = it->second; Anope::string modes = !bi->botmodes.empty() ? ("+" + bi->botmodes) : IRCD->DefaultPseudoclientModes; - bi->SetModesInternal(modes.c_str()); + bi->SetModesInternal(bi, modes.c_str()); for (unsigned i = 0; i < bi->botchannels.size(); ++i) { size_t h = bi->botchannels[i].find('#'); @@ -297,7 +297,7 @@ bool Server::IsJuped() const return juped; } -void Server::Notice(const BotInfo *source, const Anope::string &message) +void Server::Notice(BotInfo *source, const Anope::string &message) { if (Config->UsePrivmsg && Config->DefPrivmsg) IRCD->SendGlobalPrivmsg(source, this, message); diff --git a/src/uplink.cpp b/src/uplink.cpp index d29af3bea..b5439dda1 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -58,7 +58,6 @@ void Uplink::Connect() UplinkSock->Connect(ip, u.port); } - UplinkSocket::UplinkSocket() : Socket(-1, Config->Uplinks[Anope::CurrentUplink].ipv6), ConnectionSocket(), BufferedSocket() { UplinkSock = this; @@ -142,50 +141,48 @@ void UplinkSocket::OnError(const Anope::string &error) Log(LOG_TERMINAL) << "Unable to connect to uplink #" << (Anope::CurrentUplink + 1) << " (" << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port << ")" << (!error.empty() ? (": " + error) : ""); } -UplinkSocket::Message::Message() : server(NULL), user(NULL) -{ -} - -UplinkSocket::Message::Message(const Server *s) : server(s), user(NULL) +UplinkSocket::Message::Message() : source(Me) { } -UplinkSocket::Message::Message(const User *u) : server(NULL), user(u) +UplinkSocket::Message::Message(const MessageSource &src) : source(src) { - if (!u) - server = Me; } UplinkSocket::Message::~Message() { - Anope::string message_source = ""; + Anope::string message_source; - if (this->server != NULL) + if (this->source.GetServer() != NULL) { - if (this->server != Me && !this->server->IsJuped()) + const Server *s = this->source.GetServer(); + + if (s != Me && !s->IsJuped()) { - Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << this->server->GetName() << " who is not from me?"; + Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << s->GetName() << " who is not from me?"; return; } - message_source = this->server->GetSID(); + message_source = s->GetSID(); } - else if (this->user != NULL) + else if (this->source.GetUser() != NULL) { - if (this->user->server != Me && !this->user->server->IsJuped()) + const User *u = this->source.GetUser(); + + if (u->server != Me && !u->server->IsJuped()) { - Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << this->user->nick << " who is not from me?"; + Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << u->nick << " who is not from me?"; return; } - const BotInfo *bi = BotInfo::Find(this->user->nick); + const BotInfo *bi = this->source.GetBot(); if (bi != NULL && bi->introduced == false) { Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << bi->nick << " when not introduced"; return; } - message_source = this->user->GetUID(); + message_source = u->GetUID(); } if (!UplinkSock) diff --git a/src/users.cpp b/src/users.cpp index c614a02ca..f44a6f62d 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -23,6 +23,7 @@ #include "opertype.h" #include "language.h" #include "sockets.h" +#include "uplink.h" user_map UserListByNick, UserListByUID; @@ -52,7 +53,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope: this->server = sserver; this->realname = srealname; this->timestamp = this->signon = ssignon; - this->SetModesInternal("%s", smodes.c_str()); + this->SetModesInternal(sserver, "%s", smodes.c_str()); this->uid = suid; this->super_admin = false; this->nc = NULL; @@ -255,7 +256,7 @@ User::~User() FOREACH_MOD(OnPostUserLogoff, (this)); } -void User::SendMessage(const BotInfo *source, const char *fmt, ...) +void User::SendMessage(BotInfo *source, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; @@ -270,7 +271,7 @@ void User::SendMessage(const BotInfo *source, const char *fmt, ...) va_end(args); } -void User::SendMessage(const BotInfo *source, const Anope::string &msg) +void User::SendMessage(BotInfo *source, const Anope::string &msg) { const char *translated_message = Language::Translate(this, msg.c_str()); @@ -453,55 +454,55 @@ bool User::HasMode(const Anope::string &mname) const return this->modes.count(mname); } -void User::SetModeInternal(UserMode *um, const Anope::string ¶m) +void User::SetModeInternal(const MessageSource &source, UserMode *um, const Anope::string ¶m) { if (!um) return; this->modes[um->name] = param; - FOREACH_MOD(OnUserModeSet, (this, um->name)); + FOREACH_MOD(OnUserModeSet, (source, this, um->name)); } -void User::RemoveModeInternal(UserMode *um) +void User::RemoveModeInternal(const MessageSource &source, UserMode *um) { if (!um) return; this->modes.erase(um->name); - FOREACH_MOD(OnUserModeUnset, (this, um->name)); + FOREACH_MOD(OnUserModeUnset, (source, this, um->name)); } -void User::SetMode(const BotInfo *bi, UserMode *um, const Anope::string &Param) +void User::SetMode(BotInfo *bi, UserMode *um, const Anope::string ¶m) { if (!um || HasMode(um->name)) return; - ModeManager::StackerAdd(bi, this, um, true, Param); - SetModeInternal(um, Param); + ModeManager::StackerAdd(bi, this, um, true, param); + SetModeInternal(bi, um, param); } -void User::SetMode(const BotInfo *bi, const Anope::string &uname, const Anope::string &Param) +void User::SetMode(BotInfo *bi, const Anope::string &uname, const Anope::string ¶m) { - SetMode(bi, ModeManager::FindUserModeByName(uname), Param); + SetMode(bi, ModeManager::FindUserModeByName(uname), param); } -void User::RemoveMode(const BotInfo *bi, UserMode *um) +void User::RemoveMode(BotInfo *bi, UserMode *um) { if (!um || !HasMode(um->name)) return; ModeManager::StackerAdd(bi, this, um, false); - RemoveModeInternal(um); + RemoveModeInternal(bi, um); } -void User::RemoveMode(const BotInfo *bi, const Anope::string &name) +void User::RemoveMode(BotInfo *bi, const Anope::string &name) { RemoveMode(bi, ModeManager::FindUserModeByName(name)); } -void User::SetModes(const BotInfo *bi, const char *umodes, ...) +void User::SetModes(BotInfo *bi, const char *umodes, ...) { char buf[BUFSIZE] = ""; va_list args; @@ -545,7 +546,7 @@ void User::SetModes(const BotInfo *bi, const char *umodes, ...) } } -void User::SetModesInternal(const char *umodes, ...) +void User::SetModesInternal(const MessageSource &source, const char *umodes, ...) { char buf[BUFSIZE] = ""; va_list args; @@ -583,12 +584,12 @@ void User::SetModesInternal(const char *umodes, ...) if (add) { if (um->type == MODE_PARAM && sep.GetToken(sbuf)) - this->SetModeInternal(um, sbuf); + this->SetModeInternal(source, um, sbuf); else - this->SetModeInternal(um); + this->SetModeInternal(source, um); } else - this->RemoveModeInternal(um); + this->RemoveModeInternal(source, um); if (um->name == "OPER") { @@ -610,8 +611,7 @@ Anope::string User::GetModes() const { Anope::string m, params; - typedef std::map<Anope::string, Anope::string> mode_map; - for (mode_map::const_iterator it = this->modes.begin(), it_end = this->modes.end(); it != it_end; ++it) + for (ModeList::const_iterator it = this->modes.begin(), it_end = this->modes.end(); it != it_end; ++it) { UserMode *um = ModeManager::FindUserModeByName(it->first); if (um == NULL) @@ -626,6 +626,11 @@ Anope::string User::GetModes() const return m + params; } +const User::ModeList &User::GetModeList() const +{ + return modes; +} + ChanUserContainer *User::FindChannel(Channel *c) const { User::ChanUserList::const_iterator it = this->chans.find(c); @@ -642,14 +647,14 @@ bool User::IsProtected() const return false; } -void User::Kill(const Anope::string &source, const Anope::string &reason) +void User::Kill(const MessageSource &source, const Anope::string &reason) { - Anope::string real_reason = (source.empty() ? Me->GetName() : source) + " (" + reason + ")"; + Anope::string real_reason = source.GetName() + " (" + reason + ")"; - IRCD->SendSVSKill(BotInfo::Find(source), this, "%s", real_reason.c_str()); + IRCD->SendSVSKill(source, this, "%s", real_reason.c_str()); } -void User::KillInternal(const Anope::string &source, const Anope::string &reason) +void User::KillInternal(const MessageSource &source, const Anope::string &reason) { if (this->quit) { @@ -657,7 +662,7 @@ void User::KillInternal(const Anope::string &source, const Anope::string &reason return; } - Log(this, "killed") << "was killed by " << source << " (Reason: " << reason << ")"; + Log(this, "killed") << "was killed by " << source.GetName() << " (Reason: " << reason << ")"; this->Quit(reason); } |