ircinch 2.4.0

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 (105) hide show
  1. checksums.yaml +7 -0
  2. data/.standard.yml +3 -0
  3. data/CHANGELOG.md +298 -0
  4. data/CODE_OF_CONDUCT.md +84 -0
  5. data/Gemfile +5 -0
  6. data/LICENSE.txt +23 -0
  7. data/README.md +195 -0
  8. data/Rakefile +14 -0
  9. data/docs/bot_options.md +454 -0
  10. data/docs/changes.md +541 -0
  11. data/docs/common_mistakes.md +60 -0
  12. data/docs/common_tasks.md +57 -0
  13. data/docs/encodings.md +69 -0
  14. data/docs/events.md +273 -0
  15. data/docs/getting_started.md +184 -0
  16. data/docs/logging.md +90 -0
  17. data/docs/migrating.md +267 -0
  18. data/docs/plugins.md +4 -0
  19. data/docs/readme.md +20 -0
  20. data/examples/basic/autovoice.rb +32 -0
  21. data/examples/basic/google.rb +35 -0
  22. data/examples/basic/hello.rb +14 -0
  23. data/examples/basic/join_part.rb +35 -0
  24. data/examples/basic/memo.rb +39 -0
  25. data/examples/basic/msg.rb +15 -0
  26. data/examples/basic/seen.rb +37 -0
  27. data/examples/basic/urban_dict.rb +36 -0
  28. data/examples/basic/url_shorten.rb +36 -0
  29. data/examples/plugins/autovoice.rb +37 -0
  30. data/examples/plugins/custom_prefix.rb +22 -0
  31. data/examples/plugins/dice_roll.rb +38 -0
  32. data/examples/plugins/google.rb +36 -0
  33. data/examples/plugins/hello.rb +21 -0
  34. data/examples/plugins/hooks.rb +34 -0
  35. data/examples/plugins/join_part.rb +41 -0
  36. data/examples/plugins/lambdas.rb +35 -0
  37. data/examples/plugins/last_nick.rb +24 -0
  38. data/examples/plugins/msg.rb +21 -0
  39. data/examples/plugins/multiple_matches.rb +32 -0
  40. data/examples/plugins/own_events.rb +37 -0
  41. data/examples/plugins/seen.rb +44 -0
  42. data/examples/plugins/timer.rb +22 -0
  43. data/examples/plugins/url_shorten.rb +34 -0
  44. data/ircinch.gemspec +43 -0
  45. data/lib/cinch/ban.rb +53 -0
  46. data/lib/cinch/bot.rb +476 -0
  47. data/lib/cinch/cached_list.rb +21 -0
  48. data/lib/cinch/callback.rb +22 -0
  49. data/lib/cinch/channel.rb +465 -0
  50. data/lib/cinch/channel_list.rb +31 -0
  51. data/lib/cinch/configuration/bot.rb +50 -0
  52. data/lib/cinch/configuration/dcc.rb +18 -0
  53. data/lib/cinch/configuration/plugins.rb +43 -0
  54. data/lib/cinch/configuration/sasl.rb +21 -0
  55. data/lib/cinch/configuration/ssl.rb +21 -0
  56. data/lib/cinch/configuration/timeouts.rb +16 -0
  57. data/lib/cinch/configuration.rb +75 -0
  58. data/lib/cinch/constants.rb +535 -0
  59. data/lib/cinch/dcc/dccable_object.rb +39 -0
  60. data/lib/cinch/dcc/incoming/send.rb +149 -0
  61. data/lib/cinch/dcc/incoming.rb +3 -0
  62. data/lib/cinch/dcc/outgoing/send.rb +123 -0
  63. data/lib/cinch/dcc/outgoing.rb +3 -0
  64. data/lib/cinch/dcc.rb +14 -0
  65. data/lib/cinch/exceptions.rb +48 -0
  66. data/lib/cinch/formatting.rb +127 -0
  67. data/lib/cinch/handler.rb +120 -0
  68. data/lib/cinch/handler_list.rb +92 -0
  69. data/lib/cinch/helpers.rb +230 -0
  70. data/lib/cinch/i_support.rb +100 -0
  71. data/lib/cinch/irc.rb +924 -0
  72. data/lib/cinch/log_filter.rb +23 -0
  73. data/lib/cinch/logger/formatted_logger.rb +100 -0
  74. data/lib/cinch/logger/zcbot_logger.rb +26 -0
  75. data/lib/cinch/logger.rb +171 -0
  76. data/lib/cinch/logger_list.rb +88 -0
  77. data/lib/cinch/mask.rb +69 -0
  78. data/lib/cinch/message.rb +397 -0
  79. data/lib/cinch/message_queue.rb +104 -0
  80. data/lib/cinch/mode_parser.rb +78 -0
  81. data/lib/cinch/network.rb +106 -0
  82. data/lib/cinch/open_ended_queue.rb +26 -0
  83. data/lib/cinch/pattern.rb +66 -0
  84. data/lib/cinch/plugin.rb +517 -0
  85. data/lib/cinch/plugin_list.rb +40 -0
  86. data/lib/cinch/rubyext/float.rb +5 -0
  87. data/lib/cinch/rubyext/module.rb +28 -0
  88. data/lib/cinch/rubyext/string.rb +35 -0
  89. data/lib/cinch/sasl/dh_blowfish.rb +73 -0
  90. data/lib/cinch/sasl/diffie_hellman.rb +50 -0
  91. data/lib/cinch/sasl/mechanism.rb +8 -0
  92. data/lib/cinch/sasl/plain.rb +29 -0
  93. data/lib/cinch/sasl.rb +36 -0
  94. data/lib/cinch/syncable.rb +83 -0
  95. data/lib/cinch/target.rb +199 -0
  96. data/lib/cinch/timer.rb +147 -0
  97. data/lib/cinch/user.rb +489 -0
  98. data/lib/cinch/user_list.rb +89 -0
  99. data/lib/cinch/utilities/deprecation.rb +18 -0
  100. data/lib/cinch/utilities/encoding.rb +39 -0
  101. data/lib/cinch/utilities/kernel.rb +15 -0
  102. data/lib/cinch/version.rb +6 -0
  103. data/lib/cinch.rb +7 -0
  104. data/lib/ircinch.rb +7 -0
  105. metadata +205 -0
