rubydium 0.2.1 → 0.2.3

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: b77dd3488fec53db6e8af877924037be855a8e237fe1612de8f66394e418d3cb
4
- data.tar.gz: cafc9b6f3bb0d05707594b40541cb93984fe9c95f69af524dc4a9619b05816d5
3
+ metadata.gz: 538f8c4319a7140a96ed04555a91ddd99aaa9f0d93125c5c9a612cffd8077765
4
+ data.tar.gz: e8c0e25a5c1c3de5ff22065d09f40daea053c98856606d615f660e07083ea47a
5
5
  SHA512:
6
- metadata.gz: 895e9f3f019a273f54587dc754c8e7bc6a93be5f5b655b7bee391d818352ed1a672a933e8e26eb22bba6c55f1252397554b56a0e91d871c5249d6a7466641711
7
- data.tar.gz: cfeb0b7f053ea952881521ed6a60a47341d0804529df2f20d184778772a316ec4064448e3eca3cfec453ad889442fc055b9f149e837162d0c36fb9252fed6949
6
+ metadata.gz: 202c749e8eb3a522c06b3af886b409512fa005eee587bd4a6fcb53be4ac895e04727c8ab5471962a6a4a1433dd5bdaddecf2835a110ffed67c90dc66487236c4
7
+ data.tar.gz: 7ebbfe846222ff22ca618ef8ee2f7309c0b8529bd9d9571911011473a0bf0d24a564ce63b5bba40262558d4f8e1d533927d6f9972f5d70bd102ff09bba25c893
data/lib/rubydium/bot.rb CHANGED
@@ -52,12 +52,6 @@ module Rubydium
52
52
 
53
53
  private
54
54
 
55
- def help_message
56
- self.class.registered_commands.map { |command, info|
57
- "#{command} - #{info[:description]}"
58
- }.join("\n")
59
- end
60
-
61
55
  # For example:
62
56
  # "/start asdf", "/start@yourbot", "/start /another", "asdf /start" will all return "/start".
63
57
  def get_command(text)
@@ -10,6 +10,40 @@ module Rubydium
10
10
  end
11
11
 
12
12
  module ClassMethods
13
+ # Makes these actions work in inheritance as you would expect, i. e.:
14
+ #
15
+ # class ParentBot < Rubydium::Bot
16
+ # on_every_message :foo
17
+ # end
18
+ #
19
+ # class ChildBot < ParentBot
20
+ # on_every_message :bar
21
+ # end
22
+ #
23
+ # class AnotherChildBot < ParentBot
24
+ # on_every_message :baz
25
+ # end
26
+ #
27
+ # ParentBot.registered_on_every_message.map { _1[:action] } # => [:foo]
28
+ # ChildBot.registered_on_every_message.map { _1[:action] } # => [:foo, :bar]
29
+ # AnotherChildBot.registered_on_every_message.map { _1[:action] } # => [:foo, :baz]
30
+ def inherited(subclass)
31
+ %w[
32
+ @registered_on_mention
33
+ @registered_on_every_message
34
+ @registered_commands
35
+ ].each do |var_name|
36
+ current_value_copy = instance_variable_get(var_name).dup
37
+ subclass.instance_variable_set(var_name, current_value_copy)
38
+ end
39
+ end
40
+
41
+ def help_message
42
+ registered_commands.map { |command, info|
43
+ "#{command} - #{info[:description]}"
44
+ }.join("\n")
45
+ end
46
+
13
47
  def on_mention(method_name=nil, ignore_forwarded: true, &block)
14
48
  @registered_on_mention ||= []
15
49
  action = (method_name || block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rubydium
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bulgakke