]> jfr.im git - irc/evilnet/x3.git/blame - src/chanserv.h
Changed/improved 'silent' gline support
[irc/evilnet/x3.git] / src / chanserv.h
CommitLineData
d76ed9a9
AS
1/* chanserv.h - Channel service bot
2 * Copyright 2000-2004 srvx Development Team
3 *
83ff05c3 4 * This file is part of x3.
d76ed9a9 5 *
d0f04f71 6 * x3 is free software; you can redistribute it and/or modify
d76ed9a9
AS
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 */
20
21#ifndef _chanserv_h
22#define _chanserv_h
23
24#include "nickserv.h"
25
26enum UL_ALIASES {
27 UL_PEON = 100,
55342ce8 28 UL_HALFOP = 150,
d76ed9a9 29 UL_OP = 200,
4048352e
AS
30 UL_MANAGER = 300,
31 UL_PRESENT = UL_MANAGER,
d76ed9a9
AS
32 UL_COOWNER = 400,
33 UL_OWNER = 500,
34 UL_HELPER = 600,
35};
36
37enum levelOption {
d76ed9a9 38 lvlEnfOps,
55342ce8 39 lvlEnfHalfOps,
d76ed9a9
AS
40 lvlEnfModes,
41 lvlEnfTopic,
42 lvlPubCmd,
43 lvlSetters,
d76ed9a9
AS
44 lvlUserInfo,
45 lvlInviteMe,
46 lvlTopicSnarf,
47 NUM_LEVEL_OPTIONS
48};
49
50enum charOption {
4b6129c0 51 chAutomode,
d76ed9a9
AS
52 chProtect,
53 chToys,
54 chTopicRefresh,
55 chCTCPReaction,
31f23f13 56 chBanTimeout,
7637f48f 57 chResync,
fe32eb19 58 chBanType,
d76ed9a9
AS
59 NUM_CHAR_OPTIONS
60};
61
62#define CHANNEL_NODELETE 0x00000001 /* (1 << 0) */
63#define CHANNEL_SUSPENDED 0x00000002 /* (1 << 1) */
64#define CHANNEL_INFO_LINES 0x00000004 /* (1 << 2) - DEPRECATED */
65#define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) - DEPRECATED */
55342ce8 66
d76ed9a9
AS
67/* No longer used. */ /* (1 << 4) */
68#define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */
69#define CHANNEL_TOPIC_SNARF 0x00000040 /* (1 << 6) - DEPRECATED */
70#define CHANNEL_PEON_INVITE 0x00000080 /* (1 << 7) - DEPRECATED */
71#define CHANNEL_OFFCHANNEL 0x00000100 /* (1 << 8) */
55342ce8 72#define CHANNEL_HOP_ALL 0x00000200 /* (1 << 9) */
d76ed9a9
AS
73/* Flags with values over 0x20000000 or (1 << 29) will not work
74 * because chanData.flags is a 30-bit field.
75 */
76
ac3bdc8d
AS
77/* how many seconds a pending adduser will wait for a user
78 * to get auth or register
79 */
80#define ADDUSER_PENDING_EXPIRE 7200 /* 2 hours */
81
d76ed9a9
AS
82#define IsProtected(x) ((x)->flags & CHANNEL_NODELETE)
83#define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED)
0d16e639 84#define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1))
d76ed9a9
AS
85
86struct chanData
87{
88 struct chanNode *channel;
89 struct mod_chanmode modes;
90
91 time_t registered;
92 time_t visited;
93 time_t limitAdjusted;
a32da4c7 94 time_t ownerTransfer;
d76ed9a9
AS
95
96 char *topic;
97 char *greeting;
98 char *user_greeting;
99 char *registrar;
100 char *topic_mask;
101
102 unsigned int flags : 30;
103 unsigned int may_opchan : 1;
104 unsigned int max;
105 unsigned int last_refresh;
7637f48f 106 unsigned int last_resync;
31f23f13 107 unsigned short banCount; /* Lamers, really */
d76ed9a9
AS
108 unsigned short userCount;
109 unsigned short lvlOpts[NUM_LEVEL_OPTIONS];
110 unsigned char chOpts[NUM_CHAR_OPTIONS];
111
112 struct userData *users;
31f23f13 113 struct banData *bans; /* Lamers, really */
d76ed9a9
AS
114 struct dict *notes;
115 struct suspended *suspended;
82f37c08 116 struct giveownership *giveownership;
d76ed9a9
AS
117 struct chanData *prev;
118 struct chanData *next;
119};
120
c8ca69a0 121#define USER_NOAUTO_OP 0x00000001 /* OLD; Not used at all.. */
d76ed9a9
AS
122#define USER_SUSPENDED 0x00000002
123#define USER_AUTO_INVITE 0x00000004
c8ca69a0
AS
124#define USER_AUTO_OP 0x00000008
125#define USER_FLAGS_SIZE 15
126#define USER_FLAGS_DEFAULT USER_AUTO_OP
d76ed9a9 127
c8ca69a0 128#define IsUserAutoOp(USER) ((USER)->flags & USER_AUTO_OP)
d76ed9a9
AS
129#define IsUserSuspended(USER) ((USER)->flags & USER_SUSPENDED)
130#define IsUserAutoInvite(USER) ((USER)->flags & USER_AUTO_INVITE)
131
132struct userData
133{
134 struct handle_info *handle;
135 struct chanData *channel;
136
137 char *info;
138 time_t seen;
b10abdb2 139 time_t expires;
d76ed9a9
AS
140 unsigned short access;
141 unsigned int present : 1;
142 unsigned int flags : USER_FLAGS_SIZE;
143
144 /* linked list of userDatas for a chanData */
145 struct userData *prev;
146 struct userData *next;
147 /* linked list of userDatas for a handle_info */
148 struct userData *u_prev;
149 struct userData *u_next;
150};
151
ac3bdc8d
AS
152struct adduserPending
153{
154 struct chanNode *channel;
155 struct userNode *user;
156 int level;
157 time_t created;
158
159 struct adduserPending *prev;
160 struct adduserPending *next;
161};
162
d76ed9a9
AS
163struct banData
164{
165 char mask[NICKLEN + USERLEN + HOSTLEN + 3];
166 char owner[NICKLEN+1];
167 struct chanData *channel;
168
169 time_t set;
170 time_t triggered;
171 time_t expires;
172
173 char *reason;
174
175 struct banData *prev;
176 struct banData *next;
177};
178
179struct suspended
180{
181 struct chanData *cData;
182 char *suspender;
183 char *reason;
184 time_t issued, expires, revoked;
185 struct suspended *previous;
186};
187
82f37c08 188struct giveownership
189{
190 char *staff_issuer;
191 char *old_owner;
192 char *target;
193 unsigned short target_access;
194 time_t issued;
195 char *reason;
196 struct giveownership *previous;
197};
198
d76ed9a9
AS
199struct do_not_register
200{
201 char chan_name[CHANNELLEN+1];
202 char setter[NICKSERV_HANDLE_LEN+1];
203 time_t set;
204 char reason[1];
205};
206
63c95a47 207#define GetChannelUser(channel, handle) _GetChannelUser(channel, handle, 1, 0)
208struct userData *_GetChannelUser(struct chanData *channel, struct handle_info *handle, int override, int allow_suspended);
209struct banData *add_channel_ban(struct chanData *channel, const char *mask, char *owner, time_t set, time_t triggered, time_t expires, char *reason);
210
d76ed9a9
AS
211void init_chanserv(const char *nick);
212void del_channel_user(struct userData *user, int do_gc);
213struct channelList *chanserv_support_channels(void);
214unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
215struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
216int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
217
e5a8f7cd 218void do_math(char *Buffer, char *Math);
de9510bc
AS
219char* user_level_name_from_level(int level);
220
ac3bdc8d
AS
221void process_adduser_pending(struct userNode *user);
222void wipe_adduser_pending(struct chanNode *channel, struct userNode *user);
e5a8f7cd 223
d76ed9a9 224#endif