data/docs/changes.md ADDED
@@ -0,0 +1,541 @@
1
+ # @title What has changed?
2
+ # @markup kramdown
3
+
4
+ # What has changed in 2.2?
5
+
6
+ ## Getting rid of CP1252 in favour of UTF-8
7
+
8
+ In versions before 2.2, when using the `irc` encoding (the default),
9
+ Cinch would use CP1252 for outgoing messages, only falling back to
10
+ UTF-8 if a message wouldn't fit into CP1252. This is a so called
11
+ hybrid encoding, which is used by X-Chat and the like.
12
+
13
+ This encoding, however, is based on the state of 10 years ago, where
14
+ the most popular IRC clients, such as mIRC, weren't capable of
15
+ handling UTF-8. Nowadays, there are more clients that support UTF-8
16
+ than there are clients that can deal with this hybrid encoding, or
17
+ CP1252 itself. That's why, from now on, we will always use UTF-8.
18
+
19
+ If you depend on outgoing messages being encoded in CP1252, please see
20
+ {file:docs/encodings.md} on how to change the encoding.
21
+
22
+ ## API improvements
23
+
24
+ ### New methods
25
+
26
+ - {Cinch::Channel#remove} has been added to support the non-standard
27
+ REMOVE command, a friendlier alternative to kicking people.
28
+
29
+ - {Cinch::Helpers.sanitize} and {Cinch::Formatting.unformat} have been
30
+ added to help with removing unprintable characters and mIRC
31
+ formatting codes from strings.
32
+
33
+ ### Deprecated methods
34
+
35
+ In order to reduce the amount of aliases, the following ones have been
36
+ deprecated and will be removed in a future release:
37
+
38
+ - {Cinch::Channel#msg}
39
+ - {Cinch::Channel#privmsg}
40
+ - {Cinch::Target#msg}
41
+ - {Cinch::Target#privmsg}
42
+ - {Cinch::Target#safe_msg}
43
+ - {Cinch::Target#safe_privmsg}
44
+ - {Cinch::User#whois}
45
+ - {Cinch::Helpers#Color}
46
+
47
+ Additionally, the following method is deprecated and will be removed
48
+ in the future:
49
+
50
+ - {Cinch::Channel#to_str}
51
+
52
+ # What has changed in 2.1?
53
+ 1. Color stripping
54
+ 1. Per group hooks
55
+ 1. API improvements
56
+ 1. New methods
57
+ 1. Changed methods
58
+ 1. New aliases
59
+
60
+ ## Color stripping
61
+
62
+ The new method <del>`Cinch::Utilities::String.strip_colors`</del>
63
+ {Cinch::Formatting.unformat} allows removal of mIRC color codes from
64
+ messages.
65
+
66
+ Additionally, a new match option called `strip_colors` makes it
67
+ possible to automatically and temporarily strip color codes before
68
+ attempting to match a message.
69
+
70
+ ## Per group hooks
71
+
72
+ A new option `group` for hooks allows registering hooks for specific
73
+ groups.
74
+
75
+ ## API improvements
76
+
77
+ ### New methods
78
+
79
+ #### {Cinch::Bot}
80
+
81
+ - {Cinch::Bot#oper}
82
+
83
+ #### {Cinch::User}
84
+
85
+ - {Cinch::User#oper?}
86
+
87
+ #### {Cinch::Message}
88
+
89
+ - {Cinch::Message#action_reply}
90
+ - {Cinch::Message#safe_action_reply}
91
+
92
+ ### Changed methods
93
+
94
+ #### {Cinch::Handler}
95
+
96
+ - {Cinch::Handler#call} now returns the started thread.
97
+
98
+ #### {Cinch::HandlerList}
99
+
100
+ - {Cinch::HandlerList#dispatch} now returns the started threads.
101
+
102
+ ### New aliases
103
+
104
+ Due to some unfortunate naming mistakes in Cinch 2.0, Cinch 2.1 adds
105
+ several aliases. All of the new aliases deprecate the original method
106
+ names, which will be removed in Cinch 3.0.
107
+
108
+ #### {Cinch::User}
109
+ - {Cinch::User#monitored?} for {Cinch::User#monitored}
110
+ - {Cinch::User#synced?} for {Cinch::User#synced}
111
+
112
+
113
+
114
+ # What has changed in 2.0?
115
+ 1. Added support for SASL
116
+ 1. Added support for DCC SEND
117
+ 1. Added a fair scheduler for outgoing messages
118
+ 1. Added required plugin options
119
+ 1. Added support for colors/formatting
120
+ 1. Added network discovery
121
+ 1. Added match groups
122
+ 1. Added match options overwriting plugin options
123
+ 1. Added support for actions (/me)
124
+ 1. Added support for broken IRC networks
125
+ 1. Dynamic timers
126
+ 1. Reworked logging facilities
127
+ 1. API improvements
128
+ 1. Helper changes
129
+ 1. Added a Cinch::Target Target class
130
+ 1. Cinch::Constants
131
+ 1. New methods
132
+ 1. Removed/Renamed methods
133
+ 1. Handlers
134
+ 1. The Plugin class
135
+ 1. Channel/Target/User implement Comparable
136
+ 1. Renamed `*Manager` to `*List`
137
+ 1. New events
138
+
139
+ ## Added support for SASL
140
+
141
+ Cinch now supports authenticating to services via SASL. For more
142
+ information check {Cinch::SASL}.
143
+
144
+ ## Added support for DCC SEND
145
+
146
+ Support for sending and receiving files via DCC has been added to
147
+ Cinch. Check {Cinch::DCC} for more information.
148
+
149
+ ## Added a fair scheduler for outgoing messages
150
+ Cinch always provided sophisticated throttling to avoid getting kicked
151
+ due to _excess flood_. One major flaw, however, was that it used a
152
+ single FIFO for all messages, thus preferring early message targets
153
+ and penalizing later ones.
154
+
155
+ Now Cinch uses a round-robin approach, having one queue per message
156
+ target (channels and users) and one for generic commands.
157
+
158
+ ## Added required plugin options
159
+
160
+ Plugins can now require specific options to be set. If any of those
161
+ options are not set, the plugin will automatically refuse being
162
+ loaded.
163
+
164
+ This is useful for example for plugins that require API keys to
165
+ interact with web services.
166
+
167
+ The new attribute is called
168
+ {Cinch::Plugin::ClassMethods#required_options required_options}.
169
+
170
+ Example:
171
+
172
+ class MyPlugin
173
+ include Cinch::Plugin
174
+
175
+ set :required_options, [:foo, :bar]
176
+ # ...
177
+ end
178
+
179
+ # ...
180
+
181
+ bot.configure do |c|
182
+ c.plugins.plugins = [MyPlugin]
183
+ c.plugins.options[MyPlugin] = {:foo => 1}
184
+ end
185
+
186
+ # The plugin won't load because the option :bar is not set.
187
+ # Instead it will print a warning.
188
+
189
+ ## Added support for colors/formatting
190
+
191
+ A new {Cinch::Formatting module} and {Cinch::Helpers#Format helper}
192
+ for adding colors and formatting to messages has been added. See the
193
+ {Cinch::Formatting module's documentation} for more information on
194
+ usage.
195
+
196
+ ## Added support for network discovery
197
+
198
+ Cinch now tries to detect the network it connects to, including the
199
+ running IRCd. For most parts this is only interesting internally, but
200
+ if you're writing advanced plugins that hook directly into IRC and
201
+ needs to be aware of available features/quirks, check out
202
+ {Cinch::IRC#network} and {Cinch::Network}.
203
+
204
+ ## Reworked logging facilities
205
+
206
+ The logging API has been drastically improved. Check the
207
+ {file:docs/logging.md logging documentation} for more information.
208
+
209
+
210
+ ## Added match groups
211
+
212
+ A new option for matchers, `:group`, allows grouping multiple matchers
213
+ to a group. What's special is that in any group, only the first
214
+ matching handler will be executed.
215
+
216
+ Example:
217
+
218
+ class Foo
219
+ include Cinch::Plugin
220
+
221
+ match /foo (\d+)/, group: :blegh, method: :foo1
222
+ match /foo (.+)/, group: :blegh, method: :foo2
223
+ match /foo .+/, method: :foo3
224
+ def foo1(m, arg)
225
+ m.reply "foo1"
226
+ end
227
+
228
+ def foo2(m, arg)
229
+ m.reply "foo2"
230
+ end
231
+
232
+ def foo3(m)
233
+ m.reply "foo3"
234
+ end
235
+ end
236
+ # 02:05:39 dominikh │ !foo 123
237
+ # 02:05:40 cinch │ foo1
238
+ # 02:05:40 cinch │ foo3
239
+
240
+ # 02:05:43 dominikh │ !foo bar
241
+ # 02:05:44 cinch │ foo2
242
+ # 02:05:44 cinch │ foo3
243
+
244
+
245
+ ## Added match options overwriting plugin options
246
+
247
+ Matchers now have their own `:prefix`, `:suffix` and `:react_on`
248
+ options which overwrite plugin options for single matchers.
249
+
250
+
251
+ ## Added support for actions (/me)
252
+
253
+ A new event, {`:action`} has been added and can be used for matching
254
+ actions as follows:
255
+
256
+ match "kicks the bot", react_on: :action
257
+ def execute(m)
258
+ m.reply "Ouch!"
259
+ end
260
+
261
+ ## API improvements
262
+
263
+ ### Helper changes
264
+
265
+ The helper methods {Cinch::Helpers#User User()} and
266
+ {Cinch::Helpers#Channel Channel()} have been extracted from
267
+ {Cinch::Bot} and moved to {Cinch::Helpers their own module} which can
268
+ be reused in various places.
269
+
270
+ ### Added a {Cinch::Target Target} class
271
+
272
+ Since {Cinch::Channel} and {Cinch::User} share one common interface
273
+ for sending messages, it only makes sense to have a common base class.
274
+ {Cinch::Target This new class} takes care of sending messages and
275
+ removes this responsibility from {Cinch::Channel}, {Cinch::User} and
276
+ {Cinch::Bot}
277
+
278
+ ### {Cinch::Constants}
279
+
280
+ All constants for IRC numeric replies (`RPL_*` and `ERR_*`) have been
281
+ moved from {Cinch} to {Cinch::Constants}
282
+
283
+ ### New methods
284
+
285
+ #### {Cinch::Bot}
286
+
287
+ - {Cinch::Bot#channel_list}
288
+ - {Cinch::Bot#handlers}
289
+ - {Cinch::Bot#loggers}
290
+ - {Cinch::Bot#loggers=}
291
+ - {Cinch::Bot#modes}
292
+ - {Cinch::Bot#modes=}
293
+ - {Cinch::Bot#set_mode}
294
+ - {Cinch::Bot#unset_mode}
295
+ - {Cinch::Bot#user_list}
296
+
297
+ #### {Cinch::Channel}
298
+
299
+ - {Cinch::Channel#admins}
300
+ - {Cinch::Channel#half_ops}
301
+ - {Cinch::Channel#ops}
302
+ - {Cinch::Channel#owners}
303
+ - {Cinch::Channel#voiced}
304
+
305
+ #### {Cinch::Helpers}
306
+
307
+ - {Cinch::Helpers#Target} -- For creating a {Cinch::Target Target} which can receive messages
308
+ - {Cinch::Helpers#Timer} -- For creating new timers anywhere
309
+ - {Cinch::Helpers#rescue_exception} -- For rescueing and automatically logging an exception
310
+ - {Cinch::Helpers#Format} -- For adding colors and formatting to messages
311
+
312
+ ##### Logging shortcuts
313
+ - {Cinch::Helpers#debug}
314
+ - {Cinch::Helpers#error}
315
+ - {Cinch::Helpers#exception}
316
+ - {Cinch::Helpers#fatal}
317
+ - {Cinch::Helpers#incoming}
318
+ - {Cinch::Helpers#info}
319
+ - {Cinch::Helpers#log}
320
+ - {Cinch::Helpers#outgoing}
321
+ - {Cinch::Helpers#warn}
322
+
323
+ #### {Cinch::IRC}
324
+
325
+ - {Cinch::IRC#network}
326
+
327
+ #### {Cinch::Message}
328
+
329
+ - {Cinch::Message#action?}
330
+ - {Cinch::Message#action_message}
331
+ - {Cinch::Message#target}
332
+ - {Cinch::Message#time}
333
+
334
+ #### {Cinch::Plugin}
335
+
336
+ - {Cinch::Plugin#handlers}
337
+ - {Cinch::Plugin#timers}
338
+ - {Cinch::Plugin#unregister}
339
+
340
+ #### {Cinch::User}
341
+
342
+ - {Cinch::User#away}
343
+ - {Cinch::User#dcc_send} - See {Cinch::DCC::Outgoing::Send}
344
+ - {Cinch::User#match}
345
+ - {Cinch::User#monitor} - See {file:docs/common_tasks.md#checking-if-a-user-is-online Checking if a user is online}
346
+ - {Cinch::User#monitored}
347
+ - {Cinch::User#online?}
348
+ - {Cinch::User#unmonitor}
349
+
350
+ ### Handlers
351
+
352
+ Internally, Cinch uses {Cinch::Handler Handlers} for listening to and
353
+ matching events. In previous versions, this was hidden from the user,
354
+ but now they're part of the public API, providing valuable information
355
+ and the chance to {Cinch::Handler#unregister unregister handlers}
356
+ alltogether.
357
+
358
+ {Cinch::Bot#on} now returns the created handler and
359
+ {Cinch::Plugin#handlers} allows getting a plugin's registered
360
+ handlers.
361
+
362
+ ### Removed/Renamed methods
363
+ The following methods have been removed:
364
+
365
+ | Removed method | Replacement |
366
+ |----------------------------------------+---------------------------------------------------------------------------------|
367
+ | Cinch::Bot#halt | `next` or `break` (Ruby keywords) |
368
+ | Cinch::Bot#raw | {Cinch::IRC#send} |
369
+ | Cinch::Bot#msg | {Cinch::Target#msg} |
370
+ | Cinch::Bot#notice | {Cinch::Target#notice} |
371
+ | Cinch::Bot#safe_msg | {Cinch::Target#safe_msg} |
372
+ | Cinch::Bot#safe_notice | {Cinch::Target#safe_notice} |
373
+ | Cinch::Bot#action | {Cinch::Target#action} |
374
+ | Cinch::Bot#safe_action | {Cinch::Target#safe_action} |
375
+ | Cinch::Bot#dispatch | {Cinch::HandlerList#dispatch} |
376
+ | Cinch::Bot#register_plugins | {Cinch::PluginList#register_plugins} |
377
+ | Cinch::Bot#register_plugin | {Cinch::PluginList#register_plugin} |
378
+ | Cinch::Bot#logger | {Cinch::Bot#loggers} |
379
+ | Cinch::Bot#logger= | |
380
+ | Cinch::Bot#debug | {Cinch::LoggerList#debug} |
381
+ | Cinch::IRC#message | {Cinch::IRC#send} |
382
+ | Cinch::Logger::Logger#log_exception | {Cinch::Logger#exception} |
383
+ | Class methods in Plugin to set options | A new {Cinch::Plugin::ClassMethods#set set} method as well as attribute setters |
384
+
385
+
386
+ ### The Plugin class
387
+
388
+ The {Cinch::Plugin Plugin} class has been drastically improved to look
389
+ and behave more like a proper Ruby class instead of being some
390
+ abstract black box.
391
+
392
+ All attributes of a plugin (name, help message, matchers, …) are being
393
+ made available via attribute getters and setters. Furthermore, it is
394
+ possible to access a Plugin instance's registered handlers and timers,
395
+ as well as unregister plugins.
396
+
397
+ For a complete overview of available attributes and methods, see
398
+ {Cinch::Plugin} and {Cinch::Plugin::ClassMethods}.
399
+
400
+ ### Plugin options
401
+
402
+ The aforementioned changes also affect the way plugin options are
403
+ being set: Plugin options aren't set with DSL-like methods anymore but
404
+ instead are made available via {Cinch::Plugin::ClassMethods#set a
405
+ `set` method} or alternatively plain attribute setters.
406
+
407
+ See
408
+ {file:docs/migrating.md#plugin-options the migration guide} for more
409
+ information.
410
+
411
+ ### Channel/Target/User implement Comparable
412
+
413
+ {Cinch::Target} and thus {Cinch::Channel} and {Cinch::User} now
414
+ implement the Comparable interface, which makes them sortable by all
415
+ usual Ruby means.
416
+
417
+ ### Renamed `*Manager` to `*List`
418
+
419
+ `Cinch::ChannelManager` and `Cinch::UserManager` have been renamed to
420
+ {Cinch::ChannelList} and {Cinch::UserList} respectively.
421
+
422
+ ## Added support for broken IRC networks
423
+ Special support for the following flawed IRC networks has been added:
424
+
425
+ - JustinTV
426
+ - NGameTV
427
+ - IRCnet
428
+
429
+ ## Dynamic timers
430
+
431
+ It is now possible to create new timers from any method/handler. It is
432
+ also possible to {Cinch::Timer#stop stop existing timers} or
433
+ {Cinch::Timer#start restart them}.
434
+
435
+ The easiest way of creating new timers is by using the
436
+ {Cinch::Helpers#Timer Timer helper method}, even though it is also
437
+ possible, albeit more complex, to create instances of {Cinch::Timer}
438
+ directly.
439
+
440
+ Example:
441
+
442
+ match /remind me in (\d+) seconds/
443
+ def execute(m, seconds)
444
+ Timer(seconds.to_i, shots: 1) do
445
+ m.reply "This is your reminder.", true
446
+ end
447
+ end
448
+
449
+ For more information on timers, see the {Cinch::Timer Timer documentation}.
450
+
451
+ ## New options
452
+
453
+ - :{file:docs/bot_options.md#dccownip dcc.own_ip}
454
+ - :{file:docs/bot_options.md#modes modes}
455
+ - :{file:docs/bot_options.md#maxreconnectdelay max_reconnect_delay}
456
+ - :{file:docs/bot_options.md#localhost local_host}
457
+ - :{file:docs/bot_options.md#delayjoins delay_joins}
458
+ - :{file:docs/bot_options.md#saslusername sasl.username}
459
+ - :{file:docs/bot_options.md#saslpassword sasl.password}
460
+
461
+ ## New events
462
+ - :{file:docs/events.md#action action}
463
+ - :{file:docs/events.md#away away}
464
+ - :{file:docs/events.md#unaway unaway}
465
+ - :{file:docs/events.md#dccsend dcc_send}
466
+ - :{file:docs/events.md#owner owner}
467
+ - :{file:docs/events.md#dehalfop-deop-deowner-devoice deowner}
468
+ - :{file:docs/events.md#leaving leaving}
469
+ - :{file:docs/events.md#online online}
470
+ - :{file:docs/events.md#offline offline}
471
+
472
+
473
+ # What has changed in 1.1?
474
+ 1. **New events**
475
+ 2. **New methods**
476
+ 3. **New options**
477
+ 4. **Improved logger**
478
+ x. **Deprecated methods**
479
+
480
+ ## New events
481
+
482
+ - :{file:docs/events.md#op op}
483
+ - :{file:docs/events.md#dehalfop-deop-deowner-devoice deop}
484
+ - :{file:docs/events.md#voice voice}
485
+ - :{file:docs/events.md#dehalfop-deop-deowner-devoice devoice}
486
+ - :{file:docs/events.md#halfop halfop}
487
+ - :{file:docs/events.md#dehalfop-deop-deowner-devoice dehalfop}
488
+ - :{file:docs/events.md#ban ban}
489
+ - :{file:docs/events.md#unban unban}
490
+ - :{file:docs/events.md#modechange mode_change}
491
+ - :{file:docs/events.md#catchall catchall}
492
+
493
+ Additionally, plugins are now able to send their own events by using
494
+ Cinch::Bot#dispatch.
495
+
496
+ ## New methods
497
+
498
+ ### {Cinch::User#last_nick}
499
+ Stores the last nick of a user. This can for example be used in `on
500
+ :nick` to compare a user's old nick against the new one.
501
+
502
+ ### Cinch::User#notice, Cinch::Channel#notice and Cinch::Bot#notice
503
+ For sending notices.
504
+
505
+ ### {Cinch::Message#to_s}
506
+ Provides a nicer representation of {Cinch::Message} objects.
507
+
508
+ ### {Cinch::Channel#has_user?}
509
+ Provides an easier way of checking if a given user is in a channel
510
+
511
+ ## New options
512
+ - {file:docs/bot_options.md#pluginssuffix plugins.suffix}
513
+ - {file:docs/bot_options.md#ssluse ssl.use}
514
+ - {file:docs/bot_options.md#sslverify ssl.verify}
515
+ - {file:docs/bot_options.md#sslcapath ssl.ca_path}
516
+ - {file:docs/bot_options.md#sslclientcert ssl.client_cert}
517
+ - {file:docs/bot_options.md#nicks nicks}
518
+ - {file:docs/bot_options.md#timeoutsread timeouts.read}
519
+ - {file:docs/bot_options.md#timeoutsconnect timeouts.connect}
520
+ - {file:docs/bot_options.md#pinginterval ping_interval}
521
+ - {file:docs/bot_options.md#reconnect reconnect}
522
+
523
+
524
+
525
+ ## Improved logger
526
+ The {Cinch::Logger::FormattedLogger formatted logger} (which is the
527
+ default one) now contains timestamps. Furthermore, it won't emit color
528
+ codes if not writing to a TTY.
529
+
530
+ Additionally, it can now log any kind of object, not only strings.
531
+
532
+ ## Deprecated methods
533
+
534
+ | Deprecated method | Replacement |
535
+ |-----------------------------+------------------------------------|
536
+ | Cinch::User.find_ensured | Cinch::UserManager#find_ensured |
537
+ | Cinch::User.find | Cinch::UserManager#find |
538
+ | Cinch::User.all | Cinch::UserManager#each |
539
+ | Cinch::Channel.find_ensured | Cinch::ChannelManager#find_ensured |
540
+ | Cinch::Channel.find | Cinch::ChannelManager#find |
541
+ | Cinch::Channel.all | Cinch::ChannelManager#each |
@@ -0,0 +1,60 @@
1
+ # @title Common mistakes
2
+ # @markup kramdown
3
+
4
+ # I defined an initialize method in my plugin and now it doesn't work properly anymore
5
+
6
+ Cinch requires plugins to set certain states for them to work
7
+ properly. This is done by the initialize method of the Plugin module.
8
+ If you define your own initializer, make sure to accept an arbitrary
9
+ number of arguments (`*args`) and to call `super` as soon as possible.
10
+
11
+ ## Example
12
+
13
+ class MyPlugin
14
+ include Cinch::Plugin
15
+
16
+ def initialize(*args)
17
+ super
18
+ my own stuff here
19
+ end
20
+ end
21
+
22
+
23
+ # I am trying to use plugin options, but Ruby says it cannot find the `config` method
24
+
25
+ A common mistake is to try and use plugin options on class level, for example to manipulate matches. This cannot work because the class itself is not connected to any bot. Plugin options only work in instance methods of plugins.
26
+
27
+ The following is not possible:
28
+
29
+ class MyPlugin
30
+ include Cinch::Plugin
31
+
32
+ match(config[:pattern])
33
+ def execute(m)
34
+ # ...
35
+ end
36
+ end
37
+
38
+ # My handlers won't run, even though the Regexp matches.
39
+
40
+ Cinch plugins have a default prefix (`/^!/`). This allows for flexible prefixes
41
+ across the whole bot. The default prefix can be changed in `Bot#configure`:
42
+
43
+ x = Cinch::Bot.new do
44
+ configure do |c|
45
+ # ...
46
+ c.plugins.prefix = /^%/
47
+ end
48
+ end
49
+
50
+ Alternatively, you can set the prefix for specific plugins only, by calling `set`:
51
+
52
+ class MyPlygin
53
+ include Cinch::Plugin
54
+
55
+ set :prefix, /^%/
56
+ end
57
+
58
+ You can also choose to not use a prefix for specific matchers:
59
+
60
+ match /hi/, use_prefix: false
@@ -0,0 +1,57 @@
1
+ # @title Common Tasks
2
+ # @markup kramdown
3
+
4
+ # Checking if a user is online
5
+
6
+ Cinch by itself tries to keep track of the online state of users.
7
+ Whenever it sees someone speak, change their nick or be in a channel the
8
+ bot is also in, it'll set the user to being online. And when a user
9
+ quits, gets killed or cannot be whoised/contacted, its state will be
10
+ set to offline.
11
+
12
+ A problem with that information is that it can quickly become out of
13
+ sync. Consider the following example:
14
+
15
+ The bot joins a channel, sees someone in the name list and thus marks
16
+ him as online. The bot then leaves the channel and at some later
17
+ point, the user disconnects. The bot won't know that and still track
18
+ the user as online.
19
+
20
+ If (near-)realtime information about this state is required, one can
21
+ use {Cinch::User#monitor} to automatically monitor the state.
22
+ {Cinch::User#monitor #monitor} uses either the _MONITOR_ feature of modern IRCds or, if
23
+ that's not available, periodically runs _WHOIS_ to update the
24
+ information.
25
+
26
+ Whenever a user's state changes, either the `:online` or the
27
+ `:offline` event will be fired, as can be seen in the following
28
+ example:
29
+
30
+ class SomePlugin
31
+ include Cinch::Plugin
32
+
33
+ listen_to :connect, method: :on_connect
34
+ listen_to :online, method: :on_online
35
+ listen_to :offline, method: :on_offline
36
+
37
+ def on_connect(m)
38
+ User("my_master").monitor
39
+ end
40
+
41
+ def on_online(m, user)
42
+ user.send "Hello master"
43
+ end
44
+
45
+ def on_offline(m, user)
46
+ @bot.loggers.info "I miss my master :("
47
+ end
48
+ end
49
+
50
+ # Sending messages to users and channels beside `m.user` and `m.channel`
51
+
52
+ Cinch provides {Cinch::Helpers helper methods} to get instances of Channel
53
+ and User objects that you can work with:
54
+
55
+ User('user').send("Hello!") # Sends a message to user 'user'
56
+ Channel('#channel').send("Hello!") # Sends a message to channel '#channel'
57
+