FEATURE: Add hidden site settings for discobot to skip certain tutorials

FEATURE: Add hidden site settings for discobot to skip certain tutorials

Hidden for now because I’m undecided on whether this should be an exposed interface.

diff --git a/plugins/discourse-narrative-bot/config/locales/server.en.yml b/plugins/discourse-narrative-bot/config/locales/server.en.yml
index 38bad9a..76efd5a 100644
--- a/plugins/discourse-narrative-bot/config/locales/server.en.yml
+++ b/plugins/discourse-narrative-bot/config/locales/server.en.yml
@@ -6,6 +6,7 @@ en:
     discourse_narrative_bot_disable_public_replies: "Disable public replies by Discourse Narrative Bot"
     discourse_narrative_bot_welcome_post_type: "Type of welcome post that the Discourse Narrative Bot should send out"
     discourse_narrative_bot_welcome_post_delay: "Wait (n) seconds before sending the Discourse Narrative Bot welcome post."
+    discourse_narrative_bot_skip_tutorials: "Discourse Narrative Bot tutorials to skip"
 
   badges:
     certified:
diff --git a/plugins/discourse-narrative-bot/config/settings.yml b/plugins/discourse-narrative-bot/config/settings.yml
index c33d382..45d65bf 100644
--- a/plugins/discourse-narrative-bot/config/settings.yml
+++ b/plugins/discourse-narrative-bot/config/settings.yml
@@ -7,6 +7,10 @@ plugins:
   discourse_narrative_bot_welcome_post_type:
     default: 'new_user_track'
     enum: 'DiscourseNarrativeBot::WelcomePostTypeSiteSetting'
+  discourse_narrative_bot_skip_tutorials:
+    default: ''
+    type: list
+    hidden: true
   discourse_narrative_bot_welcome_post_delay:
     default: 0
   discourse_narrative_bot_ignored_usernames:
diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
index 404dd08..358f596 100644
--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
@@ -30,7 +30,12 @@ module DiscourseNarrativeBot
             next_opts = self.class::TRANSITION_TABLE.fetch(next_state)
             prerequisite = next_opts[:prerequisite]
 
-            break if !prerequisite || instance_eval(&prerequisite)
+            if (!prerequisite || instance_eval(&prerequisite)) && !(
+              SiteSetting.discourse_narrative_bot_skip_tutorials.present? &&
+              SiteSetting.discourse_narrative_bot_skip_tutorials.split("|").include?(next_state.to_s))
+
+              break
+            end
 
             [:next_state, :next_instructions].each do |key|
               opts[key] = next_opts[key]
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
index 788d314..9c3b5b7 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
@@ -266,6 +266,16 @@ describe DiscourseNarrativeBot::NewUserNarrative do
         expect(new_post.raw).to eq(expected_raw.chomp)
         expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_onebox)
       end
+
+      it 'should skip tutorials in SiteSetting.discourse_narrative_bot_skip_tutorials' do
+        SiteSetting.discourse_narrative_bot_skip_tutorials = 'tutorial_onebox'
+
+        post.update!(raw: "@#{discobot_username} #{skip_trigger.upcase}")
+
+        DiscourseNarrativeBot::TrackSelector.new(:reply, user, post_id: post.id).select
+
+        expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_emoji)
+      end
     end
 
     describe 'onebox tutorial' do

GitHub sha: 75ad0718