diff options
-rw-r--r-- | app/lib/command_tag/commands/hello_world.rb | 4 | ||||
-rw-r--r-- | app/lib/command_tag/processor.rb | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/app/lib/command_tag/commands/hello_world.rb b/app/lib/command_tag/commands/hello_world.rb index 581b21317..2341d22e2 100644 --- a/app/lib/command_tag/commands/hello_world.rb +++ b/app/lib/command_tag/commands/hello_world.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true module CommandTag::Commands::HelloWorld + def initialize_helloworld! + @vars['hello_world'] = ['Hello, world!'] + end + def handle_hello_world_at_start(_) @text << "\nHello, world!" end diff --git a/app/lib/command_tag/processor.rb b/app/lib/command_tag/processor.rb index cbe5345c0..0ec088e55 100644 --- a/app/lib/command_tag/processor.rb +++ b/app/lib/command_tag/processor.rb @@ -40,6 +40,8 @@ class CommandTag::Processor def process! reset_status_caches + initialize_handlers! + parse_statements %w(at_start once_at_start).each { |suffix| execute_statements(suffix) } @@ -72,6 +74,12 @@ class CommandTag::Processor private + def initialize_handlers! + self.class.instance_methods.grep(/\Ainitialize_\w+!\z/).each do |name| + public_send(name) + end + end + def prepare_input(text) text.gsub(/\r\n|\n\r|\r/, "\n") .gsub(/^\s*((?:(?:#{Account::MENTION_RE}|#{Tag::HASHTAG_RE})\s*)+)#!/, "\\1\n#!") |