]>
Commit | Line | Data |
---|---|---|
1 | /* chanserv.h - Channel service bot | |
2 | * Copyright 2000-2004 srvx Development Team | |
3 | * | |
4 | * This file is part of x3. | |
5 | * | |
6 | * x3 is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 3 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 | ||
26 | enum UL_ALIASES { | |
27 | UL_PEON = 1, | |
28 | UL_HALFOP = 150, | |
29 | UL_OP = 200, | |
30 | UL_MANAGER = 300, | |
31 | UL_PRESENT = UL_MANAGER, /* Level needed to keep the channel active */ | |
32 | UL_COOWNER = 400, | |
33 | UL_OWNER = 500, | |
34 | UL_HELPER = 600, | |
35 | }; | |
36 | ||
37 | enum levelOption { | |
38 | lvlEnfOps, | |
39 | lvlEnfHalfOps, | |
40 | lvlEnfModes, | |
41 | lvlEnfTopic, | |
42 | lvlPubCmd, | |
43 | lvlSetters, | |
44 | lvlUserInfo, | |
45 | lvlInviteMe, | |
46 | lvlTopicSnarf, | |
47 | NUM_LEVEL_OPTIONS | |
48 | }; | |
49 | ||
50 | enum charOption { | |
51 | chAutomode, | |
52 | chProtect, | |
53 | chToys, | |
54 | chTopicRefresh, | |
55 | chCTCPReaction, | |
56 | chBanTimeout, | |
57 | chResync, | |
58 | NUM_CHAR_OPTIONS | |
59 | }; | |
60 | ||
61 | #define CHANNEL_NODELETE 0x00000001 /* (1 << 0) */ | |
62 | #define CHANNEL_SUSPENDED 0x00000002 /* (1 << 1) */ | |
63 | #define CHANNEL_INFO_LINES 0x00000004 /* (1 << 2) - DEPRECATED */ | |
64 | #define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) - DEPRECATED */ | |
65 | ||
66 | /* No longer used. */ /* (1 << 4) */ | |
67 | #define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */ | |
68 | #define CHANNEL_TOPIC_SNARF 0x00000040 /* (1 << 6) - DEPRECATED */ | |
69 | #define CHANNEL_PEON_INVITE 0x00000080 /* (1 << 7) - DEPRECATED */ | |
70 | #define CHANNEL_OFFCHANNEL 0x00000100 /* (1 << 8) */ | |
71 | #define CHANNEL_HOP_ALL 0x00000200 /* (1 << 9) */ | |
72 | #define CHANNEL_UNREVIEWED 0x00000400 /* (1 << 9) */ | |
73 | /* Flags with values over 0x20000000 or (1 << 29) will not work | |
74 | * because chanData.flags is a 30-bit field. | |
75 | */ | |
76 | ||
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 | ||
82 | #define IsProtected(x) ((x)->flags & CHANNEL_NODELETE) | |
83 | #define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED) | |
84 | #define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1)) | |
85 | ||
86 | struct chanData | |
87 | { | |
88 | struct chanNode *channel; | |
89 | struct mod_chanmode modes; | |
90 | ||
91 | time_t registered; | |
92 | time_t visited; | |
93 | time_t limitAdjusted; | |
94 | time_t ownerTransfer; | |
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; | |
106 | unsigned int last_resync; | |
107 | unsigned short banCount; /* Lamers, really */ | |
108 | unsigned short userCount; | |
109 | unsigned short lvlOpts[NUM_LEVEL_OPTIONS]; | |
110 | unsigned char chOpts[NUM_CHAR_OPTIONS]; | |
111 | ||
112 | struct userData *users; | |
113 | struct banData *bans; /* Lamers, really */ | |
114 | struct dict *notes; | |
115 | struct suspended *suspended; | |
116 | struct giveownership *giveownership; | |
117 | struct chanData *prev; | |
118 | struct chanData *next; | |
119 | }; | |
120 | ||
121 | #define USER_NOAUTO_OP 0x00000001 /* OLD; Not used at all.. */ | |
122 | #define USER_SUSPENDED 0x00000002 | |
123 | #define USER_AUTO_INVITE 0x00000004 | |
124 | #define USER_AUTO_OP 0x00000008 | |
125 | #define USER_AUTO_JOIN 0x00000010 | |
126 | #define USER_FLAGS_SIZE 25 | |
127 | #define USER_FLAGS_DEFAULT USER_AUTO_OP | |
128 | ||
129 | #define IsUserAutoOp(USER) ((USER)->flags & USER_AUTO_OP) | |
130 | #define IsUserSuspended(USER) ((USER)->flags & USER_SUSPENDED) | |
131 | #define IsUserAutoInvite(USER) ((USER)->flags & USER_AUTO_INVITE) | |
132 | #define IsUserAutoJoin(USER) ((USER)->flags & USER_AUTO_JOIN) | |
133 | ||
134 | struct userData | |
135 | { | |
136 | struct handle_info *handle; | |
137 | struct chanData *channel; | |
138 | ||
139 | char *info; | |
140 | time_t seen; | |
141 | time_t expires; | |
142 | time_t accessexpiry; | |
143 | time_t clvlexpiry; | |
144 | unsigned short lastaccess; | |
145 | unsigned short access; | |
146 | unsigned int present : 1; | |
147 | unsigned int flags : USER_FLAGS_SIZE; | |
148 | ||
149 | /* linked list of userDatas for a chanData */ | |
150 | struct userData *prev; | |
151 | struct userData *next; | |
152 | /* linked list of userDatas for a handle_info */ | |
153 | struct userData *u_prev; | |
154 | struct userData *u_next; | |
155 | }; | |
156 | ||
157 | struct adduserPending | |
158 | { | |
159 | struct chanNode *channel; | |
160 | struct userNode *user; | |
161 | int level; | |
162 | time_t created; | |
163 | ||
164 | struct adduserPending *prev; | |
165 | struct adduserPending *next; | |
166 | }; | |
167 | ||
168 | struct banData | |
169 | { | |
170 | char mask[NICKLEN + USERLEN + HOSTLEN + 3]; | |
171 | char owner[NICKLEN+1]; | |
172 | struct chanData *channel; | |
173 | ||
174 | time_t set; | |
175 | time_t triggered; | |
176 | time_t expires; | |
177 | ||
178 | char *reason; | |
179 | ||
180 | struct banData *prev; | |
181 | struct banData *next; | |
182 | }; | |
183 | ||
184 | struct suspended | |
185 | { | |
186 | struct chanData *cData; | |
187 | char *suspender; | |
188 | char *reason; | |
189 | time_t issued, expires, revoked; | |
190 | struct suspended *previous; | |
191 | }; | |
192 | ||
193 | struct giveownership | |
194 | { | |
195 | char *staff_issuer; | |
196 | char *old_owner; | |
197 | char *target; | |
198 | unsigned short target_access; | |
199 | time_t issued; | |
200 | char *reason; | |
201 | struct giveownership *previous; | |
202 | }; | |
203 | ||
204 | struct do_not_register | |
205 | { | |
206 | char chan_name[CHANNELLEN+1]; | |
207 | char setter[NICKSERV_HANDLE_LEN+1]; | |
208 | time_t set, expires; | |
209 | char reason[1]; | |
210 | }; | |
211 | ||
212 | #define GetChannelUser(channel, handle) _GetChannelUser(channel, handle, 1, 0) | |
213 | struct userData *_GetChannelUser(struct chanData *channel, struct handle_info *handle, int override, int allow_suspended); | |
214 | struct banData *add_channel_ban(struct chanData *channel, const char *mask, char *owner, time_t set, time_t triggered, time_t expires, char *reason); | |
215 | ||
216 | void init_chanserv(const char *nick); | |
217 | void del_channel_user(struct userData *user, int do_gc); | |
218 | struct channelList *chanserv_support_channels(void); | |
219 | unsigned short user_level_from_name(const char *name, unsigned short clamp_level); | |
220 | struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle); | |
221 | int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner); | |
222 | ||
223 | void do_math(char *Buffer, char *Math); | |
224 | char* user_level_name_from_level(int level); | |
225 | ||
226 | void process_adduser_pending(struct userNode *user); | |
227 | void wipe_adduser_pending(struct chanNode *channel, struct userNode *user); | |
228 | ||
229 | int check_bans(struct userNode *user, const char *channel); | |
230 | int trace_check_bans(struct userNode *user, struct chanNode *chan); | |
231 | ||
232 | #endif |