iirc 0.4.0 → 0.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89d3e4727f759400cf52bf6a8cb23b365d62259ef32fd977c6fcaab0d542fa53
4
- data.tar.gz: fc476e509a2ca6e620d6b93bbde705113136926e574860b05bc5508c332f8e51
3
+ metadata.gz: 2e4ac6446425ac435d2277035d20421968eb778ba3ff980adc1a81a77e9822ef
4
+ data.tar.gz: 4c19e2b02319359014d0d9f14a5a9d1f757a948bac14bcc5152635dbb7412e50
5
5
  SHA512:
6
- metadata.gz: c9cbf42882b4aeb2ae080266750d540d5f834a6c55be22d8b75541c7ca4b521492eacae055c21a3bdb716ca691e3db8a685c79d918c353df324ed8f42b9f168d
7
- data.tar.gz: 98d82cf28be02e06e32dd8c6978eb0470ca486c6b9f898fb0642e244e2edbaa99f2c0df9aa9fc4491610968d72736cfae05aba8dfddd1fe04fcdf72681389503
6
+ metadata.gz: 1db175bc3db1cbc464652f8ba5e7153e087851bc803adccd4d8434420095d0431f4e41b2ff31122333ba29895d7c66f609ea3d11d6f7d76f1b0024dbbc55d8f4
7
+ data.tar.gz: a759db9e4264a582b373bc708948330ea58a26639e66e9610cc9258e3965f810de0101ad97acb6ca095c4a926de4899526e64cc53f46391b0ae91006a8b03114
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup=markdown --private --protected
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [0.4.1] - 2022-03-29
2
+
3
+ - [ISupport] Add module to process RPL_ISUPPORT
4
+ - [ISupport] Add Inquiry helpers + docs
5
+
1
6
  ## [0.4.0] - 2022-03-27
2
7
 
3
8
  - [Numerics] Add module with constants imported from ircdocs.horse
data/Gemfile CHANGED
@@ -8,3 +8,6 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  gem "minitest", "~> 5.0"
11
+
12
+ gem "redcarpet", "= 3.5.1" # for Markdown docs (README.md)
13
+ gem "yard"
data/README.md CHANGED
@@ -1,8 +1,26 @@
1
1
  # Lean, mean IRC processing machine
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/iirc`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ ```ruby
4
+ require 'iirc'
5
+
6
+ class CoolBot < IIRC::IRCv3Bot
7
+ include Verbs
8
+
9
+ def configure_coolness
10
+ on /^!poke/, :poke_back
11
+ end
4
12
 
5
- TODO: Delete this and the text above, and describe your gem
13
+ def poke_back(evt)
14
+ act "pokes #{evt.sender.nick} back!!!"
15
+ end
16
+
17
+ def autojoin_channels
18
+ ['##coolness']
19
+ end
20
+ end
21
+
22
+ CoolBot.run 'irc.libera.chat' if __FILE__ == $0
23
+ ```
6
24
 
7
25
  ## Installation
8
26
 
@@ -22,7 +40,7 @@ Or install it yourself as:
22
40
 
23
41
  ## Usage
24
42
 
25
- TODO: Write usage instructions here
43
+ TODO: Flesh out usage instructions here
26
44
 
27
45
  ## Development
28
46
 
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IIRC
4
+ # Parses RPL_ISUPPORT (005) events into a Hash.
5
+ #
6
+ # These are sent by servers after registration to provide info about the network,
7
+ # what the server supports, and how it behaves.
8
+ #
9
+ # Provides a Hash of the raw values, extended with helper methods which process them.
10
+ #
11
+ # @see https://defs.ircdocs.horse/defs/isupport.html List of tokens and their values (defs.ircdocs.horse)
12
+ # @see https://datatracker.ietf.org/doc/html/draft-hardy-irc-isupport-00
13
+ # @see https://datatracker.ietf.org/doc/html/draft-brocklesby-irc-isupport-00
14
+ module Bot::ISupport
15
+ # Hash of tokens sent by the server after registration indicating feature support and limits.
16
+ # @return [Hash#extend(Inquiry)] the raw isupport key=>value pairs. keys with no value are assigned +true+.
17
+ def isupport
18
+ @isupport ||= {}.extend(Inquiry)
19
+ end
20
+
21
+ private
22
+ def configure_isupport
23
+ on :'005', :store_isupport
24
+ end
25
+
26
+ def store_isupport(evt)
27
+ tokens = evt.args[1..-2]
28
+
29
+ for token in tokens
30
+ name, value = token.split('=', 2)
31
+ isupport[name] = value.freeze || true
32
+ end
33
+ end
34
+ end
35
+
36
+ # Methods for inquiry into a Hash of raw ISUPPORT key=>value pairs.
37
+ # These are mixed in to the Hash returned by {ISupport#isupport}.
38
+ #
39
+ # The key=>value format returned by #isupport won't change.
40
+ # Rather, methods which process the values can be added here.
41
+ module Bot::ISupport::Inquiry
42
+ # Whether or not the server supports a user mode which lets clients mark themselves as bots.
43
+ def bot_mode?
44
+ !!bot_mode
45
+ end
46
+
47
+ # User mode which can be used to mark clients as bots.
48
+ # @return [String] mode char (usually 'B')
49
+ # @return [nil] if mode is not supported
50
+ def bot_mode
51
+ self['BOT']
52
+ end
53
+
54
+ # A string indicating the case mapping used by the server to determine case-insensitive equality
55
+ # of channel names and nick names.
56
+ #
57
+ # @note IIRC does not currently perform case-insensitive comparisons. This may change in future.
58
+ # @return [String] the name of the casemapping. e.g. 'ascii', 'rfc1459', 'rfc3454'
59
+ def case_mapping
60
+ self['CASEMAPPING']
61
+ end
62
+
63
+ # Characters used as channel prefixes by this server.
64
+ # @see https://defs.ircdocs.horse/defs/chantypes.html
65
+ # @return [Array] prefixes, e.g. ['#', '&']
66
+ def channel_prefixes
67
+ (@channel_prefixes ||= self['CHANTYPES']&.chars.freeze) || ['#'].freeze
68
+ end
69
+ end
70
+ end
@@ -1,15 +1,11 @@
1
1
  module IIRC
2
2
  module Bot::Members
3
- def self.configure_actions
4
- [:listen_for_names]
5
- end
6
-
7
3
  def members
8
4
  @members ||= {}
9
5
  end
10
6
 
11
7
  private
12
- def listen_for_names
8
+ def configure_members_tracking
13
9
  on :'353', :receive_names
14
10
  on :'366', :receive_names_end
15
11
  end
data/lib/iirc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IIRC
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
data/lib/iirc.rb CHANGED
@@ -14,6 +14,7 @@ require_relative "iirc/bot/channels"
14
14
  require_relative "iirc/bot/configure"
15
15
  require_relative "iirc/bot/formatting"
16
16
  require_relative "iirc/bot/hooks"
17
+ require_relative "iirc/bot/isupport"
17
18
  require_relative "iirc/bot/members"
18
19
  require_relative "iirc/bot/oper_up"
19
20
  require_relative "iirc/bot/parsing"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iirc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mooff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-27 00:00:00.000000000 Z
11
+ date: 2022-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ircparser
@@ -33,6 +33,7 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - ".github/workflows/main.yml"
35
35
  - ".gitignore"
36
+ - ".yardopts"
36
37
  - CHANGELOG.md
37
38
  - Gemfile
38
39
  - LICENSE
@@ -57,6 +58,7 @@ files:
57
58
  - lib/iirc/bot/ircv3/caps.rb
58
59
  - lib/iirc/bot/ircv3/labeled_requests.rb
59
60
  - lib/iirc/bot/ircv3/parsing.rb
61
+ - lib/iirc/bot/isupport.rb
60
62
  - lib/iirc/bot/members.rb
61
63
  - lib/iirc/bot/oper_up.rb
62
64
  - lib/iirc/bot/parsing.rb