1 /++
2     POD structs, broken out of [kameloso.kameloso] to avoid cyclic dependencies.
3 
4     See_Also:
5         [kameloso.kameloso]
6 
7     Copyright: [JR](https://github.com/zorael)
8     License: [Boost Software License 1.0](https://www.boost.org/users/license.html)
9 
10     Authors:
11         [JR](https://github.com/zorael)
12  +/
13 module kameloso.pods;
14 
15 private:
16 
17 public:
18 
19 
20 // CoreSettings
21 /++
22     Aggregate struct containing runtime bot setting variables.
23 
24     Kept inside one struct, they're nicely gathered and easy to pass around.
25     Some defaults are hardcoded here.
26  +/
27 struct CoreSettings
28 {
29 private:
30     import lu.uda : CannotContainComments, Hidden, Quoted, Unserialisable;
31 
32 public:
33     version(Colours)
34     {
35         // monochrome colours
36         /++
37             Logger monochrome setting.
38          +/
39         bool monochrome = false;
40     }
41     else
42     {
43         // monochrome non-colours
44         /++
45             Non-colours version defaults to true.
46          +/
47         bool monochrome = true;
48     }
49 
50     // brightTerminal
51     /++
52         Flag denoting that the terminal has a bright background.
53      +/
54     bool brightTerminal = false;
55 
56     // extendedColours
57     /++
58         Flag denoting that the bot should output text using extended ANSI sequences.
59      +/
60     bool extendedColours = true;
61 
62     // preferHostmasks
63     /++
64         Flag denoting that usermasks should be used instead of accounts to authenticate users.
65      +/
66     bool preferHostmasks = false;
67 
68     // hideOutgoing
69     /++
70         Whether or not to hide outgoing messages, not printing them to screen.
71      +/
72     bool hideOutgoing = false;
73 
74     // colouredOutgoing
75     /++
76         Whether or not to add colours to outgoing messages.
77      +/
78     bool colouredOutgoing = true;
79 
80     // extendedOutgoingColours
81     /++
82         Whether or not to add extended colours to outgoing messages.
83 
84         If false, only basic colours will be used.
85      +/
86     bool extendedOutgoingColours = true;
87 
88     // reexecToReconnect
89     /++
90         Re-executes the program instead of reconnecting hot.
91      +/
92     bool reexecToReconnect = false;
93 
94     // saveOnExit
95     /++
96         Flag denoting that we should save configuration changes to file on exit.
97      +/
98     bool saveOnExit = false;
99 
100     // exitSummary
101     /++
102         Whether or not to display a connection summary on program exit.
103      +/
104     bool exitSummary = false;
105 
106     @Hidden
107     {
108         // eagerLookups
109         /++
110             Whether to eagerly and exhaustively WHOIS all participants in home channels,
111             or to do a just-in-time lookup when needed.
112          +/
113         bool eagerLookups = false;
114 
115         // headless
116         /++
117             Whether or not to be "headless", disabling all terminal output.
118          +/
119         bool headless;
120     }
121 
122     // resourceDirectory
123     /++
124         Path to resource directory.
125      +/
126     @Hidden
127     @CannotContainComments
128     string resourceDirectory;
129 
130     // prefix
131     /++
132         Character(s) that prefix a bot chat command.
133 
134         These decide what bot commands will look like; "!" for "!command",
135         "~" for "~command", "." for ".command", etc. It can be any string and
136         not just one character.
137      +/
138     @Quoted string prefix = "!";
139 
140     @Unserialisable
141     {
142         // configFile
143         /++
144             Main configuration file.
145          +/
146         string configFile;
147 
148         // configDirectory
149         /++
150             Path to configuration directory.
151          +/
152         string configDirectory;
153 
154         // force
155         /++
156             Whether or not to force connecting, skipping some sanity checks.
157          +/
158         bool force;
159 
160         // flush
161         /++
162             Whether or not to explicitly set stdout to flush after writing a linebreak to it.
163          +/
164         bool flush;
165 
166         // trace
167         /++
168             Whether or not *all* outgoing messages should be echoed to the terminal.
169          +/
170         bool trace;
171 
172         // numericAddresses
173         /++
174             Whether to print addresses as IPs or as hostnames (where applicable).
175          +/
176         bool numericAddresses;
177 
178         // observerMode
179         /++
180             Enables observer mode, which makes the bot ignore all commands
181             (but process other events).
182          +/
183         bool observerMode;
184     }
185 }
186 
187 
188 // ConnectionSettings
189 /++
190     Aggregate of values used in the connection between the bot and the IRC server.
191  +/
192 struct ConnectionSettings
193 {
194 private:
195     import kameloso.constants : ConnectionDefaultFloats, Timeout;
196     import lu.uda : CannotContainComments, Hidden;
197 
198 public:
199     // ipv6
200     /++
201         Whether to connect to IPv6 addresses or only use IPv4 ones.
202      +/
203     bool ipv6 = true;
204 
205     @CannotContainComments
206     @Hidden
207     {
208         // privateKeyFile
209         /++
210             Path to private (`.pem`) key file, used in SSL connections.
211          +/
212         string privateKeyFile;
213 
214         // certFile
215         /++
216             Path to certificate (`.pem`) file.
217          +/
218         string certFile;
219 
220         // caBundleFile
221         /++
222             Path to certificate bundle `cacert.pem` file or equivalent.
223          +/
224         string caBundleFile;
225     }
226 
227     // ssl
228     /++
229         Whether or not to attempt an SSL connection.
230      +/
231     bool ssl = false;
232 
233     @Hidden
234     {
235         // receiveTimeout
236         /++
237             Socket receive timeout in milliseconds (how often to check for concurrency messages).
238          +/
239         uint receiveTimeout = Timeout.receiveMsecs;
240 
241         // messageRate
242         /++
243             How many messages to send per second, maximum.
244          +/
245         double messageRate = ConnectionDefaultFloats.messageRate;
246 
247         // messageBurst
248         /++
249             How many messages to immediately send in one go, before throttling kicks in.
250 
251          +/
252         double messageBurst = ConnectionDefaultFloats.messageBurst;
253     }
254 }
255 
256 
257 // IRCBot
258 /++
259     Aggregate of information relevant for an IRC *bot* that goes beyond what is
260     needed for a mere IRC *client*.
261  +/
262 struct IRCBot
263 {
264 private:
265     import lu.uda : CannotContainComments, Hidden, Separator, Unserialisable;
266 
267 public:
268     // account
269     /++
270         Username to use as services account login name.
271      +/
272     string account;
273 
274     @Hidden
275     @CannotContainComments
276     {
277         // password
278         /++
279             Password for services account.
280          +/
281         string password;
282 
283         // pass
284         /++
285             Login `PASS`, different from `SASL` and services.
286          +/
287         string pass;
288 
289         // quitReason
290         /++
291             Default reason given when quitting and not specifying a reason text.
292          +/
293         string quitReason;
294 
295         // partReason
296         /++
297             Default reason given when parting a channel and not specifying a reason text.
298          +/
299         string partReason;
300     }
301 
302     @Separator(",")
303     @Separator(" ")
304     {
305         // admins
306         /++
307             The nickname services accounts of administrators, in a bot-like context.
308          +/
309         string[] admins;
310 
311         // homeChannels
312         /++
313             List of home channels for the bot to operate in.
314          +/
315         @CannotContainComments
316         string[] homeChannels;
317 
318         // guestChannels
319         /++
320             Currently inhabited non-home guest channels.
321          +/
322         @CannotContainComments
323         string[] guestChannels;
324     }
325 
326     @Unserialisable
327     {
328         // hasGuestNickname
329         /++
330             Whether or not we connected without an explicit nickname, and a random
331             guest such was generated.
332          +/
333         bool hasGuestNickname;
334     }
335 }