]> jfr.im git - irc/evilnet/x3.git/blob - src/chanserv.h
stage one, half ops support
[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 srvx.
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 lvlGiveVoice,
39 lvlGiveHalfOps,
40 lvlGiveOps,
41 lvlEnfOps,
42 lvlEnfHalfOps,
43 lvlEnfModes,
44 lvlEnfTopic,
45 lvlPubCmd,
46 lvlSetters,
47 lvlCTCPUsers,
48 lvlUserInfo,
49 lvlInviteMe,
50 lvlTopicSnarf,
51 NUM_LEVEL_OPTIONS
52 };
53
54 enum charOption {
55 chProtect,
56 chToys,
57 chTopicRefresh,
58 chCTCPReaction,
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 */
66
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) */
72 #define CHANNEL_HOP_ALL 0x00000200 /* (1 << 9) */
73
74 /* Flags with values over 0x20000000 or (1 << 29) will not work
75 * because chanData.flags is a 30-bit field.
76 */
77
78 #define IsProtected(x) ((x)->flags & CHANNEL_NODELETE)
79 #define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED)
80 #define IsOffChannel(x) ((x)->flags & CHANNEL_OFFCHANNEL)
81
82 struct chanData
83 {
84 struct chanNode *channel;
85 struct mod_chanmode modes;
86
87 time_t registered;
88 time_t visited;
89 time_t limitAdjusted;
90
91 char *topic;
92 char *greeting;
93 char *user_greeting;
94 char *registrar;
95 char *topic_mask;
96
97 unsigned int flags : 30;
98 unsigned int may_opchan : 1;
99 unsigned int max;
100 unsigned int last_refresh;
101 unsigned short banCount;
102 unsigned short userCount;
103 unsigned short lvlOpts[NUM_LEVEL_OPTIONS];
104 unsigned char chOpts[NUM_CHAR_OPTIONS];
105
106 struct userData *users;
107 struct banData *bans;
108 struct dict *notes;
109 struct suspended *suspended;
110 struct chanData *prev;
111 struct chanData *next;
112 };
113
114 #define USER_AUTO_OP 0x00000001
115 #define USER_SUSPENDED 0x00000002
116 #define USER_AUTO_INVITE 0x00000004
117 #define USER_FLAGS_SIZE 7
118
119 #define IsUserAutoOp(USER) (!((USER)->flags & USER_AUTO_OP))
120 #define IsUserSuspended(USER) ((USER)->flags & USER_SUSPENDED)
121 #define IsUserAutoInvite(USER) ((USER)->flags & USER_AUTO_INVITE)
122
123 struct userData
124 {
125 struct handle_info *handle;
126 struct chanData *channel;
127
128 char *info;
129 time_t seen;
130 unsigned short access;
131 unsigned int present : 1;
132 unsigned int flags : USER_FLAGS_SIZE;
133
134 /* linked list of userDatas for a chanData */
135 struct userData *prev;
136 struct userData *next;
137 /* linked list of userDatas for a handle_info */
138 struct userData *u_prev;
139 struct userData *u_next;
140 };
141
142 struct banData
143 {
144 char mask[NICKLEN + USERLEN + HOSTLEN + 3];
145 char owner[NICKLEN+1];
146 struct chanData *channel;
147
148 time_t set;
149 time_t triggered;
150 time_t expires;
151
152 char *reason;
153
154 struct banData *prev;
155 struct banData *next;
156 };
157
158 struct suspended
159 {
160 struct chanData *cData;
161 char *suspender;
162 char *reason;
163 time_t issued, expires, revoked;
164 struct suspended *previous;
165 };
166
167 struct do_not_register
168 {
169 char chan_name[CHANNELLEN+1];
170 char setter[NICKSERV_HANDLE_LEN+1];
171 time_t set;
172 char reason[1];
173 };
174
175 void init_chanserv(const char *nick);
176 void del_channel_user(struct userData *user, int do_gc);
177 struct channelList *chanserv_support_channels(void);
178 unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
179 struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
180 int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
181
182 void do_math(char *Buffer, char *Math);
183
184 #endif