diff options
Diffstat (limited to 'include/channels.h')
-rw-r--r-- | include/channels.h | 76 |
1 files changed, 49 insertions, 27 deletions
diff --git a/include/channels.h b/include/channels.h index ec12e4ab8..49daf6f7e 100644 --- a/include/channels.h +++ b/include/channels.h @@ -1,20 +1,30 @@ -/* Channel support +/* + * Anope IRC Services * - * (C) 2008-2016 Anope Team - * Contact us at team@anope.org + * Copyright (C) 2010-2016 Anope Team <team@anope.org> * - * Please read COPYING and README for further details. + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ -#ifndef CHANNELS_H -#define CHANNELS_H +#pragma once #include "anope.h" #include "extensible.h" #include "modes.h" #include "serialize.h" -typedef Anope::hash_map<Channel *> channel_map; +using channel_map = Anope::locale_hash_map<Channel *>; extern CoreExport channel_map ChannelList; @@ -44,13 +54,13 @@ class CoreExport Channel : public Base, public Extensible /* Channel name */ Anope::string name; /* Set if this channel is registered. ci->c == this. Contains information relevant to the registered channel */ - Serialize::Reference<ChannelInfo> ci; + Serialize::Reference<ChanServ::Channel> ci; /* When the channel was created */ time_t creation_time; /* If the channel has just been created in a netjoin */ - bool syncing; + bool syncing = false; /* Is configured in the conf as a channel bots should be in */ - bool botchannel; + bool botchannel = false; /* Users in the channel */ typedef std::map<User *, ChanUserContainer *> ChanUserList; @@ -64,15 +74,17 @@ class CoreExport Channel : public Base, public Extensible * This is the time the topic was *originally set*. When we restore the topic we want to change the TS back * to this, but we can only do this on certain IRCds. */ - time_t topic_ts; + time_t topic_ts = 0; /* The actual time the topic was set, probably close to Anope::CurTime */ - time_t topic_time; + time_t topic_time = 0; + + time_t server_modetime = 0; /* Time of last server MODE */ + time_t chanserv_modetime = 0; /* Time of last check_modes() */ + int16_t server_modecount = 0; /* Number of server MODEs this second */ + int16_t chanserv_modecount = 0; /* Number of check_mode()'s this sec */ + int16_t bouncy_modes = 0; /* Did we fail to set modes here? */ - time_t server_modetime; /* Time of last server MODE */ - time_t chanserv_modetime; /* Time of last check_modes() */ - int16_t server_modecount; /* Number of server MODEs this second */ - int16_t chanserv_modecount; /* Number of check_mode()'s this sec */ - int16_t bouncy_modes; /* Did we fail to set modes here? */ + Logger logger; private: /** Constructor @@ -86,6 +98,11 @@ class CoreExport Channel : public Base, public Extensible */ ~Channel(); + /** Gets the channels name + * @return the channel name + */ + const Anope::string &GetName() const; + /** Call if we need to unset all modes and clear all user status (internally). * Only useful if we get a SJOIN with a TS older than what we have here */ @@ -149,7 +166,7 @@ class CoreExport Channel : public Base, public Extensible * @param param The param * @param enforce_mlock true if mlocks should be enforced, false to override mlock */ - void SetModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); + void SetModeInternal(const MessageSource &source, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); /** Remove a mode internally on a channel, this is not sent out to the IRCd * @param setter The Setter @@ -157,7 +174,7 @@ class CoreExport Channel : public Base, public Extensible * @param param The param * @param enforce_mlock true if mlocks should be enforced, false to override mlock */ - void RemoveModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); + void RemoveModeInternal(const MessageSource &source, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); /** Set a mode on a channel * @param bi The client setting the modes @@ -165,7 +182,7 @@ class CoreExport Channel : public Base, public Extensible * @param param Optional param arg for the mode * @param enforce_mlock true if mlocks should be enforced, false to override mlock */ - void SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); + void SetMode(User *bi, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); /** * Set a mode on a channel @@ -174,7 +191,7 @@ class CoreExport Channel : public Base, public Extensible * @param param Optional param arg for the mode * @param enforce_mlock true if mlocks should be enforced, false to override mlock */ - void SetMode(BotInfo *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true); + void SetMode(User *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true); /** Remove a mode from a channel * @param bi The client setting the modes @@ -182,7 +199,7 @@ class CoreExport Channel : public Base, public Extensible * @param param Optional param arg for the mode * @param enforce_mlock true if mlocks should be enforced, false to override mlock */ - void RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); + void RemoveMode(User *bi, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); /** * Remove a mode from a channel @@ -191,7 +208,7 @@ class CoreExport Channel : public Base, public Extensible * @param param Optional param arg for the mode * @param enforce_mlock true if mlocks should be enforced, false to override mlock */ - void RemoveMode(BotInfo *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true); + void RemoveMode(User *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true); /** Get a modes parameter for the channel * @param name The mode @@ -205,7 +222,7 @@ class CoreExport Channel : public Base, public Extensible * @param enforce_mlock Should mlock be enforced on this mode change * @param cmodes The modes to set */ - void SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...); + void SetModes(User *bi, bool enforce_mlock, const char *cmodes, ...); /** Set a string of modes internally on a channel * @param source The setter @@ -225,8 +242,9 @@ class CoreExport Channel : public Base, public Extensible * @param source The sender of the kick * @param nick The nick being kicked * @param reason The reason for the kick + * @return true if the kick was scucessful, false if a module blocked the kick or was otherwise unsuccessful */ - void KickInternal(const MessageSource &source, const Anope::string &nick, const Anope::string &reason); + bool 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 @@ -234,7 +252,12 @@ class CoreExport Channel : public Base, public Extensible * @param reason The reason for the kick * @return true if the kick was scucessful, false if a module blocked the kick */ - bool Kick(BotInfo *bi, User *u, const char *reason = NULL, ...); + bool Kick(User *bi, User *u, const Anope::string &reason); + + template<typename... Args> bool Kick(User *bi, User *u, const Anope::string &reason, Args&&... args) + { + return Kick(bi, u, Anope::Format(reason, std::forward<Args>(args)...)); + } /** Get all modes set on this channel, excluding status modes. * @return a map of modes and their optional parameters. @@ -307,4 +330,3 @@ class CoreExport Channel : public Base, public Extensible static void DeleteChannels(); }; -#endif // CHANNELS_H |