diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-07-27 12:35:28 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:16 -0500 |
commit | 2fdc484caa2d6471116a28997bb0b7e04df6870e (patch) | |
tree | 89ca53ce7b4ac9fd76ea4fa2222860ed5e67af84 /app/lib/command_tag/processor.rb | |
parent | 6adde25fb53594235ea1cae5216a3dfdd54ffef1 (diff) |
[Command Tags] Add support for module initialization
Diffstat (limited to 'app/lib/command_tag/processor.rb')
-rw-r--r-- | app/lib/command_tag/processor.rb | 8 |
1 files changed, 8 insertions, 0 deletions
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#!") |