rodbot 0.1.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +1 -3
  3. data/.github/workflows/test.yml +21 -0
  4. data/.gitignore +16 -0
  5. data/.ruby-version +1 -0
  6. data/.yardopts +9 -0
  7. data/CHANGELOG.md +11 -0
  8. data/bin/console +13 -0
  9. data/bin/setup +6 -0
  10. data/checksums/rodbot-0.1.0.gem.sha512 +1 -0
  11. data/checksums/rodbot-0.1.0.pre1.gem.sha512 +1 -0
  12. data/checksums/rodbot-0.1.0.pre2.gem.sha512 +1 -0
  13. data/checksums/rodbot-0.1.0.pre3.gem.sha512 +1 -0
  14. data/checksums/rodbot-0.1.0.pre4.gem.sha512 +1 -0
  15. data/checksums/rodbot-0.1.0.pre5.gem.sha512 +1 -0
  16. data/checksums/rodbot-0.1.0.pre6.gem.sha512 +1 -0
  17. data/checksums/rodbot-0.1.0.pre7.gem.sha512 +1 -0
  18. data/checksums/rodbot-0.1.0.pre8.gem.sha512 +1 -0
  19. data/checksums/rodbot-0.1.0.pre9.gem.sha512 +1 -0
  20. data/checksums/rodbot-0.1.1.gem.sha512 +1 -0
  21. data/checksums/rodbot-0.2.0.gem.sha512 +1 -0
  22. data/checksums/rodbot-0.3.0.gem.sha512 +1 -0
  23. data/doc/rodbot.afphoto +0 -0
  24. data/doc/rodbot.avif +0 -0
  25. data/gems.rb +6 -0
  26. data/guardfile.rb +8 -0
  27. data/lib/rodbot/dispatcher.rb +2 -2
  28. data/lib/rodbot/memoize.rb +22 -13
  29. data/lib/rodbot/plugins/otp/README.otp.md +6 -2
  30. data/lib/rodbot/plugins/otp/app.rb +3 -5
  31. data/lib/rodbot/plugins/slack/README.slack.md +48 -0
  32. data/lib/rodbot/plugins/slack/relay.rb +79 -0
  33. data/lib/rodbot/version.rb +1 -1
  34. data/lib/templates/new/.gitignore +9 -0
  35. data/lib/templates/new/.ruby-version +1 -0
  36. data/lib/templates/new/config/credentials/.keep +0 -0
  37. data/lib/templates/new/gems.rb +5 -0
  38. data/lib/templates/new/lib/.keep +0 -0
  39. data/lib/templates/new/tmp/.keep +0 -0
  40. data/rakefile.rb +30 -0
  41. data/rodbot.gemspec +74 -0
  42. data/tmp/.keep +0 -0
  43. data.tar.gz.sig +0 -0
  44. metadata +67 -7
  45. metadata.gz.sig +0 -0
  46. data/lib/templates/new/gems.locked +0 -104
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a44274520f74f3723997267f1e2a456200e9f5118c6941dea6fc4704325bcf2b
4
- data.tar.gz: 24462b4cbc3c4751c18d1277950f6e3e0deeb7834d65d6ea43edb98ccc7f4223
3
+ metadata.gz: a4e3022218a7df9e0e16b2430fa3144a9abfadc49242fd439f48945709fb20e2
4
+ data.tar.gz: b1dbe4adfd865bdcb0ee107bbff5806705470961ba721da97d04ac92e1bba3ed
5
5
  SHA512:
