iirc 0.2.6 → 0.2.9
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 +16 -0
- data/LICENSE +7 -0
- data/Rakefile +6 -0
- data/iirc.gemspec +1 -0
- data/lib/iirc/bot/ambient.rb +22 -12
- data/lib/iirc/bot/reply_target.rb +14 -0
- data/lib/iirc/event.rb +1 -2
- data/lib/iirc/sender.rb +43 -3
- data/lib/iirc/version.rb +1 -1
- data/lib/iirc.rb +2 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b3e9c48299d3d224743658cf8f5ccb1fa350fa748c8319fccd0d1a2c7154f81
|
4
|
+
data.tar.gz: 7675b9b55b30fb8a66c96aaccae46a4cd60c1381d8d79a1d4b9e1fdd13ccc6e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f5f6743fd668c3da81091b5ae865e32bc83685166d4802bccd3bcd19c8dc2aebff176cb41b0cbb986b8b01c0e8ebeef527bdc4f099b6d327a4cca15e43ec6a9
|
7
|
+
data.tar.gz: df2a11d9936e4744581fa0cf8196a424692272f72f439acf18384ebb9afb122835637475e7d97618a81a5f291efe37f42dca378021d18b7b0246722dc86b564a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## [0.2.9] - 2022-03-24
|
2
|
+
|
3
|
+
- Add reply target concept (Bot::ReplyTarget)
|
4
|
+
- The reply target of an event is the sender's nick when we are its target,
|
5
|
+
and equal to the regular target otherwise.
|
6
|
+
- The ambient verb methods now target the reply target of the ambient event by default.
|
7
|
+
- Should make writing actions more convenient.
|
8
|
+
|
9
|
+
## [0.2.8] - 2022-03-22
|
10
|
+
|
11
|
+
- Add MIT license
|
12
|
+
|
13
|
+
## [0.2.7] - 2022-03-16
|
14
|
+
|
15
|
+
- Include Bot::RegexHooks in Batteries
|
16
|
+
|
1
17
|
## [0.2.6] - 2022-03-16
|
2
18
|
|
3
19
|
- Add ircparser dependency
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2022 mooff <mooff@awful.cooking>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rake/testtask"
|
5
|
+
require "rdoc/task"
|
5
6
|
|
6
7
|
Rake::TestTask.new(:test) do |t|
|
7
8
|
t.libs << "test"
|
@@ -9,4 +10,9 @@ Rake::TestTask.new(:test) do |t|
|
|
9
10
|
t.test_files = FileList["test/**/*_test.rb"]
|
10
11
|
end
|
11
12
|
|
13
|
+
RDoc::Task.new do |rd|
|
14
|
+
rd.rdoc_files.include("lib/**/*.rb")
|
15
|
+
rd.options = ["--all"]
|
16
|
+
end
|
17
|
+
|
12
18
|
task default: :test
|
data/iirc.gemspec
CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = IIRC::VERSION
|
8
8
|
spec.authors = ["mooff"]
|
9
9
|
spec.email = ["mooff@awful.cooking"]
|
10
|
+
spec.license = "MIT"
|
10
11
|
|
11
12
|
spec.summary = "Lean, mean IRC processing machine"
|
12
13
|
spec.description = "A composable toolkit for IRC bots"
|
data/lib/iirc/bot/ambient.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "reply_target"
|
2
|
+
|
1
3
|
module IIRC
|
2
4
|
module Bot::AmbientEvents
|
3
5
|
private
|
@@ -27,18 +29,6 @@ module IIRC
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
|
-
module Bot::AmbientVerbs
|
31
|
-
include Bot::AmbientEvents
|
32
|
-
|
33
|
-
def join(channel=ambient_target) super end
|
34
|
-
def part(channel=ambient_target, reason='') super end
|
35
|
-
def msg(channel=ambient_target, msg) super end
|
36
|
-
def act(channel=ambient_target, msg) super end
|
37
|
-
def cycle(channel=ambient_target, reason='') super end
|
38
|
-
def mode(channel=ambient_target, mode) super end
|
39
|
-
alias :say :msg
|
40
|
-
end
|
41
|
-
|
42
32
|
module Bot::AmbientEvents::LabeledRequests
|
43
33
|
def labeled_request(*)
|
44
34
|
initial_evt = ambient_event
|
@@ -47,4 +37,24 @@ module IIRC
|
|
47
37
|
end
|
48
38
|
end
|
49
39
|
end
|
40
|
+
|
41
|
+
module Bot::AmbientEvents::ReplyTarget
|
42
|
+
include Bot::ReplyTarget
|
43
|
+
def ambient_reply_target
|
44
|
+
reply_target(ambient_event)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module Bot::AmbientVerbs
|
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
|
+
end
|
50
60
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module IIRC
|
2
|
+
module Bot::ReplyTarget
|
3
|
+
# The +reply_target+ of an event is the sender's nickname when _we_ are the
|
4
|
+
# +target+. Otherwise, it returns the regular +target+.
|
5
|
+
#
|
6
|
+
# It lets us reply to events without having to repeat the `(me ===
|
7
|
+
# target) ? sender.nick : target` logic used to make sure we don't message
|
8
|
+
# ourselves when we receive a direct PRIVMSG, NOTICE, etc.
|
9
|
+
|
10
|
+
def reply_target(evt)
|
11
|
+
(me === evt.target) ? evt.sender.nick : evt.target
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/iirc/event.rb
CHANGED
data/lib/iirc/sender.rb
CHANGED
@@ -1,7 +1,26 @@
|
|
1
1
|
module IIRC
|
2
|
+
# A mixin which adds IRC hostmask introspection methods to strings.
|
3
|
+
#
|
4
|
+
# *CoolNick*, *:NickName*, <b>:nick!user@host</b>, *:server.name*, *another.server.name* forms are supported.
|
5
|
+
#
|
6
|
+
# A leading colon may be present in the string, and will be ignored.
|
7
|
+
#
|
8
|
+
# @example nick!user@example.com
|
9
|
+
# sender = "nick!user@example.com".extend(IIRC::Sender)
|
10
|
+
# sender.user? # => true
|
11
|
+
# sender.host # => "example.com"
|
12
|
+
# @example :irc.server
|
13
|
+
# sender = ":irc.server".extend(IIRC::Sender)
|
14
|
+
# sender.server? # => true
|
15
|
+
# sender.host # => "irc.server"
|
16
|
+
# @example JimBob
|
17
|
+
# sender = "JimBob".extend(IIRC::Sender)
|
18
|
+
# sender.user? # => true
|
19
|
+
# sender.nick # => "JimBob"
|
20
|
+
|
2
21
|
module Sender
|
3
22
|
def user
|
4
|
-
@user ||= User.
|
23
|
+
@user ||= User.from_source(self)
|
5
24
|
end
|
6
25
|
|
7
26
|
def server?
|
@@ -14,16 +33,37 @@ module IIRC
|
|
14
33
|
|
15
34
|
def nick; user&.nick end
|
16
35
|
def username; user&.username end
|
17
|
-
def host; user
|
36
|
+
def host; server? ? without_leading_colon : user.host end
|
18
37
|
|
19
38
|
def to_prefix
|
20
39
|
":#{self}"
|
21
40
|
end
|
22
41
|
|
23
|
-
def
|
42
|
+
def without_leading_colon
|
24
43
|
delete_prefix(':')
|
25
44
|
end
|
26
45
|
|
46
|
+
alias :to_s :without_leading_colon
|
27
47
|
alias :inspect :to_prefix
|
28
48
|
end
|
49
|
+
|
50
|
+
module_function
|
51
|
+
# Extends and returns a source string with the IIRC::Sender mixin.
|
52
|
+
# Duplicates first if the string is frozen. Returns nil if source is nil.
|
53
|
+
#
|
54
|
+
# @example :nick!user@host
|
55
|
+
# v = IIRC.Sender(":JimmyWales!jim@wikipedia.org") # => "JimmyWales!jim@wikipedia.org"
|
56
|
+
# v.nick # => "JimmyWales"
|
57
|
+
# v.host # => "wikipedia.org"
|
58
|
+
# v.user? # => true
|
59
|
+
# @example server.name
|
60
|
+
# IIRC.Sender("services.libera.chat").server? # => true
|
61
|
+
|
62
|
+
def Sender(source)
|
63
|
+
if source.nil?
|
64
|
+
nil
|
65
|
+
else
|
66
|
+
(source.frozen? ? source.dup : source).extend(Sender)
|
67
|
+
end
|
68
|
+
end
|
29
69
|
end
|
data/lib/iirc/version.rb
CHANGED
data/lib/iirc.rb
CHANGED
@@ -19,6 +19,7 @@ require_relative "iirc/bot/print_io"
|
|
19
19
|
require_relative "iirc/bot/reading"
|
20
20
|
require_relative "iirc/bot/redis"
|
21
21
|
require_relative "iirc/bot/regex_hooks"
|
22
|
+
require_relative "iirc/bot/reply_target"
|
22
23
|
require_relative "iirc/bot/track_own_nick"
|
23
24
|
require_relative "iirc/bot/verbs"
|
24
25
|
|
@@ -63,6 +64,7 @@ module IIRC
|
|
63
64
|
include Bot::AutoJoin
|
64
65
|
include Bot::Verbs
|
65
66
|
include Bot::AmbientVerbs
|
67
|
+
include Bot::RegexHooks
|
66
68
|
end
|
67
69
|
|
68
70
|
module SSL
|
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.2.
|
4
|
+
version: 0.2.9
|
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-
|
11
|
+
date: 2022-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ircparser
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- ".gitignore"
|
36
36
|
- CHANGELOG.md
|
37
37
|
- Gemfile
|
38
|
+
- LICENSE
|
38
39
|
- README.md
|
39
40
|
- Rakefile
|
40
41
|
- bin/console
|
@@ -63,6 +64,7 @@ files:
|
|
63
64
|
- lib/iirc/bot/reading.rb
|
64
65
|
- lib/iirc/bot/redis.rb
|
65
66
|
- lib/iirc/bot/regex_hooks.rb
|
67
|
+
- lib/iirc/bot/reply_target.rb
|
66
68
|
- lib/iirc/bot/track_own_nick.rb
|
67
69
|
- lib/iirc/bot/verbs.rb
|
68
70
|
- lib/iirc/event.rb
|
@@ -70,7 +72,8 @@ files:
|
|
70
72
|
- lib/iirc/user.rb
|
71
73
|
- lib/iirc/version.rb
|
72
74
|
homepage: https://github.com/awfulcooking/iirc
|
73
|
-
licenses:
|
75
|
+
licenses:
|
76
|
+
- MIT
|
74
77
|
metadata:
|
75
78
|
homepage_uri: https://github.com/awfulcooking/iirc
|
76
79
|
source_code_uri: https://github.com/awfulcooking/iirc
|