00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef REGCHANNEL_H
00011 #define REGCHANNEL_H
00012
00013 #include "memo.h"
00014 #include "modes.h"
00015 #include "extensible.h"
00016 #include "logger.h"
00017 #include "modules.h"
00018 #include "serialize.h"
00019 #include "bots.h"
00020
00021 typedef Anope::hash_map<ChannelInfo *> registered_channel_map;
00022
00023 extern CoreExport Serialize::Checker<registered_channel_map> RegisteredChannelList;
00024
00025
00026 enum
00027 {
00028 TTB_BOLDS,
00029 TTB_COLORS,
00030 TTB_REVERSES,
00031 TTB_UNDERLINES,
00032 TTB_BADWORDS,
00033 TTB_CAPS,
00034 TTB_FLOOD,
00035 TTB_REPEAT,
00036 TTB_ITALICS,
00037 TTB_AMSGS,
00038 TTB_SIZE
00039 };
00040
00043 enum BadWordType
00044 {
00045
00046 BW_ANY,
00047
00048 BW_SINGLE,
00049
00050 BW_START,
00051
00052 BW_END
00053 };
00054
00055
00056 struct CoreExport BadWord : Serializable
00057 {
00058 Serialize::Reference<ChannelInfo> ci;
00059 Anope::string word;
00060 BadWordType type;
00061
00062 BadWord();
00063 ~BadWord();
00064 void Serialize(Serialize::Data &data) const anope_override;
00065 static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
00066 };
00067
00068
00069 class CoreExport AutoKick : public Serializable
00070 {
00071 public:
00072
00073 Serialize::Reference<ChannelInfo> ci;
00074
00075 Anope::string mask;
00076 Serialize::Reference<NickCore> nc;
00077
00078 Anope::string reason;
00079 Anope::string creator;
00080 time_t addtime;
00081 time_t last_used;
00082
00083 AutoKick();
00084 ~AutoKick();
00085 void Serialize(Serialize::Data &data) const anope_override;
00086 static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
00087 };
00088
00089 struct CoreExport ModeLock : Serializable
00090 {
00091 public:
00092 Serialize::Reference<ChannelInfo> ci;
00093 bool set;
00094 Anope::string name;
00095 Anope::string param;
00096 Anope::string setter;
00097 time_t created;
00098
00099 ModeLock(ChannelInfo *ch, bool s, const Anope::string &n, const Anope::string &p, const Anope::string &se = "", time_t c = Anope::CurTime);
00100 ~ModeLock();
00101
00102 void Serialize(Serialize::Data &data) const anope_override;
00103 static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
00104 };
00105
00106 struct CoreExport LogSetting : Serializable
00107 {
00108 Serialize::Reference<ChannelInfo> ci;
00109
00110 Anope::string service_name;
00111
00112 Anope::string command_service;
00113
00114 Anope::string command_name;
00115 Anope::string method, extra;
00116 Anope::string creator;
00117 time_t created;
00118
00119 LogSetting() : Serializable("LogSetting") { }
00120 void Serialize(Serialize::Data &data) const anope_override;
00121 static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
00122 };
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 class CoreExport ChannelInfo : public Serializable, public Extensible
00159 {
00160 private:
00161 Serialize::Reference<NickCore> founder;
00162 Serialize::Reference<NickCore> successor;
00163 Serialize::Checker<std::vector<ChanAccess *> > access;
00164 Serialize::Checker<std::vector<AutoKick *> > akick;
00165 Serialize::Checker<std::vector<BadWord *> > badwords;
00166 std::map<Anope::string, int16_t> levels;
00167
00168 public:
00169 friend class ChanAccess;
00170 friend class AutoKick;
00171 friend struct BadWord;
00172
00173 typedef std::multimap<Anope::string, ModeLock *> ModeList;
00174 Serialize::Checker<ModeList> mode_locks;
00175 Serialize::Checker<std::vector<LogSetting *> > log_settings;
00176
00177 Anope::string name;
00178 Anope::string desc;
00179
00180 time_t time_registered;
00181 time_t last_used;
00182
00183 Anope::string last_topic;
00184 Anope::string last_topic_setter;
00185 time_t last_topic_time;
00186
00187 int16_t bantype;
00188
00189 MemoInfo memos;
00190
00191 Channel *c;
00192
00193
00194 Serialize::Reference<BotInfo> bi;
00195 int16_t ttb[TTB_SIZE];
00196
00197 int16_t capsmin, capspercent;
00198 int16_t floodlines, floodsecs;
00199 int16_t repeattimes;
00200
00204 ChannelInfo(const Anope::string &chname);
00205
00209 ChannelInfo(const ChannelInfo &ci);
00210
00211 ~ChannelInfo();
00212
00213 void Serialize(Serialize::Data &data) const anope_override;
00214 static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
00215
00219 void SetFounder(NickCore *nc);
00220
00224 NickCore *GetFounder() const;
00225
00226 void SetSuccessor(NickCore *nc);
00227 NickCore *GetSuccessor() const;
00228
00232 BotInfo *WhoSends() const;
00233
00237 void AddAccess(ChanAccess *access);
00238
00246 ChanAccess *GetAccess(unsigned index) const;
00247
00251 AccessGroup AccessFor(const User *u);
00252 AccessGroup AccessFor(const NickCore *nc);
00253
00257 unsigned GetAccessCount() const;
00258
00265 void EraseAccess(unsigned index);
00266
00271 void ClearAccess();
00272
00280 AutoKick* AddAkick(const Anope::string &user, NickCore *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
00281
00289 AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
00290
00295 AutoKick* GetAkick(unsigned index) const;
00296
00300 unsigned GetAkickCount() const;
00301
00305 void EraseAkick(unsigned index);
00306
00309 void ClearAkick();
00310
00316 BadWord* AddBadWord(const Anope::string &word, BadWordType type);
00317
00322 BadWord* GetBadWord(unsigned index) const;
00323
00327 unsigned GetBadWordCount() const;
00328
00332 void EraseBadWord(unsigned index);
00333
00336 void ClearBadWords();
00337
00344 bool HasMLock(ChannelMode *mode, const Anope::string ¶m, bool status) const;
00345
00354 bool SetMLock(ChannelMode *mode, bool status, const Anope::string ¶m = "", Anope::string setter = "", time_t created = Anope::CurTime);
00355
00362 bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string ¶m = "");
00363
00364 void RemoveMLock(ModeLock *mlock);
00365
00368 void ClearMLock();
00369
00373 const ModeList &GetMLock() const;
00374
00379 std::pair<ModeList::iterator, ModeList::iterator> GetModeList(const Anope::string &name);
00380
00386 const ModeLock *GetMLock(const Anope::string &mname, const Anope::string ¶m = "");
00387
00392 Anope::string GetMLockAsString(bool complete) const;
00393
00398 bool CheckKick(User *user);
00399
00404 void CheckTopic();
00405
00409 void RestoreTopic();
00410
00416 int16_t GetLevel(const Anope::string &priv) const;
00417
00422 void SetLevel(const Anope::string &priv, int16_t level);
00423
00427 void RemoveLevel(const Anope::string &priv);
00428
00431 void ClearLevels();
00432
00438 Anope::string GetIdealBan(User *u) const;
00439
00444 static ChannelInfo* Find(const Anope::string &name);
00445 };
00446
00452 extern CoreExport bool IsFounder(const User *user, const ChannelInfo *ci);
00453
00454 #endif // REGCHANNEL_H