Refactor search_answer to be dynamically inserted so it can be changed

This commit is contained in:
Robin Ward
2019-10-16 14:36:54 -04:00
parent 5ef49692e0
commit 74207ef03a
3 changed files with 10 additions and 6 deletions

View File

@ -117,7 +117,9 @@ module DiscourseNarrativeBot
}
}
SEARCH_ANSWER = ':herb:'.freeze
def self.search_answer
':herb:'
end
def self.reset_trigger
I18n.t('discourse_narrative_bot.new_user_narrative.reset_trigger')
@ -152,7 +154,7 @@ module DiscourseNarrativeBot
raw = <<~RAW
#{post.raw}
#{I18n.t("#{I18N_KEY}.search.hidden_message", i18n_post_args)}
#{I18n.t("#{I18N_KEY}.search.hidden_message", i18n_post_args.merge(search_answer: NewUserNarrative.search_answer))}
RAW
PostRevisor.new(post, topic).revise!(
@ -495,7 +497,7 @@ module DiscourseNarrativeBot
post_topic_id = @post.topic_id
return unless valid_topic?(post_topic_id)
if @post.raw.match(/#{SEARCH_ANSWER}/)
if @post.raw.match(/#{NewUserNarrative.search_answer}/)
fake_delay
reply_to(@post, I18n.t("#{I18N_KEY}.search.reply", i18n_post_args(search_url: url_helpers(:search_url))))
else