rodbot 0.4.3 → 0.4.4
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
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/test.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +7 -0
- data/README.md +3 -0
- data/checksums/rodbot-0.4.4.gem.sha512 +1 -0
- data/lib/rodbot/env.rb +1 -1
- data/lib/rodbot/plugins/word_of_the_day/lib/adapter.rb +18 -0
- data/lib/rodbot/plugins/word_of_the_day/lib/adapters/base.rb +23 -0
- data/lib/rodbot/plugins/word_of_the_day/lib/adapters/merriam_webster.rb +30 -0
- data/lib/rodbot/plugins/word_of_the_day/lib/adapters/transparent.rb +50 -0
- data/lib/rodbot/plugins/word_of_the_day/schedule.rb +2 -2
- data/lib/rodbot/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +8 -7
- metadata.gz.sig +1 -1
- data/lib/rodbot/plugins/word_of_the_day/adapter.rb +0 -22
- data/lib/rodbot/plugins/word_of_the_day/adapters/base.rb +0 -27
- data/lib/rodbot/plugins/word_of_the_day/adapters/merriam_webster.rb +0 -34
- data/lib/rodbot/plugins/word_of_the_day/adapters/transparent.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47f769ca6ea9ef12065fddf0efaf8a0269009654aef1a21fe156a92c07199844
|
4
|
+
data.tar.gz: 6c6fec74a830838687e797dabe1076ec800fddd7f1efb1ea8248a455b80a5819
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64dcb382753c7493bad70e24d4fe4e13c12b0388066f16dfc9c491a7d8869254f03d7b2000f910827f477a1a7eaf07e3b1088c46db13db91389bacc11316b25c
|
7
|
+
data.tar.gz: cce4048655798b61cfa1a3724b264ce4d739673771f4f957f5e7878fe469be871de0d28a7b1ab502abf9aefe57f2d8a08e1fcd0d0eb61438b9ca638db8eac3d7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.github/workflows/test.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -468,6 +468,8 @@ Rodbot.env.production? # => true
|
|
468
468
|
Rodbot.env.development? # => false
|
469
469
|
```
|
470
470
|
|
471
|
+
You can use the more generic alternative `APP_ENV` as well, however, if `RODBOT_ENV` is defined, it takes precedence over `APP_ENV`.
|
472
|
+
|
471
473
|
## Credentials
|
472
474
|
|
473
475
|
In order not to commit secrets to repositories or environment variables, Rodbot bundles the [dry-credentials](https://rubygems.org/gems/dry-credentials) gem and exposes it via the `rodbot credentials` CLI command. The secrets are then available in your code like `Rodbot.credentials.my_secret` and the encrypted files are written to `config/credentials`.
|
@@ -481,6 +483,7 @@ Rodbot aims to keep its core small and add features via plugins, either built-in
|
|
481
483
|
Name | Dependencies | Description
|
482
484
|
-----|--------------|------------
|
483
485
|
[:matrix](https://rubydoc.info/github/svoop/rodbot/file/lib/rodbot/plugins/matrix/README.matrix.md) | yes | relay service for the [Matrix communication network](https://matrix.org)
|
486
|
+
[:slack](https://rubydoc.info/github/svoop/rodbot/file/lib/rodbot/plugins/slack/README.slack.md) | yes | relay service for the [Slack communication network](https://slack.com)
|
484
487
|
[:otp](https://rubydoc.info/github/svoop/rodbot/file/lib/rodbot/plugins/otp/README.otp.md) | yes | guard commands with one-time passwords
|
485
488
|
[:gitlab_webhook](https://rubydoc.info/github/svoop/rodbot/file/lib/rodbot/plugins/gitlab_webhook/README.gitlab_webhook.md) | no | event announcements from [GitLab](https://gitlab.com)
|
486
489
|
[:github_webhook](https://rubydoc.info/github/svoop/rodbot/file/lib/rodbot/plugins/github_webhook/README.github_webhook.md) | no | event announcements from [GitHub](https://github.com)
|
@@ -0,0 +1 @@
|
|
1
|
+
263a706d44c8776c413d3800b455249a7c75ed323dc27932ca57d589e13e7da68bc5eb6351beff4efc3cc0dec32d03d7d9c64ee68bfe739426a0f54eccac1229
|
data/lib/rodbot/env.rb
CHANGED
@@ -27,7 +27,7 @@ module Rodbot
|
|
27
27
|
@root = root ? Pathname(root).realpath : Pathname.pwd
|
28
28
|
@tmp = @root.join('tmp')
|
29
29
|
@gem = Pathname(__dir__).join('..', '..').realpath
|
30
|
-
@current = ENV['RODBOT_ENV']
|
30
|
+
@current = ENV['RODBOT_ENV'] || ENV['APP_ENV']
|
31
31
|
@current = 'development' unless ENVS.include? @current
|
32
32
|
end
|
33
33
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'adapters/base'
|
4
|
+
require_relative 'adapters/merriam_webster'
|
5
|
+
require_relative 'adapters/transparent'
|
6
|
+
|
7
|
+
module WordOfTheDay
|
8
|
+
class Adapter
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def_delegator :@adapter, :message, :message
|
12
|
+
|
13
|
+
def initialize(language)
|
14
|
+
@language = language
|
15
|
+
@adapter = (language == 'English' ? MerriamWebster : Transparent).new(language)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'httpx'
|
4
|
+
|
5
|
+
module WordOfTheDay
|
6
|
+
class Adapter
|
7
|
+
class Base
|
8
|
+
attr_reader :language
|
9
|
+
|
10
|
+
def initialize(language)
|
11
|
+
@language = language.downcase
|
12
|
+
end
|
13
|
+
|
14
|
+
def message
|
15
|
+
if word
|
16
|
+
"[#{word}](#{url}) (#{language.capitalize})"
|
17
|
+
else
|
18
|
+
"~~#{language.capitalize}~~"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WordOfTheDay
|
4
|
+
class Adapter
|
5
|
+
class MerriamWebster < Base
|
6
|
+
private
|
7
|
+
|
8
|
+
def word
|
9
|
+
html.match(/<h2 class="word-header-txt">(.+?)</)&.captures&.first
|
10
|
+
end
|
11
|
+
|
12
|
+
def url
|
13
|
+
"https://www.merriam-webster.com/word-of-the-day/#{today}"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def today
|
19
|
+
Time.now.strftime('%F')
|
20
|
+
end
|
21
|
+
|
22
|
+
def html
|
23
|
+
case (response = HTTPX.get(url))
|
24
|
+
in { status: 200 } then response.body.to_s
|
25
|
+
else ''
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WordOfTheDay
|
4
|
+
class Adapter
|
5
|
+
class Transparent < Base
|
6
|
+
LANGUAGE_CODES = {
|
7
|
+
'arabic' => 'ar',
|
8
|
+
'chinese' => 'zh',
|
9
|
+
'dutch' => 'nl',
|
10
|
+
'esperanto' => 'esp',
|
11
|
+
'french' => 'fr',
|
12
|
+
'german' => 'de',
|
13
|
+
'irish' => 'ga',
|
14
|
+
'italian' => 'it',
|
15
|
+
'japanese' => 'ja',
|
16
|
+
'latin' => 'la',
|
17
|
+
'polish' => 'pl',
|
18
|
+
'portuguese' => 'pt',
|
19
|
+
'russian' => 'ru',
|
20
|
+
'spanish' => 'es'
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
def word
|
24
|
+
xml.match(/<word>(.+?)</)&.captures&.first
|
25
|
+
end
|
26
|
+
|
27
|
+
def url
|
28
|
+
"https://wotd.transparent.com/widget/?lang=#{language}&date=#{today}"
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def today
|
34
|
+
Time.now.strftime('%m-%d-%Y')
|
35
|
+
end
|
36
|
+
|
37
|
+
def language_code
|
38
|
+
LANGUAGE_CODES.fetch(language, language)
|
39
|
+
end
|
40
|
+
|
41
|
+
def xml
|
42
|
+
xml_url = "https://wotd.transparent.com/rss/#{today}-#{language_code}-widget.xml"
|
43
|
+
case (response = HTTPX.get(xml_url))
|
44
|
+
in { status: 200 } then response.body.to_s
|
45
|
+
else ''
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'httpx'
|
4
4
|
|
5
|
-
require_relative 'adapter'
|
5
|
+
require_relative 'lib/adapter'
|
6
6
|
|
7
7
|
module Rodbot
|
8
8
|
class Plugins
|
@@ -23,7 +23,7 @@ module Rodbot
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def message
|
26
|
-
languages.map { Adapter.new(_1).message }.compact.join(' / ')
|
26
|
+
languages.map { ::WordOfTheDay::Adapter.new(_1).message }.compact.join(' / ')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/rodbot/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rodbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Schwyn
|
@@ -27,7 +27,7 @@ cert_chain:
|
|
27
27
|
k/QvZU05f6HMYBrPogJgIzHC/C5N/yeE4BVEuBDn+10Zb1iu3aDk8sd0uMgukCY8
|
28
28
|
TUmlP5A6NeGdeDJIoLgromAKs+nvI7TWzhQq9ODs51XhxgUFRCvBqUTpjTQigw==
|
29
29
|
-----END CERTIFICATE-----
|
30
|
-
date:
|
30
|
+
date: 2024-02-12 00:00:00.000000000 Z
|
31
31
|
dependencies:
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: zeitwerk
|
@@ -456,6 +456,7 @@ files:
|
|
456
456
|
- checksums/rodbot-0.4.1.gem.sha512
|
457
457
|
- checksums/rodbot-0.4.2.gem.sha512
|
458
458
|
- checksums/rodbot-0.4.3.gem.sha512
|
459
|
+
- checksums/rodbot-0.4.4.gem.sha512
|
459
460
|
- doc/rodbot.afphoto
|
460
461
|
- doc/rodbot.avif
|
461
462
|
- exe/rodbot
|
@@ -501,10 +502,10 @@ files:
|
|
501
502
|
- lib/rodbot/plugins/slack/README.slack.md
|
502
503
|
- lib/rodbot/plugins/slack/relay.rb
|
503
504
|
- lib/rodbot/plugins/word_of_the_day/README.word_of_the_day.md
|
504
|
-
- lib/rodbot/plugins/word_of_the_day/adapter.rb
|
505
|
-
- lib/rodbot/plugins/word_of_the_day/adapters/base.rb
|
506
|
-
- lib/rodbot/plugins/word_of_the_day/adapters/merriam_webster.rb
|
507
|
-
- lib/rodbot/plugins/word_of_the_day/adapters/transparent.rb
|
505
|
+
- lib/rodbot/plugins/word_of_the_day/lib/adapter.rb
|
506
|
+
- lib/rodbot/plugins/word_of_the_day/lib/adapters/base.rb
|
507
|
+
- lib/rodbot/plugins/word_of_the_day/lib/adapters/merriam_webster.rb
|
508
|
+
- lib/rodbot/plugins/word_of_the_day/lib/adapters/transparent.rb
|
508
509
|
- lib/rodbot/plugins/word_of_the_day/schedule.rb
|
509
510
|
- lib/rodbot/rack.rb
|
510
511
|
- lib/rodbot/refinements.rb
|
@@ -579,7 +580,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
579
580
|
- !ruby/object:Gem::Version
|
580
581
|
version: '0'
|
581
582
|
requirements: []
|
582
|
-
rubygems_version: 3.
|
583
|
+
rubygems_version: 3.5.6
|
583
584
|
signing_key:
|
584
585
|
specification_version: 4
|
585
586
|
summary: Minimalistic framework to build chat bots on top of a Roda backend
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Ŭ�f���K�j�2z�r[���F��#9���,�<aսl͌�Q�7s�Lk�ʻo��OW+
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'adapters/base'
|
4
|
-
require_relative 'adapters/merriam_webster'
|
5
|
-
require_relative 'adapters/transparent'
|
6
|
-
|
7
|
-
module Rodbot
|
8
|
-
class Plugins
|
9
|
-
class WordOfTheDay
|
10
|
-
class Adapter
|
11
|
-
extend Forwardable
|
12
|
-
|
13
|
-
def_delegator :@adapter, :message, :message
|
14
|
-
|
15
|
-
def initialize(language)
|
16
|
-
@language = language
|
17
|
-
@adapter = (language == 'English' ? MerriamWebster : Transparent).new(language)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'httpx'
|
4
|
-
|
5
|
-
module Rodbot
|
6
|
-
class Plugins
|
7
|
-
class WordOfTheDay
|
8
|
-
class Adapter
|
9
|
-
class Base
|
10
|
-
attr_reader :language
|
11
|
-
|
12
|
-
def initialize(language)
|
13
|
-
@language = language.downcase
|
14
|
-
end
|
15
|
-
|
16
|
-
def message
|
17
|
-
if word
|
18
|
-
"[#{word}](#{url}) (#{language.capitalize})"
|
19
|
-
else
|
20
|
-
"~~#{language.capitalize}~~"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Rodbot
|
4
|
-
class Plugins
|
5
|
-
class WordOfTheDay
|
6
|
-
class Adapter
|
7
|
-
class MerriamWebster < Base
|
8
|
-
private
|
9
|
-
|
10
|
-
def word
|
11
|
-
html.match(/<h2 class="word-header-txt">(.+?)</)&.captures&.first
|
12
|
-
end
|
13
|
-
|
14
|
-
def url
|
15
|
-
"https://www.merriam-webster.com/word-of-the-day/#{today}"
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def today
|
21
|
-
Time.now.strftime('%F')
|
22
|
-
end
|
23
|
-
|
24
|
-
def html
|
25
|
-
case (response = HTTPX.get(url))
|
26
|
-
in { status: 200 } then response.body.to_s
|
27
|
-
else ''
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Rodbot
|
4
|
-
class Plugins
|
5
|
-
class WordOfTheDay
|
6
|
-
class Adapter
|
7
|
-
class Transparent < Base
|
8
|
-
LANGUAGE_CODES = {
|
9
|
-
'arabic' => 'ar',
|
10
|
-
'chinese' => 'zh',
|
11
|
-
'dutch' => 'nl',
|
12
|
-
'esperanto' => 'esp',
|
13
|
-
'french' => 'fr',
|
14
|
-
'german' => 'de',
|
15
|
-
'irish' => 'ga',
|
16
|
-
'italian' => 'it',
|
17
|
-
'japanese' => 'ja',
|
18
|
-
'latin' => 'la',
|
19
|
-
'polish' => 'pl',
|
20
|
-
'portuguese' => 'pt',
|
21
|
-
'russian' => 'ru',
|
22
|
-
'spanish' => 'es'
|
23
|
-
}.freeze
|
24
|
-
|
25
|
-
def word
|
26
|
-
xml.match(/<word>(.+?)</)&.captures&.first
|
27
|
-
end
|
28
|
-
|
29
|
-
def url
|
30
|
-
"https://wotd.transparent.com/widget/?lang=#{language}&date=#{today}"
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def today
|
36
|
-
Time.now.strftime('%m-%d-%Y')
|
37
|
-
end
|
38
|
-
|
39
|
-
def language_code
|
40
|
-
LANGUAGE_CODES.fetch(language, language)
|
41
|
-
end
|
42
|
-
|
43
|
-
def xml
|
44
|
-
xml_url = "https://wotd.transparent.com/rss/#{today}-#{language_code}-widget.xml"
|
45
|
-
case (response = HTTPX.get(xml_url))
|
46
|
-
in { status: 200 } then response.body.to_s
|
47
|
-
else ''
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|