6
- metadata.gz: f74b0b028597c229d5fec8b57f39ae36f62035974e87425dc6c6e4aeafc24df7e2a93ec7f298afe35983ff3d3cf91aae77049040b208c85df9c5ee89140f46ab
7
- data.tar.gz: abd243858266c2c9e13b810803e63539539be30511a3f490581512d895d4d7a3ca63f07c45d23eb27afde0e163353de01374ab8ac3a9b8a7ac0a72abc553d436
6
+ metadata.gz: 96a4262cbeaa00e9548d962014fd63353aac9c1a48843f5d5c082c66c306aeb5ccaee1660f0a501e9af104293eb68d80108deb9d1fae1a017aaa9ec327fcaf66
7
+ data.tar.gz: b2977391b972eeafad320e4dd54cf8f51a2b79a6efcea9f05f314caf912dbc6f9c1d961998afd11d78a61e3c8e12c61226993e3c564aee9220305f2f80c4da04
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1 @@
1
- ^�q��tn� �����Q8�`�_Q=�[KM��Sm6~�gq?�F3&ƾ*p���lD�[zV�
2
- ��`�y2'ڰ�袟DooXm&��s��Ų�;��B�eZ6������g�'��m���Y��z��3N��f1��I�:��~bA�?��)�R+������4�
3
- x��U'�`?�{�6��r�r3gj�6G�9V��*�I��#���X�$�����I�����V��RT�Y�D��;���#��=��l4
1
+ [��_r�R��%="-/�Y�^FO��b�����n�i�*/�:���%�䑟�ҋ�\��1��sxE��`�~�fZ{�ZGG|hxB IL���R;��z��.�L؞�kIO��M" =�>O§������U��%yK�*2����5/I#8Kv�$���נ��IE���}���o�٘� ��,�T;�
@@ -0,0 +1,21 @@
1
+ name: Test
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ strategy:
6
+ fail-fast: false
7
+ matrix:
8
+ os: [ubuntu-latest]
9
+ ruby: ['3.0', '3.1', '3.2']
10
+ name: test (Ruby ${{ matrix.ruby }} on ${{ matrix.os }})
11
+ runs-on: ${{ matrix.os }}
12
+ steps:
13
+ - name: Check out
14
+ uses: actions/checkout@v3
15
+ - name: Set up Ruby ${{ matrix.ruby }}
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+ bundler-cache: true
20
+ - name: Run tests
21
+ run: SPEC_SCOPE=all bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ # macOS
2
+ .DS_Store
3
+
4
+ # Ruby
5
+ gems.locked
6
+ pkg/*
7
+ *.gem
8
+ .bundle
9
+ .yardoc
10
+
11
+ # Temporary
12
+ tmp/*
13
+ *.pid
14
+
15
+ # Empty dirs
16
+ !.keep
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2
data/.yardopts ADDED
@@ -0,0 +1,9 @@
1
+ --exclude /lib/templates/
2
+ -
3
+ CHANGELOG.md
4
+ LICENSE.txt
5
+ lib/rodbot/plugins/github_webhook/README.github_webhook.md
6
+ lib/rodbot/plugins/gitlab_webhook/README.gitlab_webhook.md
7
+ lib/rodbot/plugins/hal/README.hal.md
8
+ lib/rodbot/plugins/matrix/README.matrix.md
9
+ lib/rodbot/plugins/word_of_the_day/README.word_of_the_day.md
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  Nothing so far
4
4
 
5
+ ## 0.3.0
6
+
7
+ #### Additions
8
+ * Built-in plugin for Slack
9
+
10
+ ## 0.2.0
11
+
12
+ #### Fixes
13
+ * Fix OTP verification
14
+ * Drop futile files from packaged gem
15
+
5
16
  ## 0.1.1
6
17
 
7
18
  #### Fixes
data/bin/console ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "rodbot"
6
+
7
+ using Rodbot::Refinements
8
+ Dir.chdir('lib/templates/new')
9
+ Rodbot.boot
10
+ Rodbot::SERVICES.each { "rodbot/services/#{_1}".constantize }
11
+
12
+ require "irb"
13
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
@@ -0,0 +1 @@
1
+ d75b98b17f6a274bbdae50d9dcc68696ccf534d4c0485fcb2833a23f551fac6a58cba2618fa8a3292a672000b5de0aefd26176377924f29004e9c789e7849e3f
@@ -0,0 +1 @@
1
+ bc07b0a01d848a821866ea0fad551c8321449322dbbe78909de56dcd929630931b4e41ae45a1737666c43514e7f4cafa0ed50ec5e5f6ddd1153edab54aa61605
@@ -0,0 +1 @@
1
+ 35f7ea0ac794b1664e1edfb4519a754d4b9eecde3649bb6b1cd0c36a083933fc9160ebcb1d4403cc5af14591a1460a9124c478e5c7907422ebe351ef8e21b355
@@ -0,0 +1 @@
1
+ 1df2ab362f74264c995861d820cfd41e9c3a465cd9bca60c5214ccaf9b9525ed7eca057e9863eeedf224b2e9d205d03526241d47ac47013f5468e212bbc4233e
@@ -0,0 +1 @@
1
+ 06123138b60dea4874f7344836dee04db1d04bc2cbc58ae66a0aba6b085930b50cb8ed152ba8f57f9044b8ceb9f16aef6588b00ade9d7eeb4410cb02c127d47a
@@ -0,0 +1 @@
1
+ dc5f19a7c1abd0ff24ae2b36199d1dcbe4619a4cf2a6ef3e27a8e758a35c111459cb246d92da139d69c9add381cdd47d4a8c8289b96e762ce477bd611669894c
@@ -0,0 +1 @@
1
+ 9b0b762987df83559962df55170d14148cb6b2790e0b608ed09eb4e67ccf2173f04bbd9fd577eff1077cb0184cf80f0af7f1b4b394aa5ebc294dd1c72ac069eb
@@ -0,0 +1 @@
1
+ f3d04271a35bbddff4005a41b6cfbe181ba732a9570f63d863e44f6bc9ca3ceff5e5318996eb8a9bfb4bc684e58465a837900a7a872449a7d4f2db7e98c4bebd
@@ -0,0 +1 @@
1
+ b02edd192928202aa459f81d024d5992100572b1298265578e9ba1d9347ebc0636226379be446a391eca8f1cce6ff2a85c5d7aeb3b256c52b1a407aef25b4d9d
@@ -0,0 +1 @@
1
+ e1ec4f97b856ece49c0c576255cc15dca50f1a6b04a087721c72994a8d54f1946ca977ee470faa70b43bbea5b062823da50c80a687ebd259be4d72ef4b089bc9
@@ -0,0 +1 @@
1
+ 2fb19f1cb90af6a68103bffa740452d5b67c553cdf10b546fcd46e76adcaf07ab8aabe330e06a14a6d7a75d5b8bc7794943e8c891261144741e043c4a404f453
@@ -0,0 +1 @@
1
+ 0967301f902d1461e206ccaae8e61f811c5e58f4136e03c654a081279d9585673c37413e4ad71a2430fe9ffe39b37b03ee0a5cc1f6780170856c334502062e82
@@ -0,0 +1 @@
1
+ 789b796fc2127afbb1850f083f9b3255a31a4dfe570e0a0c75b7ed2be9bbf736c89d418233b0c855656b75e87da2d8e3c9f31ffe0932f8a5c37461f9e4ddabc5
Binary file
data/doc/rodbot.avif ADDED
Binary file
data/gems.rb ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rodbot.gemspec
6
+ gemspec
data/guardfile.rb ADDED
@@ -0,0 +1,8 @@
1
+ clearing :on
2
+
3
+ guard :minitest do
4
+ watch(%r{^spec/(.+)_spec\.rb})
5
+ watch(%r{^lib/(.+)\.rb}) { "spec/lib/#{_1[1]}_spec.rb" }
6
+ watch(%r{shared_specs\.rb}) { 'spec' }
7
+ watch(%r{^spec/spec_helper\.rb}) { 'spec' }
8
+ end
@@ -69,7 +69,7 @@ module Rodbot
69
69
 
70
70
  # Dispatch all registered tasks
71
71
  def dispatch
72
- tasks.each_value { fork &_1 }
72
+ tasks.each_value { fork(&_1) }
73
73
  end
74
74
 
75
75
  # Supervise all dispatched tasks
@@ -77,7 +77,7 @@ module Rodbot
77
77
  loop do
78
78
  pid = Process.wait
79
79
  sleep @refork_delay
80
- fork &tasks[task(pid)]
80
+ fork(&tasks[task(pid)])
81
81
  end
82
82
  end
83
83
 
@@ -39,7 +39,10 @@ module Rodbot
39
39
  # e.either(keyword: 2) # => 2 (memoized)
40
40
  # e.either { 3 } # => :not_nil (cannot be memoized)
41
41
  # Rodbot::Memoize.suspend do
42
- # e.either(1) # => 1 (calculated, not memoized)
42
+ # e.either(1) # => 1 (recalculated, not memoized)
43
+ # end
44
+ # Rodbot::Memoize.revisit do
45
+ # e.either(5) # => 5 (recalculated, memoized anew)
43
46
  # end
44
47
  module Memoize
45
48
  module ClassMethods
@@ -47,12 +50,12 @@ module Rodbot
47
50
  unmemoized_method = :"_unmemoized_#{method}"
48
51
  alias_method unmemoized_method, method
49
52
  define_method method do |*args, **kargs, &block|
50
- if Rodbot::Memoize.suspended? || block
53
+ if Rodbot::Memoize.suspend? || block
51
54
  send(unmemoized_method, *args, **kargs, &block)
52
55
  else
53
56
  id = method.hash ^ args.hash ^ kargs.hash
54
57
  @_memoize_cache ||= {}
55
- if @_memoize_cache.has_key? id
58
+ if !Rodbot::Memoize.revisit? && @_memoize_cache.has_key?(id)
56
59
  @_memoize_cache[id]
57
60
  else
58
61
  @_memoize_cache[id] = send(unmemoized_method, *args, **kargs)
@@ -64,16 +67,22 @@ module Rodbot
64
67
  end
65
68
 
66
69
  class << self
67
- def suspend
68
- @suspended = true
69
- yield
70
- ensure
71
- @suspended = false
72
- end
70
+ %i(suspend revisit).each do |switch|
71
+ ivar = "@#{switch}"
72
+ define_method switch do |&block|
73
+ instance_variable_set(ivar, true)
74
+ block.call
75
+ ensure
76
+ instance_variable_set(ivar, false)
77
+ end
73
78
 
74
- def suspended?
75
- @suspended = false if @suspended.nil?
76
- @suspended
79
+ define_method "#{switch}?" do
80
+ if instance_variable_defined? ivar
81
+ instance_variable_get ivar
82
+ else
83
+ instance_variable_set(ivar, false)
84
+ end
85
+ end
77
86
  end
78
87
 
79
88
  def included(base)
@@ -82,5 +91,5 @@ module Rodbot
82
91
  end
83
92
  end
84
93
 
85
- end
94
+ end
86
95
 
@@ -47,7 +47,7 @@ module Routes
47
47
  end
48
48
  ```
49
49
 
50
- (As a reminder: Up until this point, `r.arguments` is a mere shortcut for `r.params['arguments']`.)
50
+ As a reminder: In the above example, `r.arguments` is a mere shortcut for `r.params['arguments']`.
51
51
 
52
52
  In order to protect this rather dangerous command with a one-time password, you have to guard the route:
53
53
 
@@ -66,7 +66,9 @@ To execute the command now, you have to add the six digit one-time password to t
66
66
  !reboot example.com 123456
67
67
  ```
68
68
 
69
- The `r.valid_otp?` guard extracts the one-time password from the message and validates it. In this example, a validation result `true` causes the server to be rebooted. Please note that `r.argument` after the guard does not contain the one-time password anymore!
69
+ The `r.valid_otp?` guard extracts the one-time password from the message and validates it. In this example, a validation result `true` causes the server to be rebooted.
70
+
71
+ Please note that `r.valid_otp?` redefines `r.arguments` to no longer include the password.
70
72
 
71
73
  If halting with a 401 error is all you want, there's even a shorter alternative `r.require_valid_otp!`:
72
74
 
@@ -80,3 +82,5 @@ end
80
82
  ```
81
83
 
82
84
  This route does exactly the same as the more verbose one above.
85
+
86
+ Please note that `r.require_valid_otp!` redefines `r.arguments` to no longer include the password.
@@ -11,12 +11,11 @@ module Rodbot
11
11
  include Rodbot::Memoize
12
12
 
13
13
  def valid_otp?
14
+ def self.arguments = params['arguments'].sub(/\s*\d{6}\s*\z/, '')
14
15
  return false unless password
15
16
  return false if Rodbot.db.get(:otp, password) # already used
16
- valid = totp.verify(password, drift_behind: Rodbot.config(:otp, :drift).to_i)
17
- !!if
17
+ !!if totp.verify(password, drift_behind: Rodbot.config(:otp, :drift).to_i)
18
18
  Rodbot.db.set(:otp, password) { true }
19
- true
20
19
  end
21
20
  end
22
21
 
@@ -36,8 +35,7 @@ module Rodbot
36
35
  #
37
36
  # @return [String, nil] extracted password if any
38
37
  memoize def password
39
- params['arguments'] = params['arguments']&.sub(/\s*(\d{6})\s*\z/, '')
40
- $1
38
+ params['arguments']&.match(/\s*(\d{6})\s*\z/)&.captures&.first
41
39
  end
42
40
  end
43
41
 
@@ -0,0 +1,48 @@
1
+ # Rodbot Plugin – Slack
2
+
3
+ Relay with the Slack communication network
4
+
5
+ ## Preparation
6
+
7
+ To get an `access_token`, you have to follow the [basic app setup guide](https://api.slack.com/authentication/basics):
8
+
9
+ 1. [Create a new Slack classic app](https://api.slack.com/apps?new_classic_app=1)
10
+ 2. In the overlay: Give the app a name and pick the workspace for the app and the bot.
11
+ 3. In the sidebar: Click on "Basic Information", unfold "Add features and functionality" and hit "Bots". Then click the "Add Legacy Bot User" button and in the overlay enter the display name (used e.g in the user list) and user name (used e.g. for mentions). Optionally activate "Always Show My Bot as Online".
12
+ 4. In the sidebar: Click on "Basic Information" again, scroll down to "Display Information" to set an app icon, color and descriptions. Click "Save Changes" when done".
13
+ 5. Scroll up and click the "Install to Workspace" button, then click "Allow".
14
+ 6. In the sidebar: Click on "Basic Information" again, scroll down to "App Credentials" and copy the "Signing Secret" which will be used as `signing_secret` below.
15
+ 7. In the sidebar: Click on "OAuth and Permissions" and copy the "Bot User OAuth Token" (starting with "xoxb-") which will be used as `access_token` below.
16
+
17
+ With the app in place, open the Slack client with your normal user, then:
18
+
19
+ 1. Select the channel you want the bot to be present in.
20
+ 2. In the upper right corner click on "View all members of this channel".
21
+ 3. Select the "Integrations" tab, then click on "Add apps" and add the app you've just created.
22
+ 4. Select the "About" tab, scroll all the way down and note the `channel_id` to be used below.
23
+
24
+ ## Activation
25
+
26
+ Install the required gems via the corresponding Bundler group:
27
+
28
+ ```
29
+ bundle config set --local with slack
30
+ bundle install
31
+ ```
32
+
33
+ Then activate and configure this plugin in `config/rodbot.rb`:
34
+
35
+ ```ruby
36
+ plugin :slack do
37
+ access_token '<TOKEN>'
38
+ channel_id '<CHANNEL_ID>'
39
+ end
40
+ ```
41
+
42
+ You might want to use the credentials facilities of Rodbot to encrypt the token.
43
+
44
+ ## Usage
45
+
46
+ Once Rodbot is restarted, the Slack relay starts listening. To check whether the relay works fine, just say +!ping+ in the channel, you should receive a "pong" in reply.
47
+
48
+ Any room message beginning with "!" is considered a bot command.
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'slack-ruby-client'
4
+
5
+ using Rodbot::Refinements
6
+
7
+ module Rodbot
8
+ class Plugins
9
+ class Slack
10
+ class Relay < Rodbot::Relay
11
+ include Rodbot::Memoize
12
+
13
+ def loops
14
+ ::Slack.configure do |config|
15
+ config.token = access_token
16
+ end
17
+ [method(:read_loop), method(:write_loop)]
18
+ end
19
+
20
+ private
21
+
22
+ def access_token
23
+ Rodbot.config(:plugin, :slack, :access_token)
24
+ rescue => error
25
+ raise Rodbot::PluginError.new("invalid access_token", error.message)
26
+ end
27
+
28
+ memoize def client
29
+ ::Slack::RealTime::Client.new
30
+ end
31
+
32
+ def channel_id
33
+ Rodbot.config(:plugin, :slack, :channel_id)
34
+ rescue => error
35
+ raise Rodbot::PluginError.new("invalid channel_id", error.message)
36
+ end
37
+
38
+ def write_loop
39
+ server = TCPServer.new(*bind)
40
+ loop do
41
+ Thread.start(server.accept) do |remote|
42
+ body = remote.gets("\x04")
43
+ remote.close
44
+ body.force_encoding('UTF-8')
45
+ client.web_client.chat_postMessage(channel: channel_id, text: body, as_user: true)
46
+ end
47
+ end
48
+ end
49
+
50
+ def read_loop
51
+ client.on :message do |message|
52
+ on_message(message) if message.channel == channel_id
53
+ end
54
+ client.start!
55
+ end
56
+
57
+ def on_message(message)
58
+ if message.text.start_with?('!')
59
+ md = 'pong' if message.text == '!ping'
60
+ md ||= reply_to(message)
61
+ client.web_client.chat_postMessage(channel: message.channel, text: md, as_user: true)
62
+ end
63
+ end
64
+
65
+ def reply_to(message)
66
+ command(*message.text[1..].split(/\s+/, 2)).
67
+ psub(placeholders(message.user))
68
+ end
69
+
70
+ def placeholders(sender)
71
+ {
72
+ sender: "<@#{sender}>"
73
+ }
74
+ end
75
+
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rodbot
4
- VERSION = "0.1.1"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -0,0 +1,9 @@
1
+ # macOS
2
+ .DS_Store
3
+
4
+ # Temporary
5
+ tmp/*
6
+ *.pid
7
+
8
+ # Empty dirs
9
+ !.keep
@@ -0,0 +1 @@
1
+ 3.2
File without changes
@@ -6,6 +6,11 @@ group :matrix, optional: true do
6
6
  gem 'matrix_sdk', '~> 2'
7
7
  end
8
8
 
9
+ group :slack, optional: true do
10
+ gem 'slack-ruby-client', '~> 2'
11
+ gem 'async-websocket', '~> 0.8.0'
12
+ end
13
+
9
14
  group :redis, optional: true do
10
15
  gem 'redis', '~> 5'
11
16
  end
File without changes
File without changes
data/rakefile.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['spec/lib/**/*_spec.rb']
8
+ t.verbose = false
9
+ t.warning = !ENV['RUBYOPT']&.match?(/-W0/)
10
+ end
11
+
12
+ namespace :yard do
13
+ desc "Run local YARD documentation server"
14
+ task :server do
15
+ `rm -rf ./.yardoc`
16
+ Thread.new do
17
+ sleep 2
18
+ `open http://localhost:8808`
19
+ end
20
+ `yard server -r`
21
+ end
22
+ end
23
+
24
+ Rake::Task[:test].enhance do
25
+ if ENV['RUBYOPT']&.match?(/-W0/)
26
+ puts "⚠️ Ruby warnings are disabled, remove -W0 from RUBYOPT to enable."
27
+ end
28
+ end
29
+
30
+ task default: :test
data/rodbot.gemspec ADDED
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/rodbot/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'rodbot'
7
+ spec.version = Rodbot::VERSION
8
+ spec.summary = 'Minimalistic framework to build chat bots on top of a Roda backend'
9
+ spec.description = <<~END
10
+ Just the bare minimum of what's needed to create bi-directional chat bots
11
+ using Roda as backend, sucker_punch and Clockwork for async and timed jobs.
12
+ END
13
+ spec.authors = ['Sven Schwyn']
14
+ spec.email = ['ruby@bitcetera.com']
15
+ spec.homepage = 'https://github.com/svoop/rodbot'
16
+ spec.license = 'MIT'
17
+
18
+ spec.metadata = {
19
+ 'homepage_uri' => spec.homepage,
20
+ 'changelog_uri' => 'https://github.com/svoop/rodbot/blob/main/CHANGELOG.md',
21
+ 'source_code_uri' => 'https://github.com/svoop/rodbot',
22
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/rodbot',
23
+ 'bug_tracker_uri' => 'https://github.com/svoop/rodbot/issues'
24
+ }
25
+
26
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
+ `git ls-files -z`.split("\x0").reject { _1.match? %r{^spec/} }
28
+ end
29
+ spec.require_paths = %w(lib)
30
+ spec.bindir = 'exe'
31
+ spec.executables = %w(rodbot)
32
+
33
+ spec.extra_rdoc_files = Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt']
34
+ spec.rdoc_options += [
35
+ '--title', 'Rodbot',
36
+ '--main', 'README.md',
37
+ '--line-numbers',
38
+ '--inline-source',
39
+ '--quiet'
40
+ ]
41
+
42
+ spec.required_ruby_version = '>= 3.0.0'
43
+
44
+ spec.add_runtime_dependency 'zeitwerk', '~> 2'
45
+ spec.add_runtime_dependency 'dry-cli', '~> 1'
46
+ spec.add_runtime_dependency 'dry-credentials', '~> 0'
47
+ spec.add_runtime_dependency 'tty-markdown', '~> 0'
48
+ spec.add_runtime_dependency 'pastel', '~> 0'
49
+ spec.add_runtime_dependency 'httparty', '~> 0'
50
+ spec.add_runtime_dependency 'puma', '~> 6', '>= 6.2'
51
+ spec.add_runtime_dependency 'roda', '~> 3'
52
+ spec.add_runtime_dependency 'tilt', '~> 2'
53
+ spec.add_runtime_dependency 'kramdown', '~> 2'
54
+ spec.add_runtime_dependency 'kramdown-parser-gfm', '~> 1'
55
+ spec.add_runtime_dependency 'clockwork', '~> 3'
56
+ spec.add_runtime_dependency 'sucker_punch', '~> 3'
57
+ spec.add_runtime_dependency 'debug'
58
+
59
+ # Sync versions with lib/templates/new/gems.rb
60
+ spec.add_development_dependency 'redis', '~> 5'
61
+ spec.add_development_dependency 'rotp', '~> 6'
62
+ spec.add_development_dependency 'matrix_sdk', '~> 2'
63
+ spec.add_development_dependency 'slack-ruby-client', '~> 2'
64
+ spec.add_development_dependency 'async-websocket', '~> 0.8.0'
65
+
66
+ spec.add_development_dependency 'rake'
67
+ spec.add_development_dependency 'minitest'
68
+ spec.add_development_dependency 'minitest-flash'
69
+ spec.add_development_dependency 'minitest-focus'
70
+ spec.add_development_dependency 'minitest-substitute'
71
+ spec.add_development_dependency 'guard'
72
+ spec.add_development_dependency 'guard-minitest'
73
+ spec.add_development_dependency 'yard'
74
+ end
data/tmp/.keep ADDED
File without changes
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.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Schwyn
@@ -29,7 +29,7 @@ cert_chain:
29
29
  kAyiRqgxF4dJviwtqI7mZIomWL63+kXLgjOjMe1SHxfIPo/0ji6+r1p4KYa7o41v
30
30
  fwIwU1MKlFBdsjkd
31
31
  -----END CERTIFICATE-----
32
- date: 2023-09-12 00:00:00.000000000 Z
32
+ date: 2023-10-11 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: zeitwerk
@@ -247,6 +247,20 @@ dependencies:
247
247
  - - "~>"
248
248
  - !ruby/object:Gem::Version
249
249
  version: '5'
250
+ - !ruby/object:Gem::Dependency
251
+ name: rotp
252
+ requirement: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - "~>"
255
+ - !ruby/object:Gem::Version
256
+ version: '6'
257
+ type: :development
258
+ prerelease: false
259
+ version_requirements: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - "~>"
262
+ - !ruby/object:Gem::Version
263
+ version: '6'
250
264
  - !ruby/object:Gem::Dependency
251
265
  name: matrix_sdk
252
266
  requirement: !ruby/object:Gem::Requirement
@@ -262,19 +276,33 @@ dependencies:
262
276
  - !ruby/object:Gem::Version
263
277
  version: '2'
264
278
  - !ruby/object:Gem::Dependency
265
- name: rotp
279
+ name: slack-ruby-client
266
280
  requirement: !ruby/object:Gem::Requirement
267
281
  requirements:
268
282
  - - "~>"
269
283
  - !ruby/object:Gem::Version
270
- version: '6'
284
+ version: '2'
271
285
  type: :development
272
286
  prerelease: false
273
287
  version_requirements: !ruby/object:Gem::Requirement
274
288
  requirements:
275
289
  - - "~>"
276
290
  - !ruby/object:Gem::Version
277
- version: '6'
291
+ version: '2'
292
+ - !ruby/object:Gem::Dependency
293
+ name: async-websocket
294
+ requirement: !ruby/object:Gem::Requirement
295
+ requirements:
296
+ - - "~>"
297
+ - !ruby/object:Gem::Version
298
+ version: 0.8.0
299
+ type: :development
300
+ prerelease: false
301
+ version_requirements: !ruby/object:Gem::Requirement
302
+ requirements:
303
+ - - "~>"
304
+ - !ruby/object:Gem::Version
305
+ version: 0.8.0
278
306
  - !ruby/object:Gem::Dependency
279
307
  name: rake
280
308
  requirement: !ruby/object:Gem::Requirement
@@ -400,10 +428,33 @@ extra_rdoc_files:
400
428
  - CHANGELOG.md
401
429
  - LICENSE.txt
402
430
  files:
431
+ - ".github/workflows/test.yml"
432
+ - ".gitignore"
433
+ - ".ruby-version"
434
+ - ".yardopts"
403
435
  - CHANGELOG.md
404
436
  - LICENSE.txt
405
437
  - README.md
438
+ - bin/console
439
+ - bin/setup
440
+ - checksums/rodbot-0.1.0.gem.sha512
441
+ - checksums/rodbot-0.1.0.pre1.gem.sha512
442
+ - checksums/rodbot-0.1.0.pre2.gem.sha512
443
+ - checksums/rodbot-0.1.0.pre3.gem.sha512
444
+ - checksums/rodbot-0.1.0.pre4.gem.sha512
445
+ - checksums/rodbot-0.1.0.pre5.gem.sha512
446
+ - checksums/rodbot-0.1.0.pre6.gem.sha512
447
+ - checksums/rodbot-0.1.0.pre7.gem.sha512
448
+ - checksums/rodbot-0.1.0.pre8.gem.sha512
449
+ - checksums/rodbot-0.1.0.pre9.gem.sha512
450
+ - checksums/rodbot-0.1.1.gem.sha512
451
+ - checksums/rodbot-0.2.0.gem.sha512
452
+ - checksums/rodbot-0.3.0.gem.sha512
453
+ - doc/rodbot.afphoto
454
+ - doc/rodbot.avif
406
455
  - exe/rodbot
456
+ - gems.rb
457
+ - guardfile.rb
407
458
  - lib/roda/plugins/rodbot.rb
408
459
  - lib/rodbot.rb
409
460
  - lib/rodbot/async.rb
@@ -440,6 +491,8 @@ files:
440
491
  - lib/rodbot/plugins/matrix/relay.rb
441
492
  - lib/rodbot/plugins/otp/README.otp.md
442
493
  - lib/rodbot/plugins/otp/app.rb
494
+ - lib/rodbot/plugins/slack/README.slack.md
495
+ - lib/rodbot/plugins/slack/relay.rb
443
496
  - lib/rodbot/plugins/word_of_the_day/README.word_of_the_day.md
444
497
  - lib/rodbot/plugins/word_of_the_day/schedule.rb
445
498
  - lib/rodbot/rack.rb
@@ -457,20 +510,27 @@ files:
457
510
  - lib/templates/deploy/procfile/Procfile.gerb
458
511
  - lib/templates/deploy/render-split/render.yaml.gerb
459
512
  - lib/templates/deploy/render/render.yaml.gerb
513
+ - lib/templates/new/.gitignore
514
+ - lib/templates/new/.ruby-version
460
515
  - lib/templates/new/README.md
461
516
  - lib/templates/new/app/app.rb
462
517
  - lib/templates/new/app/routes/help.rb
463
518
  - lib/templates/new/app/views/layout.erb
464
519
  - lib/templates/new/app/views/root.erb
465
520
  - lib/templates/new/config.ru
521
+ - lib/templates/new/config/credentials/.keep
466
522
  - lib/templates/new/config/rodbot.rb
467
523
  - lib/templates/new/config/schedule.rb
468
- - lib/templates/new/gems.locked
469
524
  - lib/templates/new/gems.rb
470
525
  - lib/templates/new/guardfile.rb
526
+ - lib/templates/new/lib/.keep
471
527
  - lib/templates/new/public/assets/images/rodbot.avif
472
528
  - lib/templates/new/public/assets/stylesheets/base.css
473
529
  - lib/templates/new/rakefile.rb
530
+ - lib/templates/new/tmp/.keep
531
+ - rakefile.rb
532
+ - rodbot.gemspec
533
+ - tmp/.keep
474
534
  homepage: https://github.com/svoop/rodbot
475
535
  licenses:
476
536
  - MIT
@@ -502,7 +562,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
502
562
  - !ruby/object:Gem::Version
503
563
  version: '0'
504
564
  requirements: []
505
- rubygems_version: 3.4.19
565
+ rubygems_version: 3.4.20
506
566
  signing_key:
507
567
  specification_version: 4
508
568
  summary: Minimalistic framework to build chat bots on top of a Roda backend
metadata.gz.sig CHANGED
Binary file
@@ -1,104 +0,0 @@
1
- PATH
2
- remote: ../../..
3
- specs:
4
- rodbot (0.1.0.pre1)
5
- clockwork (~> 3)
6
- debug
7
- dry-cli (~> 1)
8
- dry-credentials (~> 0)
9
- httparty (~> 0)
10
- kramdown (~> 2)
11
- kramdown-parser-gfm (~> 1)
12
- matrix_sdk (~> 2)
13
- pastel (~> 0)
14
- puma (~> 6, >= 6.2)
15
- roda (~> 3)
16
- rotp (~> 6)
17
- sucker_punch (~> 3)
18
- tilt (~> 2)
19
- tty-markdown (~> 0)
20
- zeitwerk (~> 2)
21
-
22
- GEM
23
- remote: https://rubygems.org/
24
- specs:
25
- activesupport (7.0.4.3)
26
- concurrent-ruby (~> 1.0, >= 1.0.2)
27
- i18n (>= 1.6, < 2)
28
- minitest (>= 5.1)
29
- tzinfo (~> 2.0)
30
- clockwork (3.0.2)
31
- activesupport
32
- tzinfo
33
- concurrent-ruby (1.2.2)
34
- debug (1.8.0)
35
- irb (>= 1.5.0)
36
- reline (>= 0.3.1)
37
- dry-cli (1.0.0)
38
- dry-credentials (0.1.0)
39
- httparty (0.21.0)
40
- mini_mime (>= 1.0.0)
41
- multi_xml (>= 0.5.2)
42
- i18n (1.12.0)
43
- concurrent-ruby (~> 1.0)
44
- io-console (0.6.0)
45
- irb (1.6.4)
46
- reline (>= 0.3.0)
47
- kramdown (2.4.0)
48
- rexml
49
- kramdown-parser-gfm (1.1.0)
50
- kramdown (~> 2.0)
51
- little-plugger (1.1.4)
52
- logging (2.3.1)
53
- little-plugger (~> 1.1)
54
- multi_json (~> 1.14)
55
- matrix_sdk (2.8.0)
56
- logging (~> 2)
57
- mini_mime (1.1.2)
58
- minitest (5.18.0)
59
- multi_json (1.15.0)
60
- multi_xml (0.6.0)
61
- nio4r (2.5.8)
62
- pastel (0.8.0)
63
- tty-color (~> 0.5)
64
- puma (6.2.0)
65
- nio4r (~> 2.0)
66
- rack (3.0.7)
67
- reline (0.3.3)
68
- io-console (~> 0.5)
69
- rexml (3.2.5)
70
- roda (3.66.0)
71
- rack
72
- rotp (6.2.2)
73
- rouge (4.1.0)
74
- strings (0.2.1)
75
- strings-ansi (~> 0.2)
76
- unicode-display_width (>= 1.5, < 3.0)
77
- unicode_utils (~> 1.4)
78
- strings-ansi (0.2.0)
79
- sucker_punch (3.1.0)
80
- concurrent-ruby (~> 1.0)
81
- tilt (2.1.0)
82
- tty-color (0.6.0)
83
- tty-markdown (0.7.2)
84
- kramdown (>= 1.16.2, < 3.0)
85
- pastel (~> 0.8)
86
- rouge (>= 3.14, < 5.0)
87
- strings (~> 0.2.0)
88
- tty-color (~> 0.5)
89
- tty-screen (~> 0.8)
90
- tty-screen (0.8.1)
91
- tzinfo (2.0.6)
92
- concurrent-ruby (~> 1.0)
93
- unicode-display_width (2.4.2)
94
- unicode_utils (1.4.0)
95
- zeitwerk (2.6.7)
96
-
97
- PLATFORMS
98
- arm64-darwin-22
99
-
100
- DEPENDENCIES
101
- rodbot!
102
-
103
- BUNDLED WITH
104
- 2.4.12