summaryrefslogtreecommitdiff
path: root/include/modules/chanserv/channel.h
blob: 7c114eea037eb3a373de75f9b2f3e12b3042a4f6 (plain)
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
/*
 * Anope IRC Services
 *
 * Copyright (C) 2012-2017 Anope Team <team@anope.org>
 *
 * 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/>.
 */

#pragma once

namespace ChanServ
{

class CoreExport Channel : public Serialize::Object
{
 public:
	::Channel *c = nullptr;                               /* Pointer to channel, if the channel exists */

	static constexpr const char *const NAME = "channel";

	using Serialize::Object::Object;

	virtual Anope::string GetName() anope_abstract;
	virtual void SetName(const Anope::string &) anope_abstract;

	virtual Anope::string GetDesc() anope_abstract;
	virtual void SetDesc(const Anope::string &) anope_abstract;

	virtual time_t GetTimeRegistered() anope_abstract;
	virtual void SetTimeRegistered(time_t) anope_abstract;

	virtual time_t GetLastUsed() anope_abstract;
	virtual void SetLastUsed(time_t) anope_abstract;

	virtual Anope::string GetLastTopic() anope_abstract;
	virtual void SetLastTopic(const Anope::string &) anope_abstract;

	virtual Anope::string GetLastTopicSetter() anope_abstract;
	virtual void SetLastTopicSetter(const Anope::string &) anope_abstract;

	virtual time_t GetLastTopicTime() anope_abstract;
	virtual void SetLastTopicTime(time_t) anope_abstract;

	virtual int16_t GetBanType() anope_abstract;
	virtual void SetBanType(int16_t) anope_abstract;

	virtual time_t GetBanExpire() anope_abstract;
	virtual void SetBanExpire(time_t) anope_abstract;

	virtual BotInfo *GetBI() anope_abstract;
	virtual void SetBI(BotInfo *) anope_abstract;

	virtual ServiceBot *GetBot() anope_abstract;
	virtual void SetBot(ServiceBot *) anope_abstract;

	/** Whether or not greets are enabled.
	 */
	virtual bool IsGreet() anope_abstract;
	virtual void SetGreet(bool) anope_abstract;

	/** Whether or not fantasy is enabled.
	 */
	virtual bool IsFantasy() anope_abstract;
	virtual void SetFantasy(bool) anope_abstract;

	virtual bool IsNoAutoop() anope_abstract;
	virtual void SetNoAutoop(bool) anope_abstract;

	virtual bool IsPeace() anope_abstract;
	virtual void SetPeace(bool) anope_abstract;

	virtual bool IsSecureFounder() anope_abstract;
	virtual void SetSecureFounder(bool) anope_abstract;

	virtual bool IsRestricted() anope_abstract;
	virtual void SetRestricted(bool) anope_abstract;

	virtual bool IsSecureOps() anope_abstract;
	virtual void SetSecureOps(bool) anope_abstract;

	virtual bool IsSignKick() anope_abstract;
	virtual void SetSignKick(bool) anope_abstract;

	virtual bool IsSignKickLevel() anope_abstract;
	virtual void SetSignKickLevel(bool) anope_abstract;

	virtual bool IsNoExpire() anope_abstract;
	virtual void SetNoExpire(bool) anope_abstract;

	virtual bool IsKeepModes() anope_abstract;
	virtual void SetKeepModes(bool) anope_abstract;

	virtual bool IsPersist() anope_abstract;
	virtual void SetPersist(bool) anope_abstract;

	virtual bool IsTopicLock() anope_abstract;
	virtual void SetTopicLock(bool) anope_abstract;

	virtual bool IsKeepTopic() anope_abstract;
	virtual void SetKeepTopic(bool) anope_abstract;

	virtual bool IsPrivate() anope_abstract;
	virtual void SetPrivate(bool) anope_abstract;

	/** Is the user the real founder?
	 * @param user The user
	 * @return true or false
	 */
	virtual bool IsFounder(const User *user) anope_abstract;

	/** Change the founder of the channel
	 * @params nc The new founder
	 */
	virtual void SetFounder(NickServ::Account *nc) anope_abstract;

	/** Get the founder of the channel
	 * @return The founder
	 */
	virtual NickServ::Account *GetFounder() anope_abstract;

	virtual void SetSuccessor(NickServ::Account *nc) anope_abstract;
	virtual NickServ::Account *GetSuccessor() anope_abstract;

	/** Find which bot should send mode/topic/etc changes for this channel
	 * @return The bot
	 */
	virtual ServiceBot *WhoSends() anope_abstract;

	/** 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.
	 */
	virtual ChanAccess *GetAccess(unsigned index) /*const*/ anope_abstract;

	/** 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).
	 */
	virtual AccessGroup AccessFor(const User *u, bool updateLastUsed = true) anope_abstract;
	virtual AccessGroup AccessFor(NickServ::Account *nc, bool updateLastUsed = true) anope_abstract;

	/** Get the size of the access vector for this channel
	 * @return The access vector size
	 */
	virtual unsigned GetAccessCount() anope_abstract;

	/** Clear the entire channel access list
	 *
	 * Clears the entire access list by deleting every item and then clearing the vector.
	 */
	virtual void ClearAccess() anope_abstract;

	/** Add an akick entry to the channel by NickServ::Account
	 * @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
	 */
	virtual AutoKick* AddAkick(const Anope::string &user, NickServ::Account *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) anope_abstract;

	/** 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
	 */
	virtual AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) anope_abstract;

	/** 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
	 */
	virtual AutoKick* GetAkick(unsigned index) anope_abstract;

	/** Get the size of the akick vector for this channel
	 * @return The akick vector size
	 */
	virtual unsigned GetAkickCount() anope_abstract;

	/** Clear the whole akick list
	 */
	virtual void ClearAkick() anope_abstract;

	/** Get the level for a privilege
	 * @param priv The privilege name
	 * @return the level
	 * @throws CoreException if priv is not a valid privilege
	 */
	virtual int16_t GetLevel(const Anope::string &priv) anope_abstract;

	/** Set the level for a privilege
	 * @param priv The privilege priv
	 * @param level The new level
	 */
	virtual void SetLevel(const Anope::string &priv, int16_t level) anope_abstract;

	/** Remove a privilege from the channel
	 * @param priv The privilege
	 */
	virtual void RemoveLevel(const Anope::string &priv) anope_abstract;

	/** Clear all privileges from the channel
	 */
	virtual void ClearLevels() anope_abstract;

	/** 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
	 */
	virtual Anope::string GetIdealBan(User *u) anope_abstract;

	virtual MemoServ::MemoInfo *GetMemos() anope_abstract;
};


} // namespace ChanServ