Directly take a Mask instead of a String in BanEntry
[clinton/bobotpp.git] / source / Channel.H
1 // Channel.H -*- C++ -*-
2 // Copyright (c) 1997, 1998 Etienne BERNARD
3 // Copyright (C) 2002 Clinton Ebadi
4
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // any later version.
9
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19
20 #ifndef CHANNEL_H
21 #define CHANNEL_H
22
23 #include <ctime>
24 #include <map>
25 #include <vector>
26
27 #include "String.H"
28
29 class BanEntry;
30 class Bot;
31 class Commands;
32 class Parser;
33 class Person;
34 class ServerConnection;
35 class User;
36 class UserCommands;
37 class UserList;
38
39
40 #define DEFAULT_KEEPMODES "iklmnpst"
41
42 // This struct is used to keep information about
43 // the channel we want to join, the modes we
44 // want to set/keep on these channels, and the
45 // channel keys
46 struct wantedChannel {
47 String mode;
48 String keep;
49 String key;
50
51 wantedChannel(String m, String kp, String ky)
52 : mode(m), keep(kp), key(ky) { }
53 };
54
55 class Channel {
56 String channelName;
57 String channelTopic;
58 bool lockedTopic;
59 int channelMode;
60 int channelLimit;
61 String channelKey;
62 String keepModes;
63 String wantedModes;
64
65 int count;
66 int countOp;
67 bool joined;
68 bool doMode;
69 bool gotWho;
70 std::map<String, User *, std::less<String> > channelMemory;
71 std::vector<BanEntry *> channelBanlist;
72 ServerConnection * cnx;
73
74 public:
75
76 enum {
77 PRIVATE = 1, // +p
78 SECRET = 2, // +s
79 INVITE_ONLY = 4, // +i
80 TOPIC_RESTRICTED = 8, // +t
81 EXTMSG_RESTRICTED = 16, // +n
82 MODERATED = 32, // +m
83 HAS_KEY = 64, // +k <key>
84 IS_LIMITED = 128 // +l <limit>
85 };
86
87 Channel(ServerConnection *, String, String);
88 ~Channel();
89
90 void addNick(String, String, int, UserList *, bool = false);
91 void delNick(String);
92 void changeNick(String, String);
93 bool hasNick(String);
94 User * getUser(String);
95
96 void addBan(String, std::time_t = -1);
97 void delBan(String);
98
99 void parseMode(Person *, String);
100 void resynchModes();
101
102 friend class Bot;
103 friend class Parser;
104 friend class Commands;
105 friend class UserCommands;
106 };
107
108 #endif