]> jfr.im git - irc/evilnet/x3.git/blob - src/chanserv.h
This makes channels more flexable as far as what modes are applied to what users...
[irc/evilnet/x3.git] / src / chanserv.h
1 /* chanserv.h - Channel service bot
2 * Copyright 2000-2004 srvx Development Team
3 *
4 * This file is part of x3.
5 *
6 * srvx 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 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
26 enum UL_ALIASES {
27 UL_PEON = 100,
28 UL_HALFOP = 150,
29 UL_OP = 200,
30 UL_MANAGER = 300,
31 UL_PRESENT = UL_MANAGER,
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 NUM_CHAR_OPTIONS
58 };
59
60 #define CHANNEL_NODELETE 0x00000001 /* (1 << 0) */
61 #define CHANNEL_SUSPENDED 0x00000002 /* (1 << 1) */
62 #define CHANNEL_INFO_LINES 0x00000004 /* (1 << 2) - DEPRECATED */
63 #define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) - DEPRECATED */
64
65 /* No longer used. */ /* (1 << 4) */
66 #define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */
67 #define CHANNEL_TOPIC_SNARF 0x00000040 /* (1 << 6) - DEPRECATED */
68 #define CHANNEL_PEON_INVITE 0x00000080 /* (1 << 7) - DEPRECATED */
69 #define CHANNEL_OFFCHANNEL 0x00000100 /* (1 << 8) */
70 #define CHANNEL_HOP_ALL 0x00000200 /* (1 << 9) */
71 /* Flags with values over 0x20000000 or (1 << 29) will not work
72 * because chanData.flags is a 30-bit field.
73 */
74
75 /* how many seconds a pending adduser will wait for a user
76 * to get auth or register
77 */
78 #define ADDUSER_PENDING_EXPIRE 7200 /* 2 hours */
79
80 #define IsProtected(x) ((x)->flags & CHANNEL_NODELETE)
81 #define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED)
82 #define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1))
83
84 struct chanData
85 {
86 struct chanNode *channel;
87 struct mod_chanmode modes;
88
89 time_t registered;
90 time_t visited;
91 time_t limitAdjusted;
92 time_t ownerTransfer;
93
94 char *topic;
95 char *greeting;
96 char *user_greeting;
97 char *registrar;
98 char *topic_mask;
99
100 unsigned int flags : 30;
101 unsigned int may_opchan : 1;
102 unsigned int max;
103 unsigned int last_refresh;
104 unsigned short banCount; /* Lamers, really */
105 unsigned short userCount;
106 unsigned short lvlOpts[NUM_LEVEL_OPTIONS];
107 unsigned char chOpts[NUM_CHAR_OPTIONS];
108
109 struct userData *users;
110 struct banData *bans; /* Lamers, really */
111 struct dict *notes;
112 struct suspended *suspended;
113 struct chanData *prev;
114 struct chanData *next;
115 };
116
117 #define USER_NOAUTO_OP 0x00000001 /* OLD; Not used at all.. */
118 #define USER_SUSPENDED 0x00000002
119 #define USER_AUTO_INVITE 0x00000004
120 #define USER_AUTO_OP 0x00000008
121 #define USER_FLAGS_SIZE 15
122 #define USER_FLAGS_DEFAULT USER_AUTO_OP
123
124 #define IsUserAutoOp(USER) ((USER)->flags & USER_AUTO_OP)
125 #define IsUserSuspended(USER) ((USER)->flags & USER_SUSPENDED)
126 #define IsUserAutoInvite(USER) ((USER)->flags & USER_AUTO_INVITE)
127
128 struct userData
129 {
130 struct handle_info *handle;
131 struct chanData *channel;
132
133 char *info;
134 time_t seen;
135 unsigned short access;
136 unsigned int present : 1;
137 unsigned int flags : USER_FLAGS_SIZE;
138
139 /* linked list of userDatas for a chanData */
140 struct userData *prev;
141 struct userData *next;
142 /* linked list of userDatas for a handle_info */
143 struct userData *u_prev;
144 struct userData *u_next;
145 };
146
147 struct adduserPending
148 {
149 struct chanNode *channel;
150 struct userNode *user;
151 int level;
152 time_t created;
153
154 struct adduserPending *prev;
155 struct adduserPending *next;
156 };
157
158 struct banData
159 {
160 char mask[NICKLEN + USERLEN + HOSTLEN + 3];
161 char owner[NICKLEN+1];
162 struct chanData *channel;
163
164 time_t set;
165 time_t triggered;
166 time_t expires;
167
168 char *reason;
169
170 struct banData *prev;
171 struct banData *next;
172 };
173
174 struct suspended
175 {
176 struct chanData *cData;
177 char *suspender;
178 char *reason;
179 time_t issued, expires, revoked;
180 struct suspended *previous;
181 };
182
183 struct do_not_register
184 {
185 char chan_name[CHANNELLEN+1];
186 char setter[NICKSERV_HANDLE_LEN+1];
187 time_t set;
188 char reason[1];
189 };
190
191 void init_chanserv(const char *nick);
192 void del_channel_user(struct userData *user, int do_gc);
193 struct channelList *chanserv_support_channels(void);
194 unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
195 struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
196 int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
197
198 void do_math(char *Buffer, char *Math);
199 char* user_level_name_from_level(int level);
200
201 void process_adduser_pending(struct userNode *user);
202 void wipe_adduser_pending(struct chanNode *channel, struct userNode *user);
203
204 #endif