]> jfr.im git - irc/evilnet/x3.git/blame - src/chanserv.h
Fixed irc_topic() to honour server/hidden_host_type and associated config settings
[irc/evilnet/x3.git] / src / chanserv.h
CommitLineData
d76ed9a9 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 7 * it under the terms of the GNU General Public License as published by
348683aa 8 * the Free Software Foundation; either version 3 of the License, or
d76ed9a9 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 {
c9bf23fe 27 UL_PEON = 1,
55342ce8 28 UL_HALFOP = 150,
d76ed9a9 29 UL_OP = 200,
4048352e 30 UL_MANAGER = 300,
c9bf23fe 31 UL_PRESENT = UL_MANAGER, /* Level needed to keep the channel active */
d76ed9a9 32 UL_COOWNER = 400,
33 UL_OWNER = 500,
34 UL_HELPER = 600,
35};
36
37enum levelOption {
d76ed9a9 38 lvlEnfOps,
55342ce8 39 lvlEnfHalfOps,
d76ed9a9 40 lvlEnfModes,
41 lvlEnfTopic,
42 lvlPubCmd,
43 lvlSetters,
d76ed9a9 44 lvlUserInfo,
45 lvlInviteMe,
46 lvlTopicSnarf,
47 NUM_LEVEL_OPTIONS
48};
49
50enum charOption {
4b6129c0 51 chAutomode,
d76ed9a9 52 chProtect,
53 chToys,
54 chTopicRefresh,
55 chCTCPReaction,
31f23f13 56 chBanTimeout,
7637f48f 57 chResync,
d76ed9a9 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 */
55342ce8 65
d76ed9a9 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) */
55342ce8 71#define CHANNEL_HOP_ALL 0x00000200 /* (1 << 9) */
1136f709 72#define CHANNEL_UNREVIEWED 0x00000400 /* (1 << 10) */
73
d76ed9a9 74/* Flags with values over 0x20000000 or (1 << 29) will not work
75 * because chanData.flags is a 30-bit field.
76 */
77
ac3bdc8d 78/* how many seconds a pending adduser will wait for a user
79 * to get auth or register
80 */
81#define ADDUSER_PENDING_EXPIRE 7200 /* 2 hours */
82
d76ed9a9 83#define IsProtected(x) ((x)->flags & CHANNEL_NODELETE)
84#define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED)
0d16e639 85#define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1))
d76ed9a9 86
87struct chanData
88{
89 struct chanNode *channel;
90 struct mod_chanmode modes;
91
92 time_t registered;
93 time_t visited;
94 time_t limitAdjusted;
a32da4c7 95 time_t ownerTransfer;
d76ed9a9 96
97 char *topic;
98 char *greeting;
99 char *user_greeting;
100 char *registrar;
101 char *topic_mask;
102
8b9e7d45 103 unsigned int maxsetinfo;
d76ed9a9 104 unsigned int flags : 30;
105 unsigned int may_opchan : 1;
106 unsigned int max;
107 unsigned int last_refresh;
7637f48f 108 unsigned int last_resync;
87708af4 109 unsigned int roulette_chamber;
31f23f13 110 unsigned short banCount; /* Lamers, really */
d76ed9a9 111 unsigned short userCount;
112 unsigned short lvlOpts[NUM_LEVEL_OPTIONS];
113 unsigned char chOpts[NUM_CHAR_OPTIONS];
114
115 struct userData *users;
31f23f13 116 struct banData *bans; /* Lamers, really */
d76ed9a9 117 struct dict *notes;
118 struct suspended *suspended;
82f37c08 119 struct giveownership *giveownership;
d76ed9a9 120 struct chanData *prev;
121 struct chanData *next;
122};
123
c8ca69a0 124#define USER_NOAUTO_OP 0x00000001 /* OLD; Not used at all.. */
d76ed9a9 125#define USER_SUSPENDED 0x00000002
126#define USER_AUTO_INVITE 0x00000004
c8ca69a0 127#define USER_AUTO_OP 0x00000008
cd25f2e9 128#define USER_AUTO_JOIN 0x00000010
129#define USER_FLAGS_SIZE 25
c8ca69a0 130#define USER_FLAGS_DEFAULT USER_AUTO_OP
d76ed9a9 131
c8ca69a0 132#define IsUserAutoOp(USER) ((USER)->flags & USER_AUTO_OP)
d76ed9a9 133#define IsUserSuspended(USER) ((USER)->flags & USER_SUSPENDED)
134#define IsUserAutoInvite(USER) ((USER)->flags & USER_AUTO_INVITE)
cd25f2e9 135#define IsUserAutoJoin(USER) ((USER)->flags & USER_AUTO_JOIN)
d76ed9a9 136
137struct userData
138{
139 struct handle_info *handle;
140 struct chanData *channel;
141
142 char *info;
143 time_t seen;
b10abdb2 144 time_t expires;
dfaa28a4 145 time_t accessexpiry;
146 time_t clvlexpiry;
147 unsigned short lastaccess;
d76ed9a9 148 unsigned short access;
149 unsigned int present : 1;
150 unsigned int flags : USER_FLAGS_SIZE;
151
152 /* linked list of userDatas for a chanData */
153 struct userData *prev;
154 struct userData *next;
155 /* linked list of userDatas for a handle_info */
156 struct userData *u_prev;
157 struct userData *u_next;
158};
159
ac3bdc8d 160struct adduserPending
161{
162 struct chanNode *channel;
163 struct userNode *user;
164 int level;
165 time_t created;
166
167 struct adduserPending *prev;
168 struct adduserPending *next;
169};
170
d76ed9a9 171struct banData
172{
173 char mask[NICKLEN + USERLEN + HOSTLEN + 3];
174 char owner[NICKLEN+1];
175 struct chanData *channel;
176
177 time_t set;
178 time_t triggered;
179 time_t expires;
180
181 char *reason;
182
183 struct banData *prev;
184 struct banData *next;
185};
186
187struct suspended
188{
189 struct chanData *cData;
190 char *suspender;
191 char *reason;
192 time_t issued, expires, revoked;
193 struct suspended *previous;
194};
195
82f37c08 196struct giveownership
197{
198 char *staff_issuer;
199 char *old_owner;
200 char *target;
201 unsigned short target_access;
202 time_t issued;
203 char *reason;
204 struct giveownership *previous;
205};
206
d76ed9a9 207struct do_not_register
208{
209 char chan_name[CHANNELLEN+1];
210 char setter[NICKSERV_HANDLE_LEN+1];
1136f709 211 time_t set, expires;
d76ed9a9 212 char reason[1];
213};
214
63c95a47 215#define GetChannelUser(channel, handle) _GetChannelUser(channel, handle, 1, 0)
216struct userData *_GetChannelUser(struct chanData *channel, struct handle_info *handle, int override, int allow_suspended);
217struct banData *add_channel_ban(struct chanData *channel, const char *mask, char *owner, time_t set, time_t triggered, time_t expires, char *reason);
218
d76ed9a9 219void init_chanserv(const char *nick);
220void del_channel_user(struct userData *user, int do_gc);
221struct channelList *chanserv_support_channels(void);
222unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
223struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
224int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
225
e5a8f7cd 226void do_math(char *Buffer, char *Math);
de9510bc 227char* user_level_name_from_level(int level);
228
ac3bdc8d 229void process_adduser_pending(struct userNode *user);
230void wipe_adduser_pending(struct chanNode *channel, struct userNode *user);
e5a8f7cd 231
1b6b5e2f 232int check_bans(struct userNode *user, const char *channel);
5aa400d2 233int trace_check_bans(struct userNode *user, struct chanNode *chan);
c99dcaf6 234
d76ed9a9 235#endif