]> jfr.im git - irc/evilnet/x3.git/blob - src/chanserv.h
Add calc command from Mystical (really from X2). NOTE: Not tested.
[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_OP = 200,
29 UL_MANAGER = 300,
30 UL_PRESENT = UL_MANAGER,
31 UL_COOWNER = 400,
32 UL_OWNER = 500,
33 UL_HELPER = 600,
34 };
35
36 enum levelOption {
37 lvlGiveVoice,
38 lvlGiveOps,
39 lvlEnfOps,
40 lvlEnfModes,
41 lvlEnfTopic,
42 lvlPubCmd,
43 lvlSetters,
44 lvlCTCPUsers,
45 lvlUserInfo,
46 lvlInviteMe,
47 lvlTopicSnarf,
48 NUM_LEVEL_OPTIONS
49 };
50
51 enum charOption {
52 chProtect,
53 chToys,
54 chTopicRefresh,
55 chCTCPReaction,
56 NUM_CHAR_OPTIONS
57 };
58
59 #define CHANNEL_NODELETE 0x00000001 /* (1 << 0) */
60 #define CHANNEL_SUSPENDED 0x00000002 /* (1 << 1) */
61 #define CHANNEL_INFO_LINES 0x00000004 /* (1 << 2) - DEPRECATED */
62 #define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) - DEPRECATED */
63 /* No longer used. */ /* (1 << 4) */
64 #define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */
65 #define CHANNEL_TOPIC_SNARF 0x00000040 /* (1 << 6) - DEPRECATED */
66 #define CHANNEL_PEON_INVITE 0x00000080 /* (1 << 7) - DEPRECATED */
67 #define CHANNEL_OFFCHANNEL 0x00000100 /* (1 << 8) */
68 /* Flags with values over 0x20000000 or (1 << 29) will not work
69 * because chanData.flags is a 30-bit field.
70 */
71
72 #define IsProtected(x) ((x)->flags & CHANNEL_NODELETE)
73 #define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED)
74 #define IsOffChannel(x) ((x)->flags & CHANNEL_OFFCHANNEL)
75
76 struct chanData
77 {
78 struct chanNode *channel;
79 struct mod_chanmode modes;
80
81 time_t registered;
82 time_t visited;
83 time_t limitAdjusted;
84
85 char *topic;
86 char *greeting;
87 char *user_greeting;
88 char *registrar;
89 char *topic_mask;
90
91 unsigned int flags : 30;
92 unsigned int may_opchan : 1;
93 unsigned int max;
94 unsigned int last_refresh;
95 unsigned short banCount;
96 unsigned short userCount;
97 unsigned short lvlOpts[NUM_LEVEL_OPTIONS];
98 unsigned char chOpts[NUM_CHAR_OPTIONS];
99
100 struct userData *users;
101 struct banData *bans;
102 struct dict *notes;
103 struct suspended *suspended;
104 struct chanData *prev;
105 struct chanData *next;
106 };
107
108 #define USER_AUTO_OP 0x00000001
109 #define USER_SUSPENDED 0x00000002
110 #define USER_AUTO_INVITE 0x00000004
111 #define USER_FLAGS_SIZE 7
112
113 #define IsUserAutoOp(USER) (!((USER)->flags & USER_AUTO_OP))
114 #define IsUserSuspended(USER) ((USER)->flags & USER_SUSPENDED)
115 #define IsUserAutoInvite(USER) ((USER)->flags & USER_AUTO_INVITE)
116
117 struct userData
118 {
119 struct handle_info *handle;
120 struct chanData *channel;
121
122 char *info;
123 time_t seen;
124 unsigned short access;
125 unsigned int present : 1;
126 unsigned int flags : USER_FLAGS_SIZE;
127
128 /* linked list of userDatas for a chanData */
129 struct userData *prev;
130 struct userData *next;
131 /* linked list of userDatas for a handle_info */
132 struct userData *u_prev;
133 struct userData *u_next;
134 };
135
136 struct banData
137 {
138 char mask[NICKLEN + USERLEN + HOSTLEN + 3];
139 char owner[NICKLEN+1];
140 struct chanData *channel;
141
142 time_t set;
143 time_t triggered;
144 time_t expires;
145
146 char *reason;
147
148 struct banData *prev;
149 struct banData *next;
150 };
151
152 struct suspended
153 {
154 struct chanData *cData;
155 char *suspender;
156 char *reason;
157 time_t issued, expires, revoked;
158 struct suspended *previous;
159 };
160
161 struct do_not_register
162 {
163 char chan_name[CHANNELLEN+1];
164 char setter[NICKSERV_HANDLE_LEN+1];
165 time_t set;
166 char reason[1];
167 };
168
169 void init_chanserv(const char *nick);
170 void del_channel_user(struct userData *user, int do_gc);
171 struct channelList *chanserv_support_channels(void);
172 unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
173 struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
174 int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
175
176 void do_math(char *Buffer, char *Math);
177
178 #endif