iirc 0.3.0 → 0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/Rakefile +59 -0
- data/lib/iirc/bot/ambient.rb +46 -45
- data/lib/iirc/bot.rb +1 -1
- data/lib/iirc/numerics.rb +1252 -0
- data/lib/iirc/version.rb +1 -1
- data/lib/iirc.rb +8 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89d3e4727f759400cf52bf6a8cb23b365d62259ef32fd977c6fcaab0d542fa53
|
4
|
+
data.tar.gz: fc476e509a2ca6e620d6b93bbde705113136926e574860b05bc5508c332f8e51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9cbf42882b4aeb2ae080266750d540d5f834a6c55be22d8b75541c7ca4b521492eacae055c21a3bdb716ca691e3db8a685c79d918c353df324ed8f42b9f168d
|
7
|
+
data.tar.gz: 98d82cf28be02e06e32dd8c6978eb0470ca486c6b9f898fb0642e244e2edbaa99f2c0df9aa9fc4491610968d72736cfae05aba8dfddd1fe04fcdf72681389503
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,28 @@
|
|
1
|
+
## [0.4.0] - 2022-03-27
|
2
|
+
|
3
|
+
- [Numerics] Add module with constants imported from ircdocs.horse
|
4
|
+
- Run `rake numerics` to re-import.
|
5
|
+
|
6
|
+
- [IIRC.run,IIRC.dial] Support passing a symbol as ssl_context
|
7
|
+
- e.g. ssl_context: :no_verify instead of ssl_context: IIRC::SSL.no_verify
|
8
|
+
|
9
|
+
- The AmbientEvents modules have been reorganised
|
10
|
+
- AmbientVerbs is now Ambient::Verbs
|
11
|
+
- AmbientEvents => Ambient::Events
|
12
|
+
- AmbientEvents::{LabeledRequests,ReplyTarget} => Ambient::{LabeledRequests,ReplyTarget}
|
13
|
+
|
14
|
+
- #ambient_reply_target() has been replaced with #reply_target(evt=ambient_event)
|
15
|
+
|
16
|
+
- [Bot.run] Set nick to class name if no param is given
|
17
|
+
- `MyBot.run('irc.libera.chat')` is enough to connect to Libera as 'MyBot'
|
18
|
+
|
1
19
|
## [0.3.0] - 2022-03-26
|
2
20
|
|
3
21
|
- [Bot] Include ReplyTarget
|
4
22
|
- [Hooks] Refactor
|
5
23
|
- Add AcceptInvites module
|
6
24
|
- Improve Greeter example
|
25
|
+
- [IIRC.run,IIRC.dial] now accept local_host, local_port keyword arguments
|
7
26
|
|
8
27
|
## [0.2.9] - 2022-03-24
|
9
28
|
|
data/Rakefile
CHANGED
@@ -15,4 +15,63 @@ RDoc::Task.new do |rd|
|
|
15
15
|
rd.options = ["--all"]
|
16
16
|
end
|
17
17
|
|
18
|
+
task :numerics do
|
19
|
+
require 'yaml'
|
20
|
+
require 'open-uri'
|
21
|
+
|
22
|
+
data = YAML.load URI.open('https://raw.githubusercontent.com/ircdocs/irc-defs/gh-pages/_data/numerics.yaml')
|
23
|
+
revision = data['file']['revision']
|
24
|
+
|
25
|
+
puts "Loaded numerics.yaml revision #{revision}"
|
26
|
+
|
27
|
+
open(File.join(__dir__, 'lib/iirc/numerics.rb'), 'w+') do |out|
|
28
|
+
out << <<~HEADER
|
29
|
+
module IIRC
|
30
|
+
# Definitions imported from ircdocs.horse
|
31
|
+
# @version #{revision}
|
32
|
+
# @see https://raw.githubusercontent.com/ircdocs/irc-defs/gh-pages/_data/numerics.yaml
|
33
|
+
# @see https://defs.ircdocs.horse/defs/numerics.html
|
34
|
+
module Numerics
|
35
|
+
HEADER
|
36
|
+
|
37
|
+
values = data['values'].reject { |v| v['obsolete'] }
|
38
|
+
counts = values.map { |v| v['name'] }.tally
|
39
|
+
|
40
|
+
constants = {}
|
41
|
+
|
42
|
+
for row in values
|
43
|
+
out << " # #{row['comment'].squeeze(' ').tr("\r", '').gsub("\n", ' ').strip}\n" if row['comment']
|
44
|
+
out << " # @format #{row['numeric']} #{row['format'].strip}\n" if row['format']
|
45
|
+
|
46
|
+
name = row['name']
|
47
|
+
if counts[name] > 1 and row['origin']
|
48
|
+
name += '_' + row['origin'].gsub(/[^[:alnum:]]/, '_').gsub(/_{2,}/, '_').sub(/_$/, '').upcase
|
49
|
+
end
|
50
|
+
if constants[name]
|
51
|
+
name += '_ALT'
|
52
|
+
if constants[name]
|
53
|
+
fail <<~MSG
|
54
|
+
Couldn't derive a unique name for #{name}.
|
55
|
+
Previous source: #{constants[name].inspect}
|
56
|
+
MSG
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
constants[name] = row
|
61
|
+
|
62
|
+
out << " #{name} = #{row['numeric'].to_sym.inspect}"
|
63
|
+
out << "\n"
|
64
|
+
end
|
65
|
+
|
66
|
+
out << <<~FOOTER
|
67
|
+
end
|
68
|
+
end
|
69
|
+
FOOTER
|
70
|
+
end
|
71
|
+
|
72
|
+
puts "%d numerics." % data['values'].count
|
73
|
+
system('wc', File.join(__dir__, 'lib/iirc/numerics.rb'))
|
74
|
+
end
|
75
|
+
|
18
76
|
task default: :test
|
77
|
+
|
data/lib/iirc/bot/ambient.rb
CHANGED
@@ -1,60 +1,61 @@
|
|
1
1
|
require_relative "reply_target"
|
2
2
|
|
3
3
|
module IIRC
|
4
|
-
module Bot::
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module Bot::Ambient
|
5
|
+
module Events
|
6
|
+
private
|
7
|
+
def configure_ambient_events
|
8
|
+
hook :set_ambient_event
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def ambient_event
|
12
|
+
Thread.current[:ambient_event]
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def ambient_target; ambient_event&.target; end
|
16
|
+
def ambient_sender; ambient_event&.sender; end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def set_ambient_event(evt)
|
19
|
+
Thread.current[:ambient_event] = evt
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
def with_ambient_event(evt)
|
23
|
+
initial_event = ambient_event
|
24
|
+
set_ambient_event(evt)
|
25
|
+
begin
|
26
|
+
yield evt
|
27
|
+
ensure
|
28
|
+
set_ambient_event(initial_event)
|
29
|
+
end
|
28
30
|
end
|
29
|
-
|
30
|
-
end
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
module LabeledRequests
|
34
|
+
def labeled_request(*)
|
35
|
+
initial_evt = ambient_event
|
36
|
+
super do |reply|
|
37
|
+
with_ambient_event(initial_evt) { yield reply }
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
|
-
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
module ReplyTarget
|
43
|
+
def reply_target(evt=ambient_event) super end
|
44
|
+
end
|
45
|
+
|
46
|
+
module Verbs
|
47
|
+
include Events
|
48
|
+
include ReplyTarget
|
49
|
+
|
50
|
+
def join(channel=reply_target) super end
|
51
|
+
def part(channel=reply_target, reason='') super end
|
52
|
+
def msg(target=reply_target, msg) super end
|
53
|
+
def act(target=reply_target, msg) super end
|
54
|
+
def cycle(channel=reply_target, reason='') super end
|
55
|
+
def mode(target=reply_target, mode) super end
|
56
|
+
alias :say :msg
|
45
57
|
end
|
46
|
-
end
|
47
58
|
|
48
|
-
|
49
|
-
include Bot::AmbientEvents
|
50
|
-
include Bot::AmbientEvents::ReplyTarget
|
51
|
-
|
52
|
-
def join(channel=ambient_reply_target) super end
|
53
|
-
def part(channel=ambient_reply_target, reason='') super end
|
54
|
-
def msg(channel=ambient_reply_target, msg) super end
|
55
|
-
def act(channel=ambient_reply_target, msg) super end
|
56
|
-
def cycle(channel=ambient_reply_target, reason='') super end
|
57
|
-
def mode(channel=ambient_reply_target, mode) super end
|
58
|
-
alias :say :msg
|
59
|
+
include Verbs
|
59
60
|
end
|
60
|
-
end
|
61
|
+
end
|
data/lib/iirc/bot.rb
CHANGED