00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef CHANNELS_H
00011 #define CHANNELS_H
00012
00013 #include "anope.h"
00014 #include "extensible.h"
00015 #include "modes.h"
00016 #include "serialize.h"
00017
00018 typedef Anope::hash_map<Channel *> channel_map;
00019
00020 extern CoreExport channel_map ChannelList;
00021
00022
00023 struct ChanUserContainer : public Extensible
00024 {
00025 User *user;
00026 Channel *chan;
00027
00028 ChannelStatus status;
00029
00030 ChanUserContainer(User *u, Channel *c) : user(u), chan(c) { }
00031 };
00032
00033 enum ChannelFlag
00034 {
00035
00036 CH_INHABIT,
00037
00038 CH_PERSIST,
00039
00040 CH_SYNCING
00041 };
00042
00043 class CoreExport Channel : public Base, public Extensible
00044 {
00045 public:
00046 typedef std::multimap<Anope::string, Anope::string> ModeList;
00047 private:
00050 ModeList modes;
00051
00052 public:
00053
00054 Anope::string name;
00055
00056 Serialize::Reference<ChannelInfo> ci;
00057
00058 time_t creation_time;
00059 std::set<ChannelFlag> flags;
00060
00061
00062 typedef std::list<ChanUserContainer *> ChanUserList;
00063 ChanUserList users;
00064
00065
00066 Anope::string topic;
00067
00068 Anope::string topic_setter;
00069
00070
00071
00072
00073 time_t topic_ts;
00074
00075 time_t topic_time;
00076
00077 time_t server_modetime;
00078 time_t chanserv_modetime;
00079 int16_t server_modecount;
00080 int16_t chanserv_modecount;
00081 int16_t bouncy_modes;
00082
00087 Channel(const Anope::string &nname, time_t ts = Anope::CurTime);
00088
00091 ~Channel();
00092
00096 void Reset();
00097
00100 void Sync();
00101
00104 void CheckModes();
00105
00110 ChanUserContainer* JoinUser(User *u);
00111
00115 void DeleteUser(User *u);
00116
00121 ChanUserContainer *FindUser(const User *u) const;
00122
00128 bool HasUserStatus(const User *u, ChannelModeStatus *cms) const;
00129
00136 bool HasUserStatus(const User *u, const Anope::string &name) const;
00137
00143 size_t HasMode(const Anope::string &name, const Anope::string ¶m = "");
00144
00151 void SetModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true);
00152
00159 void RemoveModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true);
00160
00167 void SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true);
00168
00176 void SetMode(BotInfo *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true);
00177
00184 void RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true);
00185
00193 void RemoveMode(BotInfo *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true);
00194
00200 bool GetParam(const Anope::string &name, Anope::string &target) const;
00201
00207 void SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...);
00208
00214 void SetModesInternal(MessageSource &source, const Anope::string &mode, time_t ts = 0, bool enforce_mlock = true);
00215
00221 bool MatchesList(User *u, const Anope::string &list);
00222
00228 void KickInternal(MessageSource &source, const Anope::string &nick, const Anope::string &reason);
00229
00236 bool Kick(BotInfo *bi, User *u, const char *reason = NULL, ...);
00237
00241 const ModeList &GetModes() const;
00242
00247 std::pair<ModeList::iterator, ModeList::iterator> GetModeList(const Anope::string &name);
00248
00254 Anope::string GetModes(bool complete, bool plus);
00255
00261 void ChangeTopicInternal(const Anope::string &user, const Anope::string &newtopic, time_t ts = Anope::CurTime);
00262
00268 void ChangeTopic(const Anope::string &user, const Anope::string &newtopic, time_t ts = Anope::CurTime);
00269
00272 void Hold();
00273
00280 void SetCorrectModes(User *u, bool give_mode, bool check_noop);
00281
00287 bool Unban(const User *u, bool full = false);
00288
00293 static Channel* Find(const Anope::string &name);
00294 };
00295
00296 #endif // CHANNELS_H