ircinch 2.4.5 → 2.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +1 -1
  3. data/CHANGELOG.md +10 -0
  4. data/CODE_OF_CONDUCT.md +7 -81
  5. data/README.md +39 -30
  6. data/docs/bot_options.md +207 -314
  7. data/docs/changes.md +293 -282
  8. data/docs/common_mistakes.md +50 -41
  9. data/docs/common_tasks.md +63 -42
  10. data/docs/encodings.md +28 -55
  11. data/docs/events.md +123 -131
  12. data/docs/getting_started.md +97 -102
  13. data/docs/logging.md +62 -70
  14. data/docs/migrating.md +145 -131
  15. data/docs/plugins.md +109 -3
  16. data/docs/readme.md +17 -15
  17. data/examples/README.md +78 -0
  18. data/examples/basic/autovoice.rb +14 -18
  19. data/examples/basic/google.rb +9 -22
  20. data/examples/basic/hello.rb +4 -3
  21. data/examples/basic/join_part.rb +8 -23
  22. data/examples/basic/memo.rb +26 -24
  23. data/examples/basic/msg.rb +6 -6
  24. data/examples/basic/seen.rb +17 -24
  25. data/examples/basic/urban_dict.rb +6 -26
  26. data/examples/basic/url_shorten.rb +8 -26
  27. data/examples/plugins/autovoice.rb +17 -16
  28. data/examples/plugins/custom_prefix.rb +4 -3
  29. data/examples/plugins/dice_roll.rb +13 -20
  30. data/examples/plugins/google.rb +7 -21
  31. data/examples/plugins/hello.rb +4 -3
  32. data/examples/plugins/hooks.rb +5 -6
  33. data/examples/plugins/join_part.rb +8 -21
  34. data/examples/plugins/lambdas.rb +5 -6
  35. data/examples/plugins/last_nick.rb +7 -6
  36. data/examples/plugins/msg.rb +6 -6
  37. data/examples/plugins/multiple_matches.rb +10 -11
  38. data/examples/plugins/own_events.rb +14 -19
  39. data/examples/plugins/seen.rb +23 -23
  40. data/examples/plugins/timer.rb +5 -6
  41. data/examples/plugins/url_shorten.rb +15 -19
  42. data/examples/settings.rb +19 -0
  43. data/examples/tiny_url.rb +41 -0
  44. data/ircinch.gemspec +5 -6
  45. data/lib/cinch/bot.rb +2 -3
  46. data/lib/cinch/channel.rb +4 -4
  47. data/lib/cinch/message_queue.rb +2 -2
  48. data/lib/cinch/plugin.rb +1 -1
  49. data/lib/cinch/version.rb +1 -1
  50. metadata +270 -249
  51. data/lib/cinch/rubyext/float.rb +0 -5
data/docs/bot_options.md CHANGED
@@ -1,454 +1,347 @@
1
- # @title Bot options
2
- # @markup kramdown
1
+ # Bot Options
3
2
 
4
- # Options
3
+ Set options inside `bot.configure { |c| ... }`. Options below show the
4
+ defaults for this checkout. See the [configuration source](../lib/cinch/configuration/bot.rb)
5
+ and the [getting-started guide](getting_started.md) for a complete bot example.
5
6
 
6
- ## channels
7
- Type
8
- : Array<String>
7
+ ## `channels`
9
8
 
10
- Default value
11
- : `[]`
9
+ - **Type** `Array<String>`
10
+ - **Default** `[]`
12
11
 
13
- Description
14
- : Channels in this list will be joined upon connecting.
12
+ The bot joins these channels after registration, subject to [`delay_joins`](#delay_joins).
15
13
 
14
+ **Notes**
16
15
 
17
- ### Notes
18
- - To automatically join password-protected channels, just append the
19
- password to the channel's name, separated by a space, e.g.
20
- `"#mychannel mypassword"`.
16
+ - To join a keyed channel from a handler, call `bot.join(channel_name, key)`.
17
+ Keep channel keys outside the source file.
21
18
 
22
- ## dcc
19
+ ## `dcc`
23
20
 
24
- ### dcc.own_ip
25
- Type
26
- : String
21
+ ### `dcc.own_ip`
27
22
 
28
- Default value
29
- : `nil`
23
+ - **Type** `String`
24
+ - **Default** `nil`
30
25
 
31
- Description
32
- : The external IP which should be used for outgoing DCC SENDs. For
33
- more information see {Cinch::DCC::Outgoing::Send}.
26
+ The IP address advertised for outgoing DCC transfers. With `nil`, IRCinch
27
+ uses the local address of the IRC socket. The recipient needs to be able to
28
+ reach the advertised address and listening port. See [DCC file transfers](common_tasks.md#dcc-file-transfers).
34
29
 
35
- ## delay_joins
36
- Type
37
- : Number, Symbol
30
+ ## `default_logger_level`
38
31
 
39
- Default value
40
- : `0`
32
+ - **Type** `Symbol`
33
+ - **Default** `:debug`
41
34
 
42
- Description
43
- : Delay joining channels N seconds after connecting, or until the event S fires.
35
+ The initial level used when the bot constructs its default logger. That logger
36
+ is created before the bot's configuration block runs. Set `bot.loggers.first.level`
37
+ to change it on an existing bot. See [logger levels](logging.md#logger-levels).
44
38
 
45
- ### Notes
46
- - This is especially useful in combination with the /cinch-identify/ plugin, which will trigger the `:identified` event.
39
+ ## `delay_joins`
47
40
 
48
- ## encoding
49
- Type
50
- : String, Encoding
41
+ - **Type** `Numeric`, `Symbol`
42
+ - **Default** `0`
51
43
 
52
- Default value
53
- : `:irc`
44
+ With a number, wait that many seconds after IRC registration before joining
45
+ configured channels. With a symbol, join when that event first fires on the
46
+ connection.
54
47
 
55
- Description
56
- : This determines which encoding text received from IRC will have.
48
+ ## `encoding`
57
49
 
50
+ - **Type** `String`, `Encoding`, or `:irc`
51
+ - **Default** `:irc`
58
52
 
59
- ### Notes
60
- - {file:docs/encodings.md More information on how Cinch handles encoding issues}
53
+ Controls decoding of incoming text and encoding of outgoing text. See [Encodings](encodings.md).
61
54
 
62
- ## local_host
63
- Type
64
- : String
55
+ ## `local_host`
65
56
 
66
- Default value
67
- : `nil`
57
+ - **Type** `String`
58
+ - **Default** `nil`
68
59
 
69
- Description
70
- : Which IP/host to bind to when connecting. This is useful for using
71
- so called "vhosts".
60
+ The local address or hostname to bind when opening the IRC connection.
72
61
 
73
- ## max_messages
74
- Type
75
- : Fixnum
62
+ ## `max_messages`
76
63
 
77
- Default value
78
- : `nil`
64
+ - **Type** `Integer`
65
+ - **Default** `nil`
79
66
 
80
- Description
81
- : When an overlong message gets split, only `max_messages` parts will
82
- be sent to the recipient.
67
+ Maximum number of parts sent per input line. `nil` sends all parts.
83
68
 
69
+ ## `max_reconnect_delay`
84
70
 
85
- ### Notes
86
- - Set this option to `nil` to disable any limit.
71
+ - **Type** `Integer`
72
+ - **Default** `300`
87
73
 
88
- ## max_reconnect_delay
89
- Type
90
- : Fixnum
74
+ Maximum reconnect delay in seconds. After an unsuccessful connection attempt,
75
+ IRCinch doubles the wait up to this cap. A successful registration resets the
76
+ backoff.
91
77
 
92
- Default value
93
- : `300`
78
+ ## `messages_per_second`
94
79
 
95
- Descriptipn
96
- : With every unsuccessful reconnection attempt, Cinch increases the
97
- delay between new attempts. This setting is the maximum number of
98
- seconds to wait between two attempts.
80
+ - **Type** Positive `Numeric`
81
+ - **Default** `nil`
99
82
 
100
- ## messages_per_second
101
- Type
102
- : Float
83
+ Estimated rate at which the server processes messages sent by the bot. `nil`
84
+ uses the [network default](../lib/cinch/network.rb). This estimate controls
85
+ outgoing throttling together with [`server_queue_size`](#server_queue_size).
103
86
 
104
- Default value
105
- : Network dependent
87
+ **Notes**
106
88
 
107
- Description
108
- : How many incoming messages the server processes per second. This is
109
- used for throttling.
110
-
111
-
112
- ### Notes
113
89
  - If your bot gets kicked for excess flood, try lowering the value of
114
90
  `messages_per_second`.
115
- - See also: {file:docs/bot_options.md#serverqueuesize `server_queue_size`}
116
-
117
- ## message_split_end
118
- Type
119
- : String
91
+ - See also: [`server_queue_size`](#server_queue_size)
120
92
 
121
- Default value
122
- : `" ..."`
93
+ ## `message_split_end`
123
94
 
124
- Description
125
- : When a message is too long to be sent as a whole, it will be split
126
- and the value of this option will be appended to all but the last
127
- parts of the message.
95
+ - **Type** `String`
96
+ - **Default** `" ..."`
128
97
 
98
+ When a message is too long to be sent as a whole, it will be split
99
+ and the value of this option will be appended to all but the last
100
+ part. Use `nil` or `""` to omit the marker.
129
101
 
130
- ## message_split_start
131
- Type
132
- : String
102
+ ## `message_split_start`
133
103
 
134
- Default value
135
- : `"... "`
104
+ - **Type** `String`
105
+ - **Default** `"... "`
136
106
 
137
- Description
138
- : When a message is too long to be sent as a whole, it will be split
139
- and the value of this option will be prepended to all but the first
140
- parts of the message.
107
+ When a message is too long to be sent as a whole, it will be split
108
+ and the value of this option will be prepended to all but the first
109
+ part. Use `nil` or `""` to omit the marker.
141
110
 
142
- ## modes
143
- Type
144
- : Array<String>
111
+ ## `modes`
145
112
 
146
- Default value
147
- : []
113
+ - **Type** `Array<String>`
114
+ - **Default** `[]`
148
115
 
149
- Description
150
- : An array of modes the bot should set on itself after connecting.
116
+ User mode letters to set on the bot after registration, such as `["i"]`.
117
+ Set this with `c.modes = [...]` in a configuration block. The current
118
+ configuration class does not accept `:modes` through `[]` or `load`.
151
119
 
152
- ## nick
153
- Type
154
- : String
120
+ ## `nick`
155
121
 
156
- Default value
157
- : `"cinch"`
122
+ - **Type** `String`
123
+ - **Default** `"ircinch"`
158
124
 
159
- Description
160
- : The nickname the bot will use.
125
+ The nickname the bot will use.
161
126
 
127
+ **Notes**
162
128
 
163
- ### Notes
164
- - If the nickname is in use, Cinch will append underscores until it
129
+ - If the nickname is in use, IRCinch will append underscores until it
165
130
  finds a free nick.
166
131
  - You really should set this option instead of using the default.
167
132
 
168
- ## nicks
169
- Type
170
- : Array<String>
171
-
172
- Default value
173
- : `nil`
174
-
175
- Description
176
- : This option overrules {file:docs/bot_options.md#nick `nick`} and allows Cinch
177
- to try multiple nicks before adding underscores.
133
+ ## `nicks`
178
134
 
135
+ - **Type** `Array<String>`
136
+ - **Default** `nil`
179
137
 
180
- ## password
181
- Type
182
- : String
138
+ A nonempty list of preferred nicknames, tried in order before appending
139
+ underscores. With `nil`, the bot starts with [`nick`](#nick).
183
140
 
184
- Default value
185
- : `nil`
141
+ ## `password`
186
142
 
187
- Description
188
- : A server password for access to private servers.
143
+ - **Type** `String`
144
+ - **Default** `nil`
189
145
 
146
+ Password sent with the IRC `PASS` command. For account authentication on a
147
+ server that supports SASL, see [`sasl`](#sasl).
190
148
 
191
- ### Notes
192
- - Some networks allow you to use the server password for
193
- authenticating with services (e.g. NickServ).
149
+ ## `ping_interval`
194
150
 
151
+ - **Type** `Numeric`
152
+ - **Default** `120`
195
153
 
196
- ## ping_interval
197
- Type
198
- : Number
154
+ Interval in seconds between client `PING` commands.
199
155
 
200
- Default value
201
- : `120`
156
+ **Notes**
202
157
 
203
- Description
204
- : The server will be pinged every X seconds, to keep the connection
205
- alive.
206
-
207
-
208
- ### Notes
209
158
  - The ping interval should be smaller than
210
- {file:docs/bot_options.md#timeoutsread `timeouts.read`} to prevent Cinch from
159
+ [`timeouts.read`](#timeoutsread) to prevent IRCinch from
211
160
  falsely declaring a connection dead.
212
161
 
162
+ ## `plugins`
213
163
 
214
- ## plugins
164
+ ### `plugins.plugins`
215
165
 
216
- ### plugins.plugins
217
- Type
218
- : Array<Class>
166
+ - **Type** `Array<Class>`
167
+ - **Default** `[]`
219
168
 
220
- Default value
221
- : `[]`
169
+ A list of plugins to register.
222
170
 
223
- Description
224
- : A list of plugins to register.
171
+ **Notes**
225
172
 
226
-
227
- #### Notes
228
173
  - An example: `[Plugin1, Plugin2, Plugin3]` -- Note that we are adding
229
174
  the plugin **classes** to the list.
230
175
 
231
- ### plugins.prefix
232
- Type
233
- : String, Regexp, Lambda
234
-
235
- Default value
236
- : `/^!/`
176
+ ### `plugins.prefix`
237
177
 
238
- Description
239
- : A prefix that will be prepended to all plugin commands.
178
+ - **Type** `String`, `Regexp`, `Proc`, or `nil`
179
+ - **Default** `/^!/`
240
180
 
181
+ Default prefix for plugin matchers. See [matching messages](plugins.md#matching-messages)
182
+ for overrides and how strings and regular expressions are combined.
241
183
 
242
- ### plugins.suffix
243
- Type
244
- : String, Regexp, Lambda
184
+ ### `plugins.suffix`
245
185
 
246
- Default value
247
- : `nil`
186
+ - **Type** `String`, `Regexp`, `Proc`, or `nil`
187
+ - **Default** `nil`
248
188
 
249
- Description
250
- : A suffix that will be appended to all plugin commands.
189
+ Default suffix for plugin matchers.
251
190
 
191
+ ### `plugins.options`
252
192
 
193
+ - **Type** `Hash`
194
+ - **Default** `Hash.new {|h,k| h[k] = {}}`
253
195
 
254
- ### plugins.options
255
- Type
256
- : Hash
196
+ Options keyed by plugin class, with an empty hash for each class by default.
197
+ See [plugin configuration](plugins.md#configuration).
257
198
 
258
- Default value
259
- : `Hash.new {|h,k| h[k] = {}}`
199
+ ## `port`
260
200
 
261
- Description
262
- : Options specific to plugins.
201
+ - **Type** `Integer`
202
+ - **Default** `6667`
263
203
 
204
+ The port the IRC server is listening on. Set the server's TLS port when
205
+ enabling [`ssl.use`](#ssluse).
264
206
 
265
- #### Notes
266
- - Information on plugins and options for those will be made available
267
- in a separate document soon.
207
+ ## `realname`
268
208
 
209
+ - **Type** `String`
210
+ - **Default** `"ircinch"`
269
211
 
270
- ## port
271
- Type
272
- : Fixnum
212
+ The real name Cinch will connect with.
273
213
 
274
- Default value
275
- : `6667`
214
+ ## `reconnect`
276
215
 
277
- Description
278
- : The port the IRC server is listening on
216
+ - **Type** `Boolean`
217
+ - **Default** `true`
279
218
 
219
+ Retry after connection failures or disconnects. Calling `bot.quit` disables
220
+ reconnection for that run.
280
221
 
281
- ## realname
282
- Type
283
- : String
222
+ ## `sasl`
284
223
 
285
- Default value
286
- : `"cinch"`
224
+ Set the username and password for an IRC account on a server that advertises
225
+ SASL. Use TLS for `PLAIN`, which encodes the password without encrypting it.
226
+ See [`ssl`](#ssl) for IRCinch's TLS settings and verification behavior.
287
227
 
288
- Description
289
- : The real name Cinch will connect with.
228
+ ### `sasl.username`
290
229
 
291
- ## reconnect
292
- Type
293
- : Boolean
230
+ - **Type** `String`
231
+ - **Default** `nil`
294
232
 
295
- Default value
296
- : `true`
233
+ The username to use for SASL authentication.
297
234
 
298
- Description
299
- : Should Cinch attempt to reconnect after a connection loss?
235
+ ### `sasl.password`
300
236
 
301
- ## sasl
237
+ - **Type** `String`
238
+ - **Default** `nil`
302
239
 
303
- ### sasl.username
304
- Type
305
- : String
240
+ The password to use for SASL authentication.
306
241
 
307
- Default value
308
- : `nil`
242
+ ### `sasl.mechanisms`
309
243
 
310
- Description
311
- : The username to use for SASL authentication.
244
+ - **Type** `Array<Cinch::SASL::Mechanism>`
245
+ - **Default** `[Cinch::SASL::DhBlowfish, Cinch::SASL::Plain]`
312
246
 
313
- ### sasl.password
314
- Type
315
- : String
247
+ Mechanisms to try in order. The bot tries the next one when the server sends
248
+ numeric `904` (authentication failed). For a network using `PLAIN`, set this
249
+ to `[Cinch::SASL::Plain]`.
316
250
 
317
- Default value
318
- : `nil`
251
+ ## `server`
319
252
 
320
- Description
321
- : The password to use for SASL authentication.
253
+ - **Type** `String`
254
+ - **Default** `"localhost"`
322
255
 
323
- ### sasl.mechanisms
324
- Type
325
- : Array<Cinch::SASL::Mechanism>
256
+ The IRC server to connect to.
326
257
 
327
- Default value
328
- : `[Cinch::SASL::DhBlowfish, Cinch::SASL::Plain]`
258
+ ## `server_queue_size`
329
259
 
330
- Description
331
- : The SASL mechanisms to use. All mechanisms in the array will be
332
- attempted, until one was successful
260
+ - **Type** Positive `Integer`
261
+ - **Default** `nil`
333
262
 
334
- ## server
335
- Type
336
- : String
263
+ Estimated number of pending commands the server can queue for this connection.
264
+ `nil` uses the [network default](../lib/cinch/network.rb).
337
265
 
338
- Default value
339
- : `"localhost"`
266
+ **Notes**
340
267
 
341
- Description
342
- : The IRC server to connect to
343
-
344
-
345
- ## server_queue_size
346
- Type
347
- : Fixnum
348
-
349
- Default value
350
- : Network dependent
351
-
352
- Description
353
- : The number of incoming messages the server will queue, before
354
- killing the bot for excess flood.
355
-
356
-
357
- ### Notes
358
268
  - If your bot gets kicked for excess flood, try lowering the value of
359
269
  `server_queue_size`.
360
- - See also: {file:docs/bot_options.md#messagespersecond `messages_per_second`}
361
-
362
- ## ssl
363
-
364
- ### ssl.use
365
- Type
366
- : Boolean
270
+ - See also: [`messages_per_second`](#messages_per_second)
367
271
 
368
- Default value
369
- : `false`
272
+ ## `ssl`
370
273
 
371
- Description
372
- : Sets if SSL should be used
274
+ ### `ssl.use`
373
275
 
374
- ### ssl.verify
375
- Type
376
- : Boolean
276
+ - **Type** `Boolean`
277
+ - **Default** `false`
377
278
 
378
- Default value
379
- : `false`
279
+ Open the connection with TLS. Choose the network's TLS [`port`](#port) explicitly.
380
280
 
381
- Description
382
- : Sets if the SSL certificate should be verified
281
+ ### `ssl.verify`
383
282
 
283
+ - **Type** `Boolean`
284
+ - **Default** `false`
384
285
 
385
- ### ssl.ca_path
386
- Type
387
- : String
286
+ Enable verification of the server certificate chain. The current TLS
287
+ implementation does not check whether the certificate matches the server
288
+ hostname. See the [connection source](../lib/cinch/irc.rb) and
289
+ [Ruby OpenSSL documentation](https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#attribute-i-verify_hostname).
388
290
 
389
- Default value
390
- : `"/etc/ssl/certs"`
291
+ ### `ssl.ca_path`
391
292
 
392
- Description
393
- : The path to a directory with certificates. This has to be set
394
- properly for {file:docs/bot_options.md#sslverify `ssl.verify`} to work.
293
+ - **Type** `String`
294
+ - **Default** `"/etc/ssl/certs"`
395
295
 
296
+ The path to a directory with certificates. This has to be set
297
+ properly for [`ssl.verify`](#sslverify) to work.
396
298
 
397
- ### ssl.client_cert
398
- Type
399
- : String
299
+ ### `ssl.client_cert`
400
300
 
401
- Default value
402
- : `nil`
301
+ - **Type** `String`
302
+ - **Default** `nil`
403
303
 
404
- Description
405
- : The path to a client certificate, which some networks can use for
406
- authentication (see {http://www.oftc.net/oftc/NickServ/CertFP})
304
+ Path to a PEM file containing both the client certificate and its RSA private
305
+ key. Some networks use it for account authentication. See [OFTC’s CertFP guide](https://www.oftc.net/NickServ/CertFP/).
407
306
 
307
+ ## `shared`
408
308
 
409
- #### Notes
410
- - You will want to set the correct port when using SSL
309
+ - **Type** `Hash`
310
+ - **Default** `{}`
411
311
 
412
- ## user
413
- Type
414
- : String
312
+ Per-bot data accessible to plugin instances through `shared`. Use
313
+ `synchronize` for updates that can run in concurrent handlers.
415
314
 
416
- Default value
417
- : `"cinch"`
315
+ ## `strictness`
418
316
 
419
- Description
420
- : The user name to use when connecting to the IRC server.
317
+ - **Type** `:forgiving` or `:strict`
318
+ - **Default** `:forgiving`
421
319
 
422
- ## timeouts
320
+ In strict mode, changing the bot's nickname or a channel topic, or kicking
321
+ a user, raises an exception when the supplied value exceeds the server's
322
+ advertised limit. In forgiving mode the request goes to the server.
423
323
 
424
- ### timeouts.read
425
- Type
426
- : Number
324
+ ## `timeouts`
427
325
 
428
- Default value
429
- : `240`
326
+ ### `timeouts.read`
430
327
 
431
- Description
432
- : If no data has been received for this amount of seconds, the
433
- connection will be considered dead.
328
+ - **Type** `Numeric`
329
+ - **Default** `240`
434
330
 
331
+ Socket read timeout in seconds. An expired read closes the connection.
435
332
 
436
- ### timeouts.connect
437
- Type
438
- : Number
333
+ ### `timeouts.connect`
439
334
 
440
- Default value
441
- : `10`
335
+ - **Type** `Numeric`
336
+ - **Default** `10`
442
337
 
443
- Description
444
- : Give up connecting after this amount of seconds.
338
+ Timeout in seconds for opening the TCP socket. The TLS handshake follows
339
+ afterward.
445
340
 
446
- ## default_logger_level
447
- Type
448
- : Symbol
341
+ ## `user`
449
342
 
450
- Default value
451
- : `:debug`
343
+ - **Type** `String`
344
+ - **Default** `"ircinch"`
452
345
 
453
- Description
454
- : Modify the log level of the default logger, for instance, the bot will log very little if you set this value to `:fatal`.
346
+ The username sent with the IRC `USER` command. Set [`sasl.username`](#saslusername)
347
+ separately for SASL authentication.