forked from anope/anope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregchannel.h
252 lines (202 loc) · 7.2 KB
/
regchannel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*
*
* (C) 2008-2024 Anope Team
* Contact us at [email protected]
*
* Please read COPYING and README for further details.
*/
#ifndef REGCHANNEL_H
#define REGCHANNEL_H
#include "memo.h"
#include "modes.h"
#include "extensible.h"
#include "logger.h"
#include "modules.h"
#include "serialize.h"
#include "bots.h"
typedef Anope::hash_map<ChannelInfo *> registered_channel_map;
extern CoreExport Serialize::Checker<registered_channel_map> RegisteredChannelList;
/* AutoKick data. */
class CoreExport AutoKick : public Serializable
{
public:
/* Channel this autokick is on */
Serialize::Reference<ChannelInfo> ci;
Anope::string mask;
Serialize::Reference<NickCore> nc;
Anope::string reason;
Anope::string creator;
time_t addtime;
time_t last_used;
AutoKick();
~AutoKick();
void Serialize(Serialize::Data &data) const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
};
/* It matters that Base is here before Extensible (it is inherited by Serializable)
*/
class CoreExport ChannelInfo : public Serializable, public Extensible
{
/* channels who reference this one */
Anope::map<int> references;
private:
Serialize::Reference<NickCore> founder; /* Channel founder */
Serialize::Reference<NickCore> successor; /* Who gets the channel if the founder nick is dropped or expires */
Serialize::Checker<std::vector<ChanAccess *> > access; /* List of authorized users */
Serialize::Checker<std::vector<AutoKick *> > akick; /* List of users to kickban */
Anope::map<int16_t> levels;
public:
friend class ChanAccess;
friend class AutoKick;
Anope::string name; /* Channel name */
Anope::string desc;
time_t time_registered;
time_t last_used;
Anope::string last_topic; /* The last topic that was set on this channel */
Anope::string last_topic_setter; /* Setter */
time_t last_topic_time; /* Time */
Channel::ModeList last_modes; /* The last modes set on this channel */
int16_t bantype;
MemoInfo memos;
Channel *c; /* Pointer to channel, if the channel exists */
/* For BotServ */
Serialize::Reference<BotInfo> bi; /* Bot used on this channel */
time_t banexpire; /* Time bans expire in */
/** Constructor
* @param chname The channel name
*/
ChannelInfo(const Anope::string &chname);
/** Copy constructor
* @param ci The ChannelInfo to copy settings from
*/
ChannelInfo(const ChannelInfo &ci);
~ChannelInfo();
void Serialize(Serialize::Data &data) const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
/** Change the founder of the channel
* @params nc The new founder
*/
void SetFounder(NickCore *nc);
/** Get the founder of the channel
* @return The founder
*/
NickCore *GetFounder() const;
void SetSuccessor(NickCore *nc);
NickCore *GetSuccessor() const;
/** Find which bot should send mode/topic/etc changes for this channel
* @return The bot
*/
BotInfo *WhoSends() const;
/** Add an entry to the channel access list
* @param access The entry
*/
void AddAccess(ChanAccess *access);
/** Get an entry from the channel access list by index
*
* @param index The index in the access list vector
* @return A ChanAccess struct corresponding to the index given, or NULL if outside the bounds
*
* Retrieves an entry from the access list that matches the given index.
*/
ChanAccess *GetAccess(unsigned index) const;
/** Retrieve the access for a user or group in the form of a vector of access entries
* (as multiple entries can affect a single user).
*/
AccessGroup AccessFor(const User *u, bool updateLastUsed = true);
AccessGroup AccessFor(const NickCore *nc, bool updateLastUsed = true);
/** Get the size of the access vector for this channel
* @return The access vector size
*/
unsigned GetAccessCount() const;
/** Get the number of access entries for this channel,
* including those that are on other channels.
*/
unsigned GetDeepAccessCount() const;
/** Erase an entry from the channel access list
*
* @param index The index in the access list vector
*
* @return The erased entry
*/
ChanAccess *EraseAccess(unsigned index);
/** Clear the entire channel access list
*
* Clears the entire access list by deleting every item and then clearing the vector.
*/
void ClearAccess();
/** Add an akick entry to the channel by NickCore
* @param user The user who added the akick
* @param akicknc The nickcore being akicked
* @param reason The reason for the akick
* @param t The time the akick was added, defaults to now
* @param lu The time the akick was last used, defaults to never
*/
AutoKick* AddAkick(const Anope::string &user, NickCore *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
/** Add an akick entry to the channel by reason
* @param user The user who added the akick
* @param mask The mask of the akick
* @param reason The reason for the akick
* @param t The time the akick was added, defaults to now
* @param lu The time the akick was last used, defaults to never
*/
AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
/** Get an entry from the channel akick list
* @param index The index in the akick vector
* @return The akick structure, or NULL if not found
*/
AutoKick* GetAkick(unsigned index) const;
/** Get the size of the akick vector for this channel
* @return The akick vector size
*/
unsigned GetAkickCount() const;
/** Erase an entry from the channel akick list
* @param index The index of the akick
*/
void EraseAkick(unsigned index);
/** Clear the whole akick list
*/
void ClearAkick();
/** Get the level entries for the channel.
* @return The levels for the channel.
*/
const Anope::map<int16_t> &GetLevelEntries();
/** Get the level for a privilege
* @param priv The privilege name
* @return the level
* @throws CoreException if priv is not a valid privilege
*/
int16_t GetLevel(const Anope::string &priv) const;
/** Set the level for a privilege
* @param priv The privilege priv
* @param level The new level
*/
void SetLevel(const Anope::string &priv, int16_t level);
/** Remove a privilege from the channel
* @param priv The privilege
*/
void RemoveLevel(const Anope::string &priv);
/** Clear all privileges from the channel
*/
void ClearLevels();
/** Gets a ban mask for the given user based on the bantype
* of the channel.
* @param u The user
* @return A ban mask that affects the user
*/
Anope::string GetIdealBan(User *u) const;
/** Finds a ChannelInfo
* @param name channel name to lookup
* @return the ChannelInfo associated with the channel
*/
static ChannelInfo* Find(const Anope::string &name);
void AddChannelReference(const Anope::string &what);
void RemoveChannelReference(const Anope::string &what);
void GetChannelReferences(std::deque<Anope::string> &chans);
};
/** Is the user the real founder?
* @param user The user
* @param ci The channel
* @return true or false
*/
extern CoreExport bool IsFounder(const User *user, const ChannelInfo *ci);
#endif // REGCHANNEL